Postgres and selinux 

Saturday, June 02, 2007 11:58:25 AM

Had a little fun today getting progresql working in a directory other than /var/lib/pgsql on a CentOS 5.0 system with selinux enabled.

The actual intention is to use lvm snapshot to backup the database.  So rather than mount the dedicated partition to /var/lib/pgsql, I decided to mount it to /pgsql instead.

I added these lines to
/etc/selinux/targeted/contexts/files/file_contexts

/pgsql/data(/.*)?     system_u:object_r:postgresql_db_t:s0
/pgsql        system_u:object_r:postgresql_db_t:s0
/pgsql/pgstartup\.log system_u:object_r:postgresql_log_t:s0

Then I fixed the files in the new location

/sbin/fixfiles check /pgsql
/sbin/fixfiles restore /pgsql

Finally updated  /etc/init.d/postgresql

PGDATA=/pgsql/data
PGLOG=/pgsql/pgstartup.log

Most likely I will decide that not mounting on /var/lib/pgsql is a bad idea, but I would like to be able to start parallel servers that point to snapshots at some time in the future.



Comments are closed on this post.