Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 2. Setting up Databases
2.1. Configuring PostgreSQL Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Running Red Hat JBoss Operations Network with PostgreSQL requires three things:
- Adequate PostgreSQL settings for memory, timeouts, connections, and related settings
- A database
- A user with adequate permissions
JBoss ON supports PostgreSQL 8.4.x, 9.0.x, 9.1.x, 9.2.x, 9.3.x*, 9.4.x*, 9.5.x*
* Support added by JBoss ON 3.3 Update 06.
2.1.1. Installing PostgreSQL Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
You can download the Microsoft Windows binaries you need from: https://www.postgresql.org/download/windows/
Use YUM to install PostgreSQL:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
To install a specific version of PostgreSQL, go to: https://yum.postgresql.org/rpmchart.php and download the postgresql, postgresql-server and postgresql-libs RPM packages and install via yum from the download directory. For example:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
sudo yum install postgresql postgresql-server
sudo yum install postgresql postgresql-server
sudo yum install postgresql91-9.1.24-2PGDG.rhel6.x86_64.rpm postgresql91-libs-9.1.24-2PGDG.rhel6.x86_64.rpm postgresql91-server-9.1.24-2PGDG.rhel6.x86_64.rpm
sudo yum install
postgresql91-9.1.24-2PGDG.rhel6.x86_64.rpm
postgresql91-libs-9.1.24-2PGDG.rhel6.x86_64.rpm
postgresql91-server-9.1.24-2PGDG.rhel6.x86_64.rpm
2.1.2. Configuring PostgreSQL Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Important
The following configuration is provided as an example of configuring this server quickly for a JBoss ON testing environment. Suggested values in these procedures are not be used in production environments. The procedure is not be used as a supported way of configuring a production server. Always follow the database provider configuration instructions carefully when configuring a production environment.
For detailed information about setting up client authentication for PostgreSQL users and databases, see the PostgreSQL documentation for the supported version at http://www.postgresql.org/docs/8.4/interactive/client-authentication.html.
Note
Ensure that the Postgres authentication mechanism is properly configured for the configuration commands to work.
- Optional. Change the password for the Unix user for PostgreSQL:
sudo passwd postgres
sudo passwd postgresCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Initialize the PostgreSQL database. The database must be initialized before starting the server.
- For installs using Red Hat Enterprise Linux 6 (and earlier) repositories:
sudo service postgresql initdb
sudo service postgresql initdbCopy to Clipboard Copied! Toggle word wrap Toggle overflow - For installs using downloaded binaries on Red Hat Enterprise Linux 6 (and earlier):
sudo service postgresql-<version> initdb
sudo service postgresql-<version> initdbCopy to Clipboard Copied! Toggle word wrap Toggle overflow Where: <version> = <major>.<minor>For example:sudo service postgresql-9.2 initdb
sudo service postgresql-9.2 initdbCopy to Clipboard Copied! Toggle word wrap Toggle overflow - For installs using Red Hat Enterprise Linux 7 (and later) repositories:
sudo /usr/bin/postgresql-setup initdb
sudo /usr/bin/postgresql-setup initdbCopy to Clipboard Copied! Toggle word wrap Toggle overflow - For installs using downloaded binaries on Red Hat Enterprise Linux 7 (and later):
sudo /usr/pgsql-<version>bin/postgresql<version_short>-setup initdb
sudo /usr/pgsql-<version>bin/postgresql<version_short>-setup initdbCopy to Clipboard Copied! Toggle word wrap Toggle overflow Where: <version_short> = <major><minor>For example:sudo /usr/pgsql-9.2/bin/postgresql92-setup initdb
sudo /usr/pgsql-9.2/bin/postgresql92-setup initdbCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- Start the PostgreSQL service.
- On Red Hat Enterprise Linux 6 (and earlier) using repository install:
sudo service postgresql start sudo chkconfig postgresql on
sudo service postgresql start sudo chkconfig postgresql onCopy to Clipboard Copied! Toggle word wrap Toggle overflow - On Red Hat Enterprise Linux 6 (and earlier) using downloaded binaries:
sudo service postgresql-<version> start sudo chkconfig postgresql-<version> on
sudo service postgresql-<version> start sudo chkconfig postgresql-<version> onCopy to Clipboard Copied! Toggle word wrap Toggle overflow - On Red Hat Enterprise Linux 7 (and later) using repository install:
sudo systemctl enable postgresql.service sudo systemctl start postgresql.service
sudo systemctl enable postgresql.service sudo systemctl start postgresql.serviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow - On Red Hat Enterprise Linux 7 (and later) using downloaded binaries:
sudo systemctl enable postgresql-<version>.service sudo systemctl start postgresql-<version>.service
sudo systemctl enable postgresql-<version>.service sudo systemctl start postgresql-<version>.serviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow - On Microsoft Windows:
net start pgsql-<version>
net start pgsql-<version>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Set up a password for the
postgresuser on the database:su - postgres psql
# su - postgres $ psql postgres=# ALTER USER postgres PASSWORD 'password'; ALTER ROLECopy to Clipboard Copied! Toggle word wrap Toggle overflow - Create a PostgreSQL role named rhqadmin, where 'password' should be replaced with a strong password.
postgres=# CREATE USER rhqadmin PASSWORD 'password'; CREATE ROLE
postgres=# CREATE USER rhqadmin PASSWORD 'password'; CREATE ROLECopy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantAlthough the default postgresql credentials expected by rhqctl are user rhqadmin and password rhqadmin, these credentials should not be used as they present a security risk. The relevant change to rhqctl is covered in Section 3.6, “About the rhqctl Script”. - Create a PostgreSQL database named rhq, specifying the rhqadmin role as the owner.
postgres=# CREATE DATABASE rhq OWNER rhqadmin; CREATE DATABASE
postgres=# CREATE DATABASE rhq OWNER rhqadmin; CREATE DATABASECopy to Clipboard Copied! Toggle word wrap Toggle overflow - Use the following command to locate the
pg_hba.conf file:postgres=# SHOW hba_file;
postgres=# SHOW hba_file;Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Use \q to quit psql.
- Give users on the computer access to the database. To allow all users, add the appropriate connection settings for each connection type (local, IPv4, and IPv6) to the
data/pg_hba.confconfiguration file, for both local and external connections:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Using all all sets these settings for every user to every PostgreSQL database. This settings can be applied to only the JBoss ON database by using rhq all or even to specific users for JBoss ON, such as rhq rhqadmin. Changing the METHOD values to md5 ensures passwords are encrypted, not sent as plain text. - Restart the database service.
- On Red Hat Enterprise Linux 6 (and earlier):
sudo service postgresql restart
sudo service postgresql restartCopy to Clipboard Copied! Toggle word wrap Toggle overflow - On Red Hat Enterprise Linux 7 (and later):
sudo systemctl restart postgresql
sudo systemctl restart postgresqlCopy to Clipboard Copied! Toggle word wrap Toggle overflow - On Red Hat Enterprise Linux 7 (and later) using downloaded binaries:
sudo systemctl restart postgresql-<version>
sudo systemctl restart postgresql-<version>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Make the configuration changes in Section 2.1.3, “Setting PostgreSQL Parameters”.
2.1.3. Setting PostgreSQL Parameters Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
There are several settings in the PostgreSQL server configuration that can be tuned to provide better performance for JBoss ON.
2.1.3.1. Editing the postgresql.conf File Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
PostgreSQL requires minor changes to the database configuration in the
postgresql.conf file.
- Make sure that an adequate amount of memory and system resources are assigned to accommodate the JBoss ON database.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe parameterstatement_timeoutshould not be set. Ifpostgressql.confcontains a statement_timeout parameter, it should be overridden for the JBoss ON database user:ALTER USER rhqadmin SET statement_timeout=0;
ALTER USER rhqadmin SET statement_timeout=0;Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.1.3.2. Setting Kernel Parameters Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Consider adjusting the kernel parameters for your system. The PostgreSQL documentation on Managing Kernel Resources has more information.
2.1.3.3. Editing pg_hba.conf Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Update the
pg_hba.conf file to allow the newly-created role to connect from the machine the JBoss ON server is installed on, such as localhost. Adding client connections is covered in the PostgreSQL documentation in the Client Authentication section.
After editing the
pg_hba.conf file, restart PostgreSQL for the changes to take effect. If no errors are displayed, the database is now ready to support a JBoss ON installation.
For more information on tuning Postgres, see the PostgreSQL documentation about Tuning your PostgreSQL Server.
2.1.3.4. Fixes for "Relation RHQ_Principal does not exist" Error Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Sometimes the database connection is marked as valid but the install still fails with the Relation RHQ_Principal does not exist error. This occurs when a new database is created by running initdb in a
non-C locale through PostgreSQL instances.
To fix this error:
- Using a database explorer, create an empty table called
RHQ_PRINCIPALin the database used for JBoss ON. - Click Install server.The installer displays a warning about an existing schema. Overwrite the existing schema as it only consists of one empty table.
Another option is to specify the encoding of the created database as
SQL-ASCII at creation time. For example:
initdb -D /my/test/data -E SQL_ASCII --locale en_US.UTF-8
initdb -D /my/test/data -E SQL_ASCII --locale en_US.UTF-8