A quick guide on how to install PostgreSQL 10 on Centos 7. vCloud Director 9.5 officially supports PostgreSQL 10 and I thought I would setup a new database server to migrate my existing vCloud SQL database over too.
VMware recommends the database server is built with 16 GB of memory, 100 GB storage, and 4 CPUs.
Deploy a basic Centos 7 VM and update the OS, then connect to the VM via SSH using Putty. If you have updated the OS then chances are open-vm-tools has been installed but run the following command to confirm.
yum install -y open-vm-tools
Next restart the Centos VM before continuing.
Then run the following command to retrieve the PostgreSQL 10 RPM.
rpm -ivh http://yum.postgresql.org/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
Then run the following command to install PostgreSQL.
yum install net-tools postgresql10 postgresql10-server postgresql10-libs postgresql10-contrib
Type Y and press Enter to continue
Next we need to change the default PostgreSQL password. To do so enter the following command.
passwd postgres
Then enter your new password.
The next thing we need to do is configure PostgreSQL to start on boot up. To do this enter browse to the following directory.
cd /usr/pgsql-10/bin/
Then run the command below.
./postgresql-10-setup initdb
Next we need to start the PostgreSQL service, to do this enter the following.
systemctl start postgresql-10.service
Then to enable the PostgreSQL service enter the following command.
systemctl enable postgresql-10.service
Switch over to the postres user by running the following command
sudo -u postgres -i
Then we create the vcloud user and database by issuing the following commands (one after the other). Please replace password123 with the password that you would like to use.
psql
create user vcloud
alter user vcloud password ‘password123’
alter role vcloud with login
create database vcloud;
grant all privileges on database vcloud to vcloud
A good way to check that the DB was created is to run the following command.
\l+ or \list+
Type \q and press Enter
Type su and enter the root password to switch back to the root user account
Then we need to allow PostgreSQL connections through the default firewall configuration
Next its time to allow the vcloud user to login. To do this we need to add a line to the pg_hba.conf file.
Enter the command below to edit the file.
vi /var/lib/pgsql/10/data/pg_hba.conf
Then add the following line as per below. Lock down the address access to suit your current deployment. As mine is currently in my lab I just allowed the range for this example.
Host vcloud vcloud 192.168.1.0/24 md5
Next we need to setup the PostgreSQL listening port and IP address. To do this we need to edit the postgres.conf file.
Run the following command to edit the file.
vi /var/lib/pgsql/10/data/postgres.conf
Remove the # in front of listen_addresses and the port. Then after listen_addresses change ‘localhost’ to ‘*’
listen_address = ‘*’
port= 5432
It should look like the below image after making the changes.
Press Esc and then type :wq and press Enter to save the changes you just made.
Now its time to install NTP and configure the required settings. Run the following command.
yum install ntp
You will be prompted to press Y to complete the install.
You need to configure the NTP server for each of the vCloud Director servers, including the database server. The maximum allowed time drift is 2 seconds.
Enter the following to edit the NTP configuration.
vi /etc/ntp.conf
Scroll down to the list of public servers and update it to the ntp servers you would like set. For now I will just set the following.
Next we need to start and enable the ntpd service by entering the following commands.
systemctl start ntpd
systemctl enable ntpd
Then we need to ensure that ntpd is running by entering the following command.
systemctl status ntpd
Ensure that each of your DNS entries have been set for the database server and vCloud Director cells.
Last step is to turn off selinux, you can do that we need to edit the following file.
vi /etc/sysconfig/selinux Change SELINUX=enforcing to SELINUX=disabled
Then reboot the server to complete the installation.
VMware also offer some performance tuning options for previous versions here
Once you have completed your installation another good tip is to deploy PGAdmin. It provides a great web interface and helps make the transition from SQL to PostgreSQL a little easier. I have provided a link to the PGAdmin site here
I hope this has been helpful for those of you looking to move your current vCloud Director SQL databases over to PostgreSQL.