Appendix D. Preparing a Remote PostgreSQL Database
By default, the Manager’s configuration script, engine-setup, creates and configures the Manager database locally on the Manager machine. For automatic database configuration, see Section 2.3, “Configuring the Red Hat Virtualization Manager”.
To set up the Manager database with custom values on the Manager machine, see Appendix E, Preparing a Local Manually-Configured PostgreSQL Database. You should set up a Manager database before you configure the Manager. You must supply the database credentials during engine-setup.
The Data Warehouse’s configuration script offers the choice of creating a local or remote database. However, situations may arise where you might want to configure a remote database for Data Warehouse manually.
Use this procedure to configure the database on a machine that is separate from the machine where the Manager is installed.
The engine-setup and engine-backup --mode=restore commands only support system error messages in the en_US.UTF8 locale, even if the system locale is different.
The locale settings in the postgresql.conf file must be set to en_US.UTF8.
The database name must contain only numbers, underscores, and lowercase letters.
Enabling the Red Hat Virtualization Manager Repositories
Register the system with Red Hat Subscription Manager, attach the Red Hat Enterprise Linux Server and Red Hat Virtualization subscriptions, and enable the Manager repositories.
Procedure
Register your system with the Content Delivery Network, entering your Customer Portal user name and password when prompted:
subscription-manager register
# subscription-manager registerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Find the
Red Hat Enterprise Linux ServerandRed Hat Virtualizationsubscription pools and record the pool IDs:subscription-manager list --available
# subscription-manager list --availableCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the pool IDs to attach the subscriptions to the system:
subscription-manager attach --pool=pool_id
# subscription-manager attach --pool=pool_idCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteTo view currently attached subscriptions:
subscription-manager list --consumed
# subscription-manager list --consumedCopy to Clipboard Copied! Toggle word wrap Toggle overflow To list all enabled repositories:
yum repolist
# yum repolistCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the repositories:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Initializing the PostgreSQL Database
Install the PostgreSQL server package:
yum install rh-postgresql95 rh-postgresql95-postgresql-contrib
# yum install rh-postgresql95 rh-postgresql95-postgresql-contribCopy to Clipboard Copied! Toggle word wrap Toggle overflow Initialize the PostgreSQL database, start the
postgresqlservice, and ensure that this service starts on boot:scl enable rh-postgresql95 -- postgresql-setup --initdb systemctl enable rh-postgresql95-postgresql systemctl start rh-postgresql95-postgresql
# scl enable rh-postgresql95 -- postgresql-setup --initdb # systemctl enable rh-postgresql95-postgresql # systemctl start rh-postgresql95-postgresqlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Connect to the
psqlcommand line interface as thepostgresuser:su - postgres -c 'scl enable rh-postgresql95 -- psql'
su - postgres -c 'scl enable rh-postgresql95 -- psql'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a default user. The Manager’s default user is
engineand the Data Warehouse’s default user isovirt_engine_history:postgres=# create role user_name with login encrypted password 'password';
postgres=# create role user_name with login encrypted password 'password';Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a database. The Manager’s default database name is
engineand Data Warehouse’s default database name isovirt_engine_history:postgres=# create database database_name owner user_name template template0 encoding 'UTF8' lc_collate 'en_US.UTF-8' lc_ctype 'en_US.UTF-8';
postgres=# create database database_name owner user_name template template0 encoding 'UTF8' lc_collate 'en_US.UTF-8' lc_ctype 'en_US.UTF-8';Copy to Clipboard Copied! Toggle word wrap Toggle overflow Connect to the new database:
postgres=# \c database_name
postgres=# \c database_nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
uuid-osspextension:database_name=# CREATE EXTENSION "uuid-ossp";
database_name=# CREATE EXTENSION "uuid-ossp";Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
plpgsqllanguage if it does not exist:database_name=# CREATE LANGUAGE plpgsql;
database_name=# CREATE LANGUAGE plpgsql;Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure the database can be accessed remotely by enabling md5 client authentication. Edit the /var/lib/pgsql/data/pg_hba.conf file, and add the following line immediately underneath the line starting with
localat the bottom of the file, replacingX.X.X.Xwith the IP address of the Manager or the Data Warehouse machine:host database_name user_name ::0/32 md5 host database_name user_name ::0/128 md5
host database_name user_name ::0/32 md5 host database_name user_name ::0/128 md5Copy to Clipboard Copied! Toggle word wrap Toggle overflow Allow TCP/IP connections to the database. Edit the /var/opt/rh/rh-postgresql95/lib/pgsql/data/postgresql.conf file and add the following line:
listen_addresses='*'
listen_addresses='*'Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example configures the
postgresqlservice to listen for connections on all interfaces. You can specify an interface by giving its IP address.Update the PostgreSQL server’s configuration. Edit the /var/opt/rh/rh-postgresql95/lib/pgsql/data/postgresql.conf file and add the following lines:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Open the default port used for PostgreSQL database connections, and save the updated firewall rules:
firewall-cmd --zone=public --add-service=postgresql firewall-cmd --permanent --zone=public --add-service=postgresql
# firewall-cmd --zone=public --add-service=postgresql # firewall-cmd --permanent --zone=public --add-service=postgresqlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
postgresqlservice:systemctl rh-postgresql95-postgresql restart
# systemctl rh-postgresql95-postgresql restartCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Optionally, set up SSL to secure database connections using the instructions at http://www.postgresql.org/docs/9.5/static/ssl-tcp.html#SSL-FILE-USAGE.