Configuring and Starting the PostgreSQL Server
By default, PostgreSQL only accepts connections on the loopback interface. Configure PostgreSQL to accept the connections based on hostname, IP address (including CIDR address), or MAC address. A fully qualified domain name (FQDN) is not a requirement. If you do not make these changes, the services cannot connect to and use the database on which they depend.
-
Make sure that
LC_ALL
is set toen_US.UTF-8
and initialize the database as follows:- RHEL
7:
echo 'LC_ALL="en_US.UTF-8"' >> /etc/locale.conf sudo su -l postgres -c "postgresql-setup initdb"
- RHEL
7:
- Enable MD5 authentication. Edit
pg_hba.conf
, which is usually found in/var/lib/pgsql/data
or/etc/postgresql/<version>/main
. Add the following line:host all all <range-start-ip-address>/28 md5
If the defaultpg_hba.conf
file contains the following line:
then thehost all all 127.0.0.1/32 ident
host
line specifyingmd5
authentication shown above must be inserted before thisident
line. Failure to do so may cause an authentication error when running thescm_prepare_database.sh
script. You can modify the contents of themd5
line shown above to support different configurations. For example, if you want to access PostgreSQL from a different host, replace127.0.0.1
with your IP address and updatepostgresql.conf
, which is typically found in the same place aspg_hba.conf
, to include:listen_addresses = '*'
- Configure settings to ensure your system performs as expected. Update these
settings in the
/var/lib/pgsql/data/postgresql.conf
or/var/lib/postgresql/data/postgresql.conf
file. Settings vary based on cluster size and resources as follows:- Small to mid-sized clusters - Consider the following settings as starting points.
If resources are limited, consider reducing the buffer sizes and checkpoint segments
further. Ongoing tuning may be required based on each host's resource utilization. For
example, if the Cloudera Manager Server is running on the same host as other roles, the
following values may be acceptable:
max_connection
- In general, allow each database on a host 100 maximum connections and then add 50 extra connections. You may have to increase the system resources available to PostgreSQL, as described at Connection Settings.shared_buffers
- 256MBwal_buffers
- 8MBcheckpoint_segments
- 16checkpoint_completion_target
- 0.9
- Large clusters - Can contain up to 1000 hosts. Consider the following settings as
starting points.
max_connection
- For large clusters, each database is typically hosted on a different host. In general, allow each database on a host 100 maximum connections and then add 50 extra connections. You may have to increase the system resources available to PostgreSQL, as described at Connection Settings.shared_buffers
- 1024 MB. This requires that the operating system can allocate sufficient shared memory. See PostgreSQL information on Managing Kernel Resources for more information on setting kernel resources.wal_buffers
- 16 MB. This value is derived from theshared_buffers
value. Settingwal_buffers
to be approximately 3% ofshared_buffers
up to a maximum of approximately 16 MB is sufficient in most cases.checkpoint_segments
- 128. The PostgreSQL Tuning Guide recommends values between 32 and 256 for write-intensive systems, such as this one.checkpoint_completion_target
- 0.9.
- Small to mid-sized clusters - Consider the following settings as starting points.
If resources are limited, consider reducing the buffer sizes and checkpoint segments
further. Ongoing tuning may be required based on each host's resource utilization. For
example, if the Cloudera Manager Server is running on the same host as other roles, the
following values may be acceptable:
- Configure the PostgreSQL server to start at boot.
OS Command RHEL 7 compatible sudo systemctl enable postgresql
- Restart the PostgreSQL database:
- RHEL 7
Compatible:
sudo systemctl restart postgresql
- RHEL 7
Compatible: