一、启动数据库

pg_ctl start -D $PGDATA或pg_ctl start -D /kingdee/pgsql

$PGDATA执行postgresql的数据库的数据目录

二、停止数据库

pg_ctl stop -D $PGDATA   [-m shutdown-mode]

-m shutdown-mode指数据库停止的方法,有以下三种:

smart: 等所有的连接终止后关闭数据库。如果客户端连接不终止,则无法关闭数据库。

fast: 相当于oracle数据库的immdiate模式

immediate:相当于oracle数据库的abort模式

[pgsql@easha1 ~]$ pg_ctl start -D $PGDATA
waiting for server to start....2022-01-05 11:01:16.931 CST [7425] LOG:  starting PostgreSQL 14.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
2022-01-05 11:01:16.932 CST [7425] LOG:  listening on IPv6 address "::1", port 5432
2022-01-05 11:01:16.932 CST [7425] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2022-01-05 11:01:16.933 CST [7425] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2022-01-05 11:01:16.935 CST [7426] LOG:  database system was shut down at 2022-01-05 10:28:59 CST
2022-01-05 11:01:16.936 CST [7425] LOG:  database system is ready to accept connections
 done
server started
[pgsql@easha1 ~]$

[pgsql@easha1 ~]$ pg_ctl stop -D $PGDATA -m fast
waiting for server to shut down....2022-01-05 11:02:50.390 CST [7425] LOG:  received fast shutdown request
2022-01-05 11:02:50.391 CST [7425] LOG:  aborting any active transactions
2022-01-05 11:02:50.392 CST [7425] LOG:  background worker "logical replication launcher" (PID 7433) exited with exit code 1
2022-01-05 11:02:50.392 CST [7427] LOG:  shutting down
2022-01-05 11:02:50.423 CST [7425] LOG:  database system is shut down
 done
server stopped
[pgsql@easha1 ~]$
 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐