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

又在Patroni中踩坑一小时

原创 库海无涯 2024-08-08
143

##

又在Patroni中踩坑一小时

1、场景复现

root@debian:/var/lib/postgresql/16/main# systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; preset: enabled)
     Active: active (exited) since Wed 2024-08-07 13:06:09 CST; 6min ago
    Process: 3355 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 3355 (code=exited, status=0/SUCCESS)
        CPU: 2ms

8月 07 13:06:09 debian systemd[1]: Starting postgresql.service - PostgreSQL RDBMS...
8月 07 13:06:09 debian systemd[1]: Finished postgresql.service - PostgreSQL RDBMS.


root@debian:/var/lib/postgresql/16/main# su - postgres
postgres@debian:~$ psql
Error: Invalid data directory for cluster 16 main

2、检查参数

postgres@debian:~/16/main$ cat postmaster.opts
/usr/lib/postgresql/16/bin/postgres "-D" "/var/lib/postgresql/16/main" "-c" "config_file=/etc/postgresql/16/main/postgresql.conf"

postgres@debian:~/16/main$ pg_config
BINDIR = /usr/lib/postgresql/16/bin
DOCDIR = /usr/share/doc/postgresql-doc-16
HTMLDIR = /usr/share/doc/postgresql-doc-16
INCLUDEDIR = /usr/include/postgresql

3、尝试解决

postgres@debian:~/16/main$ /usr/lib/postgresql/16/bin/postgres "-D" "/var/lib/postgresql/16/main" "-c" "config_file=/etc/postgresql/16/main/postgresql.conf"
2024-08-07 05:23:01.279 GMT [3475] 日志:  无法打开配置文件 "/etc/postgresql/16/main/postgresql.conf": 权限不够
2024-08-07 05:23:01.279 GMT [3475] 致命错误:  配置文件 "/etc/postgresql/16/main/postgresql.conf" 有错
postgres@debian:~/16/main$ exit

4、找到原因并解决问题

root@debian:~# ls -lsa /etc/postgresql/16/main/
总计 72
 4 drwxr-xr-x 3 postgres postgres  4096  8月 7日 12:09 .
 4 drwxr-xr-x 3 postgres postgres  4096  8月 7日 10:54 ..
 4 drwxr-xr-x 2 postgres postgres  4096  8月 7日 10:54 conf.d
 4 -rw-r--r-- 1 postgres postgres   315  8月 7日 10:54 environment
 4 -rw-r--r-- 1 postgres postgres   143  8月 7日 10:54 pg_ctl.conf
 8 -rw-r----- 1 postgres postgres  6011  8月 7日 11:28 pg_hba.conf
 4 -rw-r----- 1 postgres postgres  2640  8月 7日 10:54 pg_ident.conf
32 -rw-r--r-- 1 postgres postgres 30100  8月 7日 11:26 postgresql.base.conf
 4 -rw------- 1 root     root       868  8月 7日 13:05 postgresql.conf
 4 -rw-r--r-- 1 postgres postgres   317  8月 7日 10:54 start.conf
root@debian:~# chown -R postgres:postgres /etc/postgresql/16/main/postgresql.conf
root@debian:~# systemctl stop postgresql
root@debian:~# systemctl start postgresql
root@debian:~#
root@debian:~#
root@debian:~#
root@debian:~# su - postgres
postgres@debian:~$ psql
psql (16.3 (Debian 16.3-1.pgdg120+1))
输入 "help" 来获取帮助信息.

postgres=#

5、总结

昨晚花了1个小时来解决这个问题,客户使用Debian 12,然后apt安装postgresql,有些目录非常的混乱,导致patroni的配置也非常复杂。

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论