1、卸载旧版本postgresql
$ yum remove postgresql*
2、更新yum
$ yum update
3、下载pgdg-centos10-10-2.noarch.rpm,或者到https://yum.postgresql.org/repopackages.php#pg10选择相应版本
wget https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
4、
rpm -ivh pgdg-centos10-10-2.noarch.rpm
5、
$ sudo yum -y install postgresql10-server
6、初始化
$ service postgresql-10 initdb
7、启动postgresql
$ service postgresql-10 start
8、设置开机自动启动服务
chkconfig postgresql-10 on