赞
踩
现象:
[root@pg ~]# systemctl status postgresql
● postgresql.service - PostgreSQL 9.6.24 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2023-11-08 11:15:14 CST; 13s ago
Process: 26250 ExecStop=/usr/local/pgsql/bin/pg_ctl stop -m fast -w -D /usr/local/pgsql/pgdata (code=exited, status=0/SUCCESS)
Process: 26267 ExecStart=/usr/local/pgsql/bin/pg_ctl start -w -D /usr/local/pgsql/pgdata -l /usr/local/pgsql/pgdata/pg_log/startup.log (code=exited, status=1/FAILURE)
Main PID: 23576 (code=exited, status=0/SUCCESS)
Nov 08 11:15:13 pg systemd[1]: Starting PostgreSQL 9.6.24 database server...
Nov 08 11:15:14 pg systemd[1]: postgresql.service: control process exited, code=exited status=1
Nov 08 11:15:14 pg systemd[1]: Failed to start PostgreSQL 9.6.24 database server.
Nov 08 11:15:14 pg systemd[1]: Unit postgresql.service entered failed state.
Nov 08 11:15:14 pg systemd[1]: postgresql.service failed.
从上面的报错中,可以看到:
1、关闭正常,启动失败
2、启动日志存放在/usr/local/pgsql/pgdata/pg_log/startup.log文件中
检查启动日志
LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory "pg_log".
日志重定向到了配置的日志路径中,检查pg的参数文件,确定日志的文件名
[postgres@pg pgdata]$ cat postgresql.conf
#self define
listen_addresses = '*'
port = 5432
logging_collector = on
log_directory = 'pg_log'
log_filename = 'postgresql-%a.log'
log_truncate_on_rotation = on
log_rotation_age = 1d #这个mon文件保留多久才被允许覆盖,第2天产生的Tue了
log_rotation_size = 0
从这里看到,日志目录是pg_log,日志文件名是postgresql-%a.log,这里的%a是星期几的缩写,今天星期三,那么日志文件名就是postgresql-Wed.log
查看真正的数据库启动日志postgresql-Wed.log
LOG: configuration file "/usr/local/pgsql/pgdata/pg_hba.conf" contains no entries
FATAL: could not load pg_hba.conf
LOG: database system is shut down
从这里可以看到,无法加载pg_hba.conf文件,原因是这个文件中的内容全部被注释,没有可运行的内容。这里面,至少存在一条
local all all trust
再次启动,正常
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。