01.01. Install PostgreSQL on pgsql-db01,pgsql-db02

                <<< Back   Next >>> 

1. Add PostgreSQL Yum Repository
[root]# 
dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

2. Disable modules some other version of PostgreSQL.
[root]# 
dnf -qy module disable postgresql

3. Confirm the list of enabled repositories.
[root]# 
dnf repolist
dnf clean all

4. Check to see if PostgreSQL 14 packages are available on the repository
[root]# 
yum search postgresql14

5. Install PostgreSQL 14 server and client
[root]# 
dnf -y install postgresql14-server.x86_64 postgresql14.x86_64

6. Check installed version
[root]# 
rpm -qi postgresql14-server

7. create user owner postgres and database catalogs
[root]# 
groupadd postgres
useradd -c 'PostgreSQL software owner' -d /home/postgres -g postgres -s /bin/bash postgres
mkdir -p /srv/postgres/data/
chown -R postgres:postgres /srv
chmod 700 /srv/postgres/data/

8. Initialize and start/stop database service
-- add profile
[postgres]$ 
vi ./.bash_profile
export PATH=/usr/pgsql-14/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PGDATA=/srv/postgres/data/14

[postgres]$ 
mkdir /srv/postgres/data/14
/usr/pgsql-14/bin/pg_ctl initdb -o "-k" -D /srv/postgres/data/14
/usr/pgsql-14/bin/pg_ctl -D /srv/postgres/data/14 -l logfile start
/usr/pgsql-14/bin/pg_ctl stop

9. Change service configuration
[root]# 
vi /usr/lib/systemd/system/postgresql-14.service
Environment=PGDATA=/srv/postgres/data/14
Environment=PGLOG=/srv/postgres/data/14/pg_log/postgresql.log

10. Enable and start service
[root]# 
systemctl enable postgresql-14.service
systemctl start postgresql-14.service

11. Check service configuration
[root]# 
systemctl status postgresql-14.service

12. Droping database on pgsql-db02
[root]# 
systemctl stop postgresql-14.service
rm -fr /srv/postgres/data/14/*
                <<< Back   Next >>> 

No comments:

Post a Comment