您的位置:首页 > 数据库

ubuntu下使用pg_upgrade从PostgreSQL9.5升级到PostgreSQL9.6

2016-10-15 20:42 519 查看
更新apt

sudo apt update
sudo apt upgrade

安装PostgreSQL9.6

sudo apt install postgresql-9.6

停止PostgreSQL

sudo service postgresql stop

修改/etc/postgresql/9.5/main/pg_hba.conf,确保本机信任访问

local   all             postgres                                peer

修改/etc/postgresql/9.6/main/pg_hba.conf,确保本机信任访问

local   all             postgres                                peer

切换到postges角色

sudo su postgres

升级检查

/usr/lib/postgresql/9.6/bin/pg_upgrade -c -p 15431 -P 5432 -b /usr/lib/postgresql/9.5/bin/ -B /usr/lib/postgresql/9.6/bin/ -d /var/lib/postgresql/9.5/main -D  /var/lib/postgresql/9.6/main -o ' -c config_file=/etc/postgresql/9.5/main/postgresql.conf' -O ' -c config_file=/etc/postgresql/9.6/main/postgresql.conf'

检查无误后,执行升级

/usr/lib/postgresql/9.6/bin/pg_upgrade -v -p 15431 -P 5432 -b /usr/lib/postgresql/9.5/bin/ -B /usr/lib/postgresql/9.6/bin/ -d /var/lib/postgresql/9.5/main -D  /var/lib/postgresql/9.6/main -o ' -c config_file=/etc/postgresql/9.5/main/postgresql.conf' -O ' -c config_file=/etc/postgresql/9.6/main/postgresql.conf'

升级无误后,exit回到root用户,移除旧的9.5版本

sudo apt remove postgresql-9.5

启动PostgreSQL

sudo service postgresql start

切换到postges角色

sudo su postgres

优化新数据库

"/usr/lib/postgresql/9.6/bin/vacuumdb" --all --analyze-in-stages

使用客户端连接新数据库后,无误后,删除旧数据库数据。

rm -rf '/var/lib/postgresql/9.5/main'

到此,升级完毕。

你可以编辑 /etc/postgresql/9.6/main/postgresql.conf 文件来优化PostgreSQL。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐