Thursday, July 21, 2022

How to install PostgreSQL 14 in Rocky Linux 8.

 


This video will show you the completed steps to install PostgreSQL 14 in Rocky Linux 8.6.

It's including changing the default PGDATA directory, automate startup/shutdown database and open firewall.

You can also install on others Rehat family linux such as Rehat enterprise 8, Oracle Linux 8 or CentOS 8.


Installation steps:


############################

##   Login as root        ##

############################ 


## 0. Create group and user: postgres

# groupadd -g 5000 postgres

# useradd  -u 5000 -g 5000 -c "PostgreSQL Database" postgres

useradd  -u 5000 -c "PostgreSQL Database" postgres


##  1. Install postgresql software

dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

dnf -qy module disable postgresql

dnf install -y postgresql14-server


##  2. Create PGDATA directory


mkdir -p /pgsql/data

chown -R postgres.postgres /pgsql


############################

## Login as Postgres      ##

############################ 


## 3. Setup postgres evironment variable


PGDATA=/pgsql/data

PATH=$PATH:/usr/pgsql-14/bin


## 4. Initialize & startup database


initdb

pg_ctl start | stop

psql


############################

##     Login as root     ##

############################ 


## 5. Auto-startup


vi /usr/lib/systemd/system/postgresql-14.service


systemctl daemon-reload


systemctl enable postgresql-14

systemctl start postgresql-14


## 6. Open firewall


#firewall-cmd --zone=public --add-port=5432/tcp

firewall-cmd --add-service=postgresql

firewall-cmd --runtime-to-permanent

## All done

Wednesday, July 20, 2022

[LINUX systemd] How to automate startup/shutdown Oracle Database on Linux




Implementing this task is required for production database, even you're willing to startup the database after the host rebooting. Because your database can crash if it is not shutdown properly due to the host is down!

In this video, we will use systemd which is available on Redhat 7, Redhat 8 and its family (Oracle Linux, CentOS, Rocky)....

This demo is using Oracle Database 21c on Rocky Linux 8.6

The below script is used in the video. You may need to change the location to your ORACLE_HOME

-------------------------

# cd /usr/lib/systemd/system # vi oracle.service [Unit] Description=Oracle Database Service After=network.target [Service] Type=simple RemainAfterExit=yes User=oracle Group=dba Environment="ORACLE_HOME=/u02/app/oracle/product/21c/dbhome_01" ExecStart=/u02/app/oracle/product/21c/dbhome_01/bin/dbstart $ORACLE_HOME >> 2>&1 & ExecStop=/u02/app/oracle/product/21c/dbhome_01/bin/dbshut $ORACLE_HOME 2>&1 & TimeoutSec=120 [Install] WantedBy=multi-user.target


----------------

Oracle Database 18c Express WITHOUT container database architecture.

Oracle has introduced multitenant architecture from Oracle Database 12c. In Oracle Database 18c Express edition, the CDB database (multiten...