I use FreeBSD Jails. I use them a lot. I have jails for websites. I have jails for regression testing, mail servers, OpenVPN servers, etc. I like jails for many reasons. One of which is being able to create a new jail which is pretty much identical to another jail, except for a few things.
In this case, I wanted to create a new jail to do regression testing for Bacula, the best backup solution around. Existing jails ran tests for MySQL 5.1, MySQL 5.5, PostgreSQL 8.4, PostgreSQL 9.0, and PostgreSQL 9.2. I wanted to start regression testing on PostgreSQL 9.3. I started by cloning the 9.2 jail:
# ezjail-admin stop pg92.example.org # ezjail-admin archive pg92.example.org # ezjail-admin create -a /usr/jails/ezjail_archives/pg92_example_org-201310141916.06.tar.gz pg93.example.org 10.55.0.106
NOTE: I typed those commands from memory; they may be incorrect, but worst case: they’re a good starting point for you.
Then I connected to the console and amended the hostname in /etc/r.conf, upgraded the client, dumped database and globals file, stopped postgresql, upgraded the server, reimported.
# portugrade -o databases/postgresql93-client postgresql-client # pg_dumpall > dump.sql # pg_dumpall --globals > globals.sql # service postgresql stop # cd /usr/local/pgsql # mv data 92.DELETEME # portugrade -o databases/postgresql93-server postgresql-server # /usr/local/etc/rc.d/postgresql initdb # /usr/local/etc/rc.d/postgresql start # su pgsql $ psql template1 < globals.sql $ psql template1 < dump.sql
Everything went smoothly.
Except for pg92, which would start, but I couldn't do anything with it. Nagios was reporting:
CRITICAL - no connection to 'template1' (FATAL: semctl(36438029, 3, SETVAL, 0) failed: Invalid argument
Attempts to access the database gave this error:
$ psql -l psql: FATAL: semctl(36700173, 3, SETVAL, 0) failed: Invalid argument
I left that overnight, figuring I had to bump some boot parameters to cater for the additional PostgreSQL instance running on this server. I was wrong. Googling for that error message, I came across my article on running multiple jails. Oh yeah, you can't have the same UID for PostgreSQL in each jail.
Oh that's easily solved.
I chose to alter the UID in pg92, because that's the one which was not running. I changed both the UID in /etc/passwd and the GID in /etc/group. Then I ran:
chown -R pgsql:pgsql /usr/local/pgsql
Hope that helps you.