将PostgreSQL升级到最新版本
1.备份
su - postgres
pg_dumpall -c > backup.dump
2.将PostgreSQL的存储库注册到yum中。
su -
wget https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-centos10-10-2.noarch.rpm
rpm -ivh pgdg-centos10-10-2.noarch.rpm
vi /etc/yum.repos.d/CentOS-Base.repo
# [base] と [updates]セクションにexclude=postgresql*を追加
3. 安装PostgreSQL10
yum install postgresql10-server
停用旧版本的数据库
/etc/rc.d/init.d/postgresql stop
5. 创建初始数据
su - postgres
/usr/pgsql-10/bin/initdb -D /var/lib/pgsql/10/data
6. 启动新版本的数据库
su -
/etc/rc.d/init.d/postgresql-10 start
7. 服务设置更改
chkconfig --list
chkconfig postgresql off
chkconfig postgresql-10 on
8. 登录确认
su - postgres
/usr/pgsql-10/bin/psql -U postgres
9. 数据恢复
/usr/pgsql-10/bin/psql -d postgres -f backup.dump