#根据脚本analyze_new_cluster.sh执行统计信息收集
Darren2:postgres:/usr/local/pgsql:>/usr/local/pgsql/pgsql9.6.5/bin/vacuumdb -U 'postgres' --all --analyze-in-stages -p 5431
vacuumdb: processing database "postgres": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "template1": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "testdb1": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "postgres": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "template1": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "testdb1": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "postgres": Generating default (full) optimizer statistics
vacuumdb: processing database "template1": Generating default (full) optimizer statistics
vacuumdb: processing database "testdb1": Generating default (full) optimizer statistics
#查看数据是否存在
Darren2:postgres:/usr/local/pgsql:>psql -p 5431
postgres=# select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 9.6.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4), 64-bit
testdb1=# \dt+
List of relations
Schema | Name | Type | Owner | Size | Description
--------+------+-------+-------+-------+-------------
public | t1 | table | cdhu1 | 85 MB |
#通过上述脚本删除老数据
Darren2:postgres:/usr/local/pgsql:>cat delete_old_cluster.sh
#!/bin/sh
rm -rf '/usr/local/pgsql/pgsql9.5.9/data'
rm -rf '/usr/local/pgsql/pgsql9.5.9/tbs1/PG_9.5_201510051'
Darren2:postgres:/usr/local/pgsql:>bash delete_old_cluster.sh
最后再修改环境变量和端口号等和原来版本保持一致。
Error
Darren2:postgres:/usr/local/pgsql:>/usr/local/pgsql/pgsql9.6.5/bin/pg_ctl start -D /usr/local/pgsql/pgsql9.6.5/data
pg_ctl: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory
解决方法:
[root@Darren2 postgresql-9.6.5]# ln -s /usr/local/pgsql/pgsql9.6.5/lib/libpq.so.5 /usr/lib64/
Ubuntu 16.04 下安装 PostgreSQL 和 phpPgAdmin
Ubuntu 16.04 下 PostgreSQL 主从复制配置
Fedota 24 将数据库升级到 PostgreSQL 9.5
CentOS7安装配置PostgreSQL9.6