With vCloud Director 9.0, VMware introduced postgres as supported database for vCD. If you are planning to use postgres as DB, then you should install Postgres v 9.5 on a supported OS.
In our last Post I mentioned that I purposefully configured MSSQL as DB from my new vCD 9.0 installation, as I wanted to test the migration of vCDDB from MSSQL to Postgres. This post is focused on how to do so.
If you are new to postgres and do not know how to install it, then follow this blog for installation instructions which are pretty easy and straight forward.
Once you have installed postgres and started services, next is to create database for vCD. Follow below commands to do so
1: Create Database
1 2 |
postgres=# CREATE DATABASE vcloud; CREATE DATABASE |
2: Verify presence of newly created database
1 2 3 4 5 6 7 8 9 10 11 |
postgres=# l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+---------+-------+----------------------- postgres | postgres | UTF8 | C | C | template0 | postgres | UTF8 | C | C | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | C | C | =c/postgres + | | | | | postgres=CTc/postgres vcloud | postgres | UTF8 | C | C | (4 rows) |
3: Create vCloud user and assign password to user
1 2 3 4 5 |
postgres=# create user vcloud; CREATE ROLE postgres=# alter user vcloud password 'Telstra@123'; ALTER ROLE |
4: Enable the database owner to log in to the database
1 2 |
postgres=# alter role vcloud with login; ALTER ROLE |
5: Grant full permission to vCloud user to vCloud database
1 2 |
postgres=# grant all privileges on database vcloud to vcloud; GRANT |
6: Test the vcloud user access to database
1 2 3 4 5 |
postgres@vpostgre-mgmtdb-a:~> psql -d vcloud -U vcloud psql.bin (9.3.6 (VMware Postgres 9.3.6.0-2686691 release)) Type "help" for help. vcloud=> |
Make sure your postgresql.conf and pg_hba.conf looks like below
1 2 3 4 5 6 7 8 9 |
[root@vcddb-postgres01 data]# grep -iE "listen_addresses|port" /var/lib/pgsql/9.5/data/postgresql.conf listen_addresses = '*' port = 5432 [root@vcddb-postgres01 data]# cat /var/lib/pgsql/9.5/data/pg_hba.conf # "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 0.0.0.0/0 trust |
Now we are done with DB creation/configuration task. Next is to perform the migration of database. Unfortunately there is not much info given about this task in vCD 9.0 documentation.
I managed to find the way while playing around in my lab. Database migration is done using the cell management utility which is present in /opt/vmware/vcloud-director/bin directory. We need to use dbmigrate command line option with cell-management-tool.
To see list of supported options run this query
# /opt/vmware/vcloud-director/bin/cell-management-tool dbmigrate –help
Once you have reviewed the available options, use following command to do the db migration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@vcd90 ~]# /opt/vmware/vcloud-director/bin/cell-management-tool dbmigrate --database-host 192.168.109.54 --database-name vcloud --database-user vcloud --database-port 5432 Target DB - Enter password: Configuring the target database... ......................................../ Successfully configured the target database. Target database is using PostgreSQL version 9.5.9. Blacklisted licensing_vm_data. Finished clearing tables for migration. Beginning database migration. .............................................................................................................................................................................................................................................................. Database migration succeeded. SUCCESS:254 FAILED:0 SKIPPED:0 To start using this database, run the cell-management-tool reconfigure-database command on each cell in your server group by executing the following command with the migrated databases connection properties: /opt/vmware/vcloud-director/bin/cell-management-tool reconfigure-database |
Run the reconfigure-database command
1 2 |
[root@vcd90 ~]# /opt/vmware/vcloud-director/bin/cell-management-tool reconfigure-database Database configuration complete for local cell. |
And that’s it. You can now login to postgres db and verify the tables etc.
Additional Reading
What’s New in Vcloud Director 9.0
vCloud Director 9.0 Single Cell Installation
I hope you find this post informational. Feel free to share this on social media if it is worth sharing. Be sociable 🙂