Installing on Redhat Linux

Veeam Backup and Replication with the release of v12 has started to support PostgreSQL which is a robust, open-source object-relational database system that offers reliability, data integrity, and a rich set of features.
Since the database installation is usually with the installer, it gets installed on Windows. Now for those who love a challenge or want to run PostgreSQL on Linux to ensure configuration database is on a different server, you can follow these steps to prepare the PostgreSQL for the setup.
If you’re using Red Hat Linux and looking to install PostgreSQL, follow these steps.
Prerequisites
- A Red Hat Linux system
- Sudo or root privileges
Step 1: Update Your System
Ensure your system is up-to-date with the latest packages:
sudo dnf update
Step 2: Install PostgreSQL with Contrib
First, we will need to add the PostgreSQL repository. To install PostgreSQL, Make sure you are using v15, or v16, use the dnf
command ” EL-8 for RedHat 8 and EL-9 for Redhat 9″:
# below with Redhat v8
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# OR use below with Redhat v9
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
For PostgreSQL 15 or 16, select the desired version stream and install “Note that contrib is a requirement for Veeam to run the database”:
sudo dnf module install postgresql16-server postgresql16-contrib
Step 3: Initialize the Database
After installation, you need to initialize the database cluster, “keep in mind Veeam requires that the template1 DB is configured with UTF8 encoding”:
sudo /usr/pgsql-16/bin/postgresql-16-setup initdb
Step 4: Start and Enable PostgreSQL Service
Start the PostgreSQL service:
sudo systemctl start postgresql.service
Enable it to start automatically on boot:
sudo systemctl enable postgresql.service
Step 5: Configure PostgreSQL to run with different service user at a different location(Optional)
Create the PostgreSQL Service User: First, create a new user in Linux, and set its password:
useradd -m vpsql
passwd vpsql
Stop the PostgreSQL Service: First, stop the PostgreSQL service to prevent any data corruption:
sudo systemctl stop postgresql.service
Change Ownership of the Data Directory: Identify your current data directory (usually located at /var/lib/pgsql/data
). Then, create a new directory where you want to move your data. Make sure it has the proper ownership and permissions:
sudo mkdir /new/data/directory
sudo chown vpsql:vpsql /new/data/directory
sudo chmod 700 /new/data/directory
Copy Data to the New Location: Copy the data from the old directory to the new one. Use rsync
to preserve file permissions and ownership “note that the target directory without the /”:
sudo rsync -av /var/lib/pgsql/data/ /new/data/directory
Update PostgreSQL Configuration: Edit the postgresql.conf
and the postgresql-16.service files in the new data directory and set the data_directory
to the new location:
sudo vi /new/data/directory/postgresql.conf
# Set data_directory = '/new/data/directory'
sudo vi /lib/systemd/system/postgresql-16.service
# Set User = vpsql
# Set Group = vpsql
# Set Environment = PGDATA='/new/data/directory'
Update Startup Scripts: Update any startup scripts (e.g., /etc/init.d/postgresql
) to reference the correct user (vpsql
) instead of the default postgres
.
sudo chown -R vpsql:vpsql /var/run/postgresql
vi /usr/lib/tmpfiles.d/postgresql-16.conf
Restart PostgreSQL Service: Restart the PostgreSQL service for the changes to take effect:
sudo systemctl daemon-reload
sudo systemctl restart postgresql.service
Step 7: Allow Remote Connections (Optional)
To allow remote connections, edit the pg_hba.conf
file and add the following line:
host all all 0.0.0.0/0 md5
Then, adjust the listen_addresses
in postgresql.conf
:
listen_addresses = '*'
Don’t forget to restart the PostgreSQL service after making changes:
sudo systemctl restart postgresql.service
Step 8: Firewall Configuration (Optional)
If you have a firewall running, allow the default PostgreSQL port:
sudo firewall-cmd --add-service=postgresql --permanent
sudo firewall-cmd --reload
And that’s it! You’ve successfully installed PostgreSQL on your Red Hat Linux system. Enjoy your new database server!
Remember, the exact steps may vary slightly depending on your specific version of Red Hat Linux. Always refer to the official PostgreSQL documentation or your Red Hat Linux documentation for the most accurate guidance12.
Leave a Reply