Friday, October 24, 2014

CentOS 7 install PostgreSQL 9.2.7 with data files on SSD

CentOS 7 is much much newer than 6, highly recommended fro any new "Enterprise" build.

It came with the PostgreSQL is 9.2.7, the latest stable is 9.3.5 from PostgreSQL.org at this moment.
I say 9.2 is good enough for me considering the works RedHat has been done to make it fit.

To install it is super easy:

yum install postgresql-server.x86_64



Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/2): extras/7/x86_64/primary_db | 33 kB 00:00:00
(2/2): updates/7/x86_64/primary_db | 3.6 MB 00:00:00
Loading mirror speeds from cached hostfile
* base: centos.mirror.rafal.ca
* extras: mirror.netflash.net
* updates: centos.mirror.nexicom.net
Resolving Dependencies
--> Running transaction check
---> Package postgresql-server.x86_64 0:9.2.7-1.el7 will be installed
--> Processing Dependency: postgresql-libs(x86-64) = 9.2.7-1.el7 for package: postgresql-server-9.2.7-1.el7.x86_64
--> Processing Dependency: postgresql(x86-64) = 9.2.7-1.el7 for package: postgresql-server-9.2.7-1.el7.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql-server-9.2.7-1.el7.x86_64
--> Running transaction check
---> Package postgresql.x86_64 0:9.2.7-1.el7 will be installed
---> Package postgresql-libs.x86_64 0:9.2.7-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================
Installing:
postgresql-server x86_64 9.2.7-1.el7 base 3.8 M
Installing for dependencies:
postgresql x86_64 9.2.7-1.el7 base 2.9 M
postgresql-libs x86_64 9.2.7-1.el7 base 229 k

Transaction Summary
=======================================================================================================================================
Install 1 Package (+2 Dependent packages)

Total download size: 6.9 M
Installed size: 32 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): postgresql-libs-9.2.7-1.el7.x86_64.rpm | 229 kB 00:00:00
(2/3): postgresql-9.2.7-1.el7.x86_64.rpm | 2.9 MB 00:00:00
(3/3): postgresql-server-9.2.7-1.el7.x86_64.rpm | 3.8 MB 00:00:00
---------------------------------------------------------------------------------------------------------------------------------------
Total 7.2 MB/s | 6.9 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : postgresql-libs-9.2.7-1.el7.x86_64 1/3
Installing : postgresql-9.2.7-1.el7.x86_64 2/3
Installing : postgresql-server-9.2.7-1.el7.x86_64 3/3
Verifying : postgresql-libs-9.2.7-1.el7.x86_64 1/3
Verifying : postgresql-server-9.2.7-1.el7.x86_64 2/3
Verifying : postgresql-9.2.7-1.el7.x86_64 3/3

Installed:
postgresql-server.x86_64 0:9.2.7-1.el7

Dependency Installed:
postgresql.x86_64 0:9.2.7-1.el7 postgresql-libs.x86_64 0:9.2.7-1.el7

Complete!


Mount the data directory on SSD

First check the permission:

ls -alt /var/lib/pgsql/
drwx------. 2 postgres postgres 6 Jun 10 03:49 backups
drwx------. 2 postgres postgres 6 Jun 10 03:49 data


Add in /etc/fstab:

/dev/mapper/VG_Backup-LV_Backup /var/lib/pgsql/backups xfs defaults 0 0
/dev/mapper/VG_SSD00-LV_SSD_Database /var/lib/pgsql/data xfs defaults 0 0


Mount it manually:

mount /var/lib/pgsql/data
mount /var/lib/pgsql/backups


Change the permission:

chown postgres:postgres /var/lib/pgsql/data
chown postgres:postgres /var/lib/pgsql/backups


And don't forget reboot check permission:

# ls -alt /var/lib/pgsql
total 8
drwxr-xr-x. 26 root root 4096 Oct 23 16:42 ..
drwx------. 4 postgres postgres 51 Oct 23 16:35 .
drwxr-xr-x. 2 postgres postgres 6 Oct 23 16:29 data
drwxr-xr-x. 2 postgres postgres 6 Oct 23 15:59 backups
-rw-r--r--. 1 postgres postgres 85 Jun 10 03:49 .bash_profile

No comments:

Post a Comment