Home > Storage > PowerFlex > White Papers > Deploying PostgreSQL on Dell PowerFlex > Deploying PostgreSQL
This section describes the steps taken to create the lab environment that was used for the performance tests and validation of the best practices that are described in this paper.
Each compute node is mapped with PowerFlex storage volumes, where two volumes are used for the database datafiles and the third one for the write ahead logging (WAL). The PowerFlex volumes are seen as /dev/scini* devices. They are formatted as XFS filesystems and are mounted to their respective mount points with appropriate permissions, as shown in the following example.
# sudo mkfs.xfs /dev/scinia
# sudo mkfs.xfs /dev/scinib
# sudo mount /dev/scinia /mnt/logs
# sudo mount /dev/scinib /mnt/xfs-pgdata
# sudo chown postgres:postgres /mnt/logs/db1
# sudo chmod 0700 /mnt/logs/db1
# sudo chown postgres:postgres /mnt/xfs-pgdata/db1
# sudo chmod 0700 /mnt/xfs-pgdata/db1
For other configuration recommendations, such as for udev rules and fstab entries, see the best practices section.
Steps to install and configure the PostgreSQL databases:
Run the following command to download and install the PostgreSQL software:
# sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# sudo dnf -qy module disable postgresql
# sudo dnf install -y postgresql15-server
Once the PostgreSQL software is installed, the database needs to be initialized and pointed to make use of the mount points created in the prerequisites section. In the following example two PostgreSQL databases are running on two different ports are being initialized:
# sudo /usr/pgsql-15/bin/pg_ctl -D /mnt/xfs-pgdata/db1 -l /mnt/log-pgdata2/log-db1/db2.logfile -o "-p 5436" start
# sudo /usr/pgsql-15/bin/pg_ctl -D /mnt/xfs-pgdata2/db2 -l /mnt/log-pgdata2/log-db2/db2.logfile -o "-p 5438" start
To automatically start the databases, at startup a systemd service is created. The systemd enables and runs the PostgreSQL database at system startup. The following example shows a sample systemd service configuration:
# cat /etc/systemd/system/postgresql-db1.service
[Unit]
Description=PostgreSQL instance on disk1-scinia
After=network-online.target
After=tuned.service
[Service]
User=postgres
Group=postgres
Environment=PGPORT=5436
Environment=PGDATA=/mnt/xfs-pgdata1/db1
Type=forking
ExecStart=/usr/pgsql-15/bin/pg_ctl -D /mnt/xfs-pgdata/db1 -l /mnt/log-pgdata2/log-db1/db2.logfile -o "-p 5436" start
ExecStop=/usr/pgsql-15/bin/pg_ctl -D /mnt/xfs-pgdata/db1 -l /mnt/log-pgdata2/log-db1/db2.logfile -o "-p 5436" stop
ExecReload=/usr/pgsql-15/bin/pg_ctl -D /mnt/xfs-pgdata/db1 -l /mnt/log-pgdata2/log-db1/db2.logfile -o "-p 5436" reload
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
Enable and start the created systemd services:
# sudo systemctl enable postgresql-db1.service
# sudo systemctl start postgresql-db1.service
At this point the two PostgreSQL database server software processes are successfully initialized and running, listening for the client connectivity at the configured ports. You can now create the user databases in each of the processes with the desired database name as follows:
# sudo -u postgres createdb -h localhost -p 5436 mydb1
# sudo -u postgres createdb -h localhost -p 5438 mydb2
Note: The commands to deploy other environments, for example, using different operating systems, database features or file system structure will vary.