数据库关闭问题分析及解决
postgres数据库执行retart命令后,偶现错误
1 the database system is shutting down
2 the database system is starting up
一 数据库的关闭方式
关闭方式种类 | 方式含义 | 命令 |
---|---|---|
smart智能关闭模式 | 但凡有外部连接未结束,就需要等待这些连接结束后才会开始关闭数据库 | pg_ctl stop -m smart |
fast快速关闭模式 | 通过向所有活动会话发送SIGTERM信号来结束这些会话 | pg_ctl stop -m fast |
immediate直接关闭模式 | 向所有子进程发送SIGQUIT信号。通过这种方式关闭数据库,完整性是不可靠的。再次启动数据库时将会重放WAL日志进行恢复。 | pg_ctl stop -m immediate |
1 smart智能关闭模式
打开两个客户端,其中客户端1打开会话,客户端2用smart方式关闭数据库
客户端1
psql
psql (14.12 (Ubuntu 14.12-1.pgdg22.04+1))
Type "help" for help.
postgres=#
客户端2:
/usr/lib/postgresql/14/bin/pg_ctl -D /etc/postgresql/14/main stop -m smart
waiting for serv