1、初始化系统配置
# useradd -d /opt/postgres postgres
# yum groupinstall -y "Development Tools" "Legacy UNIX Compatibility" -y
# yum install -y bison flex readline* zlib-devel gcc* gmake -y
# mkdir /pgdata
# mkdir /archive
# chown postgres.postgres /pgdata/ -R
# chown postgres.postgres /archive/ -R
# vim /etc/sysctl.conf
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
kernel.shmmni = 4096
kernel.sem = 50100 64128000 50100 1280
fs.file-max = 7672460
net.ipv4.ip_local_port_range = 9000 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
# sysctl -p
# vim /etc/security/limits.conf
* soft nofile 131072
* hard nofile 131072
* soft nproc 131072
* hard nproc 131072
* soft core unlimited
* hard core unlimited
* soft memlock 50000000
* hard memlock 50000000
2、安装postgresql数据库
# tar -zxvf postgresql-12.6.tar.gz
# cd postgresql-12.6
# ./configure --prefix=/opt/postgres/ --with-pgport=1921
# gmake world
# gmake install-world
# chown postgres.postgres /opt/postgres/ -R
# su - postgres
$ vim .bash_profile
export PGDATA=/pgdata
export PGHOME=/opt/postgres
export LD_LIBRARY_PATH=${PGHOME}/lib:${LD_LIBRARY_PATH}
export DATE=$(date +"%y%m%d%H%M")
export PATH=${PGHOME}/bin:${PATH}
export MANPATH=${PGHOME}/share/man:${MANPATH}
export PGUSER=postgres
$ source .bash_profile
$ psql --version
## 初始化数据
$ initdb -A md5 -D ${PGDATA} -E utf8 --locale=C -W
## 启动数据库
$ pg_ctl -D /pgdata -l logfile start
$ psql
Password for user postgres:
psql (12.6)
Type "help" for help.
标签:opt,core,postgresql,postgres,过程,export,net,安装
From: https://www.cnblogs.com/zbc230/p/17536074.html