导航

搭建postgresql集群的问题汇总

Posted on 2018-09-30 10:58  许爱琪  阅读(1447)  评论(0编辑  收藏  举报

问题一:如何配置pg远程访问
          修改postgresql.conf-->listen_addresses = '*'
          修改pg_hba.conf-->添加 host    all             all             0.0.0.0/0               trust
          ps:以上代表允许从任何地址登录postgresql
问题二:远程连接pg服务器时出现如下错误          
          psql: could not connect to server: No route to host
                   Is the server running on host "192.168.100.149" and accepting
                   TCP/IP connections on port 5432?
         原因:pg服务器的防火墙阻挡
         解决方案:pg服务器开放5432端口
        /sbin/iptables -I INPUT -p tcp --dport 5432 -j ACCEPT
        /etc/init.d/iptables save
        service iptables restart
问题三:pgpool-II安装好后,执行命令"createdb -p 9999 test"出错
         createdb: could not connect to database template1: could not connect to server: No such file or directory
          Is the server running locally and accepting
          connections on Unix domain socket "/tmp/.s.PGSQL.9999"?
      原因:没有指定pgpool所在的服务器
      解决方法:执行"createdb -h 192.168.100.148 -p 9999 test"
问题四:搭建复制模式后,如果节点1坏了,如何进行故障恢复?
      步骤一:在pgpool服务器上手动执行命令:pcp_attach_node -d 5 localhost 9898 postgres postgres 1 将失效的节点加入集群
         ps:localhost 是指pgpool的服务器
             9898      是指pcp端口
             postgres:postgres是指pcp管理的用户名和密码
             1是指节点号码
     步骤二:
问题五:搭建流复制环境时,在备库上,利用psql无法连接数据库,出现错误“psql: FATAL:  the database system is starting up"
           原因:备库的postgesql.conf中的“hot_standby"这个参数没有设置正确
            解决方法:设置hot_standby=on        
问题六:安装pgpool的时候出现错误"make: pg_config: Command not found"&"make: *** No targets.  Stop."
          指定路径:export PATH=/home/pg93/pgsql/bin:$PATH

问题七:备份脚本:pg_basebackup -F p -D $PGDATA -h 192.168.224.128 -p 5432 -U replica
           压力测试:pgbench -M prepared -n -r -f ./test.sql -p 5432 -U postgres -c 16 -T 60 postgres
问题八:man postgres 出现错误 No manual entry for postgres
           解决方法:修改/etc/man.config  添加man路径:MANPATH /usr/local/pgsql/share/man/
问题九:/usr/bin/ld: cannot find -lsasl2
           解决方法:安装yum install cyrus-sasl-devel -y