Lab: How to stop/start a postgres db
As postgres user (recommendation is never allow direct connection to postgres, allow other users with su to switch to postgres user).
Start:
[postgres@localhost ~]$ pg_ctl -D /pgData/data -l logfile start
waiting for server to start.... done
server started
waiting for server to start.... done
server started
[postgres@localhost ~]$
Where /pgData/data is the datafile directory where the postgres database is stored
Examine the postgres db status:
Where /pgData/data is the datafile directory where the postgres database is stored
Examine the postgres db status:
[postgres@localhost ~]$ ps -ef|grep -i postgres
root 9284 9269 0 02:40 pts/0 00:00:00 su - postgres
postgres 9285 9284 0 02:40 pts/0 00:00:00 -bash
postgres 9319 1 0 02:42 ? 00:00:00 /pgBin/12.5/bin/postgres -D /pgData/data
postgres 9321 9319 0 02:42 ? 00:00:00 postgres: checkpointer
postgres 9322 9319 0 02:42 ? 00:00:00 postgres: background writer
postgres 9323 9319 0 02:42 ? 00:00:00 postgres: walwriter
postgres 9324 9319 0 02:42 ? 00:00:00 postgres: autovacuum launcher
postgres 9325 9319 0 02:42 ? 00:00:00 postgres: stats collector
postgres 9326 9319 0 02:42 ? 00:00:00 postgres: logical replication launcher
postgres 9327 9285 0 02:42 pts/0 00:00:00 ps -ef
postgres 9328 9285 0 02:42 pts/0 00:00:00 grep --color=auto -i postgres
[postgres@localhost ~]$
root 9284 9269 0 02:40 pts/0 00:00:00 su - postgres
postgres 9285 9284 0 02:40 pts/0 00:00:00 -bash
postgres 9319 1 0 02:42 ? 00:00:00 /pgBin/12.5/bin/postgres -D /pgData/data
postgres 9321 9319 0 02:42 ? 00:00:00 postgres: checkpointer
postgres 9322 9319 0 02:42 ? 00:00:00 postgres: background writer
postgres 9323 9319 0 02:42 ? 00:00:00 postgres: walwriter
postgres 9324 9319 0 02:42 ? 00:00:00 postgres: autovacuum launcher
postgres 9325 9319 0 02:42 ? 00:00:00 postgres: stats collector
postgres 9326 9319 0 02:42 ? 00:00:00 postgres: logical replication launcher
postgres 9327 9285 0 02:42 pts/0 00:00:00 ps -ef
postgres 9328 9285 0 02:42 pts/0 00:00:00 grep --color=auto -i postgres
[postgres@localhost ~]$
9319 is the parent process for the postgres process tree
[postgres@localhost ~]$ pg_ctl status -D /pgData/data
pg_ctl: server is running (PID: 9319)
/pgBin/12.5/bin/postgres "-D" "/pgData/data"
[postgres@localhost ~]$
pg_ctl: server is running (PID: 9319)
/pgBin/12.5/bin/postgres "-D" "/pgData/data"
[postgres@localhost ~]$
Stop:
[postgres@localhost ~]$ pg_ctl -D /pgData/data stop
waiting for server to shut down.... done
server stopped
[postgres@localhost ~]$
waiting for server to shut down.... done
server stopped
[postgres@localhost ~]$
Status:
[postgres@localhost ~]$ pg_ctl status -D /pgData/datapg_ctl: no server running
[postgres@localhost ~]$
No comments:
Post a Comment