暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Postgresql升级,失败了

我不说你不造 2019-04-29
1065

公司服务器上安装的Postgresql版本是9.2.7,是比较老的了,不支持并行查询和插入,但是上头又总是提出非常大的查询需求(6亿*31这种),所以想升级到9.6,以便加入并行机制,提升下效率。 
官网直接下载source包,我下载的是9.6.12版本,没什么理由,9.6里最新的而已。 
直接解压并配置

  1. # tar -zxvf postgresql-9.6.12.tar.gz

  2. # cd postgresql-9.6.12

  3. # ./configure --prefix=/data/5435/pgsql-9.6 --with-perl --with-python --with-openssl --with-pam --without-ldap --with-libxml --with-libxslt

把一些缺少的包打上,然后编译

  1. # gmake world

  2. # gmake install-world

安装完成(不出其他幺儿子的话) 
这里创建下postgres用户(升级的话,肯定原来用户就有,就不用创建了)

  1. # useradd postgres

还有,需要修改下postgresql.conf和pg_hba.conf两个文件。 
初始化数据库

  1. # su - postgres

  2. $ /data/5435/pgsql-9.6/bin/initdb -E UTF8 -D /data/5435/pgsql --locale=zh_CN.UTF-8 -U postgres -W

新库这里就准备好了,然后把旧的数据文件直接拷贝进新的目录里,记得是拷贝哦。拷贝完成后进行升级验证

  1. $ /data/5435/pgsql-9.6/bin/pg_upgrade -c -j 2 -U postgres -v -b /usr/bin -B /data/5435/pgsql-9.6/bin -d /data/5432 -D /data/5435/pgsql -p 5432 -P 5435

pg_upgrade的说明:

  1. $ /data/5435/pgsql-9.6/bin/pg_upgrade --help

  2. pg_upgrade upgrades a PostgreSQL cluster to a different major version.


  3. Usage:

  4. pg_upgrade [OPTION]...


  5. Options:

  6. -b, --old-bindir=BINDIR old cluster executable directory

  7. -B, --new-bindir=BINDIR new cluster executable directory

  8. -c, --check check clusters only, don't change any data

  9. -d, --old-datadir=DATADIR old cluster data directory

  10. -D, --new-datadir=DATADIR new cluster data directory

  11. -j, --jobs number of simultaneous processes or threads to use

  12. -k, --link link instead of copying files to new cluster

  13. -o, --old-options=OPTIONS old cluster options to pass to the server

  14. -O, --new-options=OPTIONS new cluster options to pass to the server

  15. -p, --old-port=PORT old cluster port number (default 50432)

  16. -P, --new-port=PORT new cluster port number (default 50432)

  17. -r, --retain retain SQL and log files after success

  18. -U, --username=NAME cluster superuser (default "postgres")

  19. -v, --verbose enable verbose internal logging

  20. -V, --version display version information, then exit

  21. -?, --help show this help, then exit


  22. Before running pg_upgrade you must:

  23. create a new database cluster (using the new version of initdb)

  24. shutdown the postmaster servicing the old cluster

  25. shutdown the postmaster servicing the new cluster


  26. When you run pg_upgrade, you must provide the following information:

  27. the data directory for the old cluster (-d DATADIR)

  28. the data directory for the new cluster (-D DATADIR)

  29. the "bin" directory for the old version (-b BINDIR)

  30. the "bin" directory for the new version (-B BINDIR)


  31. For example:

  32. pg_upgrade -d oldCluster/data -D newCluster/data -b oldCluster/bin -B newCluster/bin

  33. or

  34. $ export PGDATAOLD=oldCluster/data

  35. $ export PGDATANEW=newCluster/data

  36. $ export PGBINOLD=oldCluster/bin

  37. $ export PGBINNEW=newCluster/bin

  38. $ pg_upgrade


  39. Report bugs to <pgsql-bugs@postgresql.org>.

但是,我校验没通过:

  1. Values to be changed:


  2. First log segment after reset: 000000010000000000000002

  3. "/usr/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/data/5432" -o "-p 5432 -b -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directory='/data/5435'" start >> "pg_upgrade_server.log" 2>&1


  4. *failure*

  5. There were problems executing ""/usr/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/data/5432" -o "-p 5432 -b -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directory='/data/5435'" start >> "pg_upgrade_server.log" 2>&1"

  6. Consult the last few lines of "pg_upgrade_server.log" for

  7. the probable cause of the failure.


  8. connection to database failed: could not connect to server: No such file or directory

  9. Is the server running locally and accepting

  10. connections on Unix domain socket "/data/5435/.s.PGSQL.5432"?


  11. could not connect to old postmaster started with the command:

  12. "/usr/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/data/5432" -o "-p 5432 -b -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directory='/data/5435'" start

然后查看server.log

  1. command: "/usr/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/data/5432" -o "-p 5432 -b -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directory='/data/5435'" start >> "pg_upgrade_server.log" 2>&1

  2. 等待服务器进程启动 ....致命错误: 未认可的配置参数 "unix_socket_directory"

  3. .... 已停止等待

  4. pg_ctl: 无法启动服务器进程

  5. 检查日志输出.

查了很多资料,都没有<未认可的配置参数 "unix_socket_directory">这玩意儿的说明,但是我直接在pg_ctl 调用unix_socket_directory='/data/5435'
是可以的,而且使用link,而不是copy,也是检查通过,时间有限,先记录一下问题,后面继续研究。By the way,我虚拟机上检查是通过的,可能生产环境有特殊配置emmmm。



文章转载自我不说你不造,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论