部署到patroni上的PG主、备库集群,数据同步报错:invalid connection string syntax: invalid connection option “gssencmode“

本地是3个节点的虚拟机,每个节点上有PostgreSQL,zookeeper,patroni(使用patctl安装的),pgbouncer。

主、备报错日志展示:
备库日志:

```bash
(venv-patctl-1.8.0) [postgres@postgres fdata]$ tail -f log/postgresql-2024-06-18_085516.log
2024-06-18 09:07:41.930 CST [3249] LOG:  waiting for WAL to become available at 0/9000018
2024-06-18 09:07:46.931 CST [3681] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

2024-06-18 09:07:46.931 CST [3249] LOG:  waiting for WAL to become available at 0/9000018
2024-06-18 09:07:51.936 CST [3682] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

2024-06-18 09:07:51.936 CST [3249] LOG:  waiting for WAL to become available at 0/9000018
2024-06-18 09:07:56.938 CST [3684] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

2024-06-18 09:07:56.938 CST [3249] LOG:  waiting for WAL to become available at 0/9000018
2024-06-18 09:08:01.943 CST [3686] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

主库日志:

````bash
(venv-patctl-1.8.0) [postgres@postgres fdata]$ tail -f log/postgresql-2024-06-18_085516.log
2024-06-18 09:09:41.573 CST [3274] LOG:  waiting for WAL to become available at 0/A000120
2024-06-18 09:09:46.574 CST [3744] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

2024-06-18 09:09:46.574 CST [3274] LOG:  waiting for WAL to become available at 0/A000120
2024-06-18 09:09:51.579 CST [3748] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

2024-06-18 09:09:51.579 CST [3274] LOG:  waiting for WAL to become available at 0/A000120
2024-06-18 09:09:56.580 CST [3750] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

2024-06-18 09:09:56.580 CST [3274] LOG:  waiting for WAL to become available at 0/A000120
2024-06-18 09:10:01.586 CST [3763] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

原因分析:

PG数据库的psql引用版本不对,我本地数据库版本是16但是psql引用的是版本10,导致patroni选举的主备节点进行流复制时与lib库不兼容,需要把环境变量配置正确(可以使用env查看环境变量配置)。

正确状态:

错误状态:

问题描述:

 ### 1 服务器详情

 #### 1.1 服务器配置(示例)

| 项       | 信息                                                |
| -------- | --------------------------------------------------- |
| 操作系统 | Red Hat Enterprise Linux Server release 7.8 (Maipo) |
| CPU      | 1(Thread) × 1(Core) × 4(Socket)                     |
| 内存8    | 4GB                                                 |
| 磁盘     | 40G                                                 |
#### 1.2 部署情况(示例)

| 服务器IP    | OS登录信息 | 节点状态、部署服务及对应端口号 |
| ----------- | -------------- | ------ |
| 192.168.6.108 | postgres/postgres | PG主(8432) |
| 192.168.6.109 | postgres/postgres | PG备(8432)(同步) |
| 192.168.6.110 | postgres/postgres | PG备(8432)(同步) |
#### 1.3 数据库用户信息

| 名称           | 账号      | 密码      |
| ---------------| ----------| --------- |
| DB超级用户     | fbase     | fbase     |
| 主备流复制用户 | repuser    | repuser   |
| 普通用户       | quay      | quay      |

## 问题描述:
1、数据库主备不同步,原来刚安装完成的数据库是能使用的,然后做了一次主备切换,又重启了一下Linux系统。
2、主、备库可以正常开启,但是备库收不到日志。

## 主、备库状态
(venv-patctl-1.8.0) [postgres@postgres confd]$ patronictl -c postgres0.yml list
+ Cluster: batman (7381605992916885494) -------+---------+----+-----------+
| Member        | Host               | Role    | State   | TL | Lag in MB |
+---------------+--------------------+---------+---------+----+-----------+
| postgresql108 | 192.168.6.108:8432 | Replica | running |  4 |        16 |
| postgresql109 | 192.168.6.109:8432 | Leader  | running |  6 |           |
| postgresql110 | 192.168.6.110:8432 | Replica | running |  5 |         0 |
+---------------+--------------------+---------+---------+----+-----------+
## 报错日志描述
# 1、备库日志
```bash
(venv-patctl-1.8.0) [postgres@postgres fdata]$ tail -f log/postgresql-2024-06-18_085516.log
2024-06-18 09:07:41.930 CST [3249] LOG:  waiting for WAL to become available at 0/9000018
2024-06-18 09:07:46.931 CST [3681] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

2024-06-18 09:07:46.931 CST [3249] LOG:  waiting for WAL to become available at 0/9000018
2024-06-18 09:07:51.936 CST [3682] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

2024-06-18 09:07:51.936 CST [3249] LOG:  waiting for WAL to become available at 0/9000018
2024-06-18 09:07:56.938 CST [3684] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

2024-06-18 09:07:56.938 CST [3249] LOG:  waiting for WAL to become available at 0/9000018
2024-06-18 09:08:01.943 CST [3686] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"
```
# 2、主库日志
````bash
(venv-patctl-1.8.0) [postgres@postgres fdata]$ tail -f log/postgresql-2024-06-18_085516.log
2024-06-18 09:09:41.573 CST [3274] LOG:  waiting for WAL to become available at 0/A000120
2024-06-18 09:09:46.574 CST [3744] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

2024-06-18 09:09:46.574 CST [3274] LOG:  waiting for WAL to become available at 0/A000120
2024-06-18 09:09:51.579 CST [3748] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

2024-06-18 09:09:51.579 CST [3274] LOG:  waiting for WAL to become available at 0/A000120
2024-06-18 09:09:56.580 CST [3750] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"

2024-06-18 09:09:56.580 CST [3274] LOG:  waiting for WAL to become available at 0/A000120
2024-06-18 09:10:01.586 CST [3763] FATAL:  invalid connection string syntax: invalid connection option "gssencmode"


````

解决:Linux系统有两个环境变量的配置文件,.bash_profile和.bashrc ,使用命令env查看Linux环境配置即可:

(venv-patctl-1.8.0) [postgres@postgres ~]$ env

MANPATH=/home/postgres/fbase/16.3/share/man:

XDG_SESSION_ID=1

HOSTNAME=postgres

SHELL=/bin/bash

TERM=xterm-256color

PG_MASTER_OOM_SCORE_ADJ=1000

HISTSIZE=1000

QTDIR=/usr/lib64/qt-3.3

QTINC=/usr/lib64/qt-3.3/include

QT_GRAPHICSSYSTEM_CHECKED=1

USER=postgres

LD_LIBRARY_PATH=/home/postgres/fbase/16.3/lib:/third-lib/:

PGPORT=5432

LS_COLORS=rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:

PGUSER=fbase

PGDATABASE=postgres

VIRTUAL_ENV=/home/postgres/patctl/venv-patctl-1.8.0

DATE=202406181042

MAIL=/var/spool/mail/postgres

PATH=/home/postgres/patctl/venv-patctl-1.8.0/bin:/home/postgres/fbase/16.3/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:.:/home/postgres/.local/bin:/home/postgres/bin

PG_OOM_ADJUST_VALUE=0

PWD=/home/postgres

LANG=en_US.utf8

PGHOST=localhost

KDEDIRS=/usr

PS1=(venv-patctl-1.8.0) [\u@\h \W]\$

PGHOME=/home/postgres/fbase/16.3

HISTCONTROL=ignoredups

SHLVL=1

HOME=/home/postgres

LOGNAME=postgres

QTLIB=/usr/lib64/qt-3.3/lib

XDG_DATA_DIRS=/home/postgres/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share

PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj

PGDATA=/home/postgres/data/fbase/fdata

LESSOPEN=||/usr/bin/lesspipe.sh %s

QT_PLUGIN_PATH=/usr/lib64/kde4/plugins:/usr/lib/kde4/plugins

_=/bin/env

OLDPWD=/home/postgres/patctl/confd

(venv-patctl-1.8.0) [postgres@postgres ~]$

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值