pg无法启动

现象:

[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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值