yum 安装
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
yum install postgresql10
yum install postgresql10-server
/usr/pgsql-10/bin/postgresql-10-setup initdb
systemctl enable postgresql-10
systemctl start postgresql-10
编译安装
依赖包
~]$yum install zlib-devel readline-devel gcc perl-devel
创建用户
~]#groupadd -g 26 postgres
~]#useradd -u 26 -g postgres -c "PostgreSQL Server" -d /var/lib/pgsql postgres
~]#echo "12345678" | passwd --stdin postgres
获取源码
https://www.postgresql.org/download
解压缩
~]$gunzip postgresql-10.2.tar.gz
~]$su
rumor]#tar xf postgresql-10.2.tar -C /usr/local/
rumor]#cd /usr/local/
local]#mv postgresql-10.2 postgresql102
编译安
cd postgresql102/
./configure
make
su
make install
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
启动/停止服务
~]$ /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data/
导入环境变量
~]$ pwd
/var/lib/pgsql
~]$ vim .bash_profile
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/pgsql/bin
export PATH
停止服务
~]$ pg_ctl stop -D /usr/local/pgsql/data/