Cnit09
2023-10-14 11:35:44
1. PreInstall PostgreSQL
yum -y groupinstall "Development Tools"
yum install -y wget net-tools tar
2. Download source PostgreSQL
wget "https://ftp.postgresql.org/pub/source/v16.0/postgresql-16.0.tar.gz"
3. Extra source PostgreSQL
tar -xvf postgresql-16.0.tar.gz
4. Combine PostgreSQL
cd postgresql-16.0
./configure --without-icu --without-readline --without-zlib
make
make install
5. Check binary và version PostgreSQL
ll -lha /usr/local/pgsql/
/usr/local/pgsql/bin/psql --version
6. Init database PostgreSQL
#Create use run PostgreSQL
adduser postgres
#Create folder data
mkdir -p /usr/local/pgsql/data
#Change permit folder data
chown postgres /usr/local/pgsql/data
#Init databases
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
#start PostgreSQL
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
7. Stop & Start PostgreSQL
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile stop
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
8. Check service PostgreSQL
ps -ef | grep postgres
#OR
netstat -tupln | grep 5432