Running the same service (apache, mysql) in multiple jails

I am running a few jails via ezjail. Nginx and pf on the main host take care of routing incoming requests to the appropriate jail.
Each jail needs to run different instances of the same service - Apache and MySQL.

Please help me get the set up right for doing this^^.

As far as I understand, since jails share the same network stack as the host, so all the mysql instances infact depend on the same port. Is this a problem? Would there be a tangible benefit to running each mysql instance on a different port number?

When I check the output of top each mysqld instance seems to have the exact same amount of memory consumption. Why/how is that - is the mysql memory somehow shared? Would there be a benefit to restricting the amount of memory each jail can consume?

What else should I take care of when doing this - running the same service in different jails?
 
As far as I understand, since jails share the same network stack as the host, so all the mysql instances infact depend on the same port. Is this a problem?
Not exactly. Services bind to an IP address and port. Most services will bind to 0.0.0.0 by default. This means it's going to be listening on all available IP addresses. Simply bind each jailed service to the specific jail's IP address and there won't be a conflict.

When I check the output of [BGCOLOR=#dee3e7] top[/BGCOLOR] each mysqld instance seems to have the exact same amount of memory consumption. Why/how is that - is the mysql memory somehow shared? Would there be a benefit to restricting the amount of memory each jail can consume?
I would suggest just using a single MySQL instance and make sure each site has its own databases and user accounts. Obviously, you don't give the user accounts for a specific database access to any other database. You also don't give any of those user accounts the GRANT privilege.
 
Would there be a benefit to restricting the amount of memory each jail can consume?
It may not be a good decision. Your DB will grow as time goes by. You may rather want to tweak other MySQL variables - using INNODB over MYISAM, adjust INNODB table size and so on.
 
Back
Top