Iniciando, Parando, e Abortando o PostgreSQL

O comando pg_ctl stop, por padrão, espera todos os clientes se desconectarem.
Se for utilizado com -m fast, desconecta todos os clientes, e executa ROLLBACK de todas as transações.
Se for utilizado com -m immediate, desliga imediatamente o PostgreSQL, que fará um RECOVER na próxima vez que for iniciado.

Manual do pg_ctl: http://www.postgresql.org/docs/9.1/interactive/app-pg-ctl.html

postgres@PostgreSQL:~$ /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data/
server starting
postgres@PostgreSQL:~$ LOG:  database system was shut down at 2011-11-20 18:24:24 BRST
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started
postgres@PostgreSQL:~$ /usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data/
LOG:  received smart shutdown request
LOG:  autovacuum launcher shutting down
waiting for server to shut down............................................................... failed
pg_ctl: server does not shut down
HINT: The "-m fast" option immediately disconnects sessions rather than
waiting for session-initiated disconnection.
postgres@PostgreSQL:~$ /usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data/ -m fast
waiting for server to shut down....LOG:  received fast shutdown request
LOG:  aborting any active transactions
FATAL:  terminating connection due to administrator command
CONTEXT:  COPY pgbench_accounts, line 65053390: "65053390       651     0       "
STATEMENT:  copy pgbench_accounts from stdin
...LOG:  shutting down
.LOG:  database system is shut down
 done
server stopped
postgres@PostgreSQL:~$
postgres@PostgreSQL:~$ /usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data/ -m immediate
LOG:  received immediate shutdown request
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
waiting for server to shut down....WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and repeat your command.
CONTEXT:  COPY pgbench_accounts, line 9439056, column abalance: "0"
 done
server stopped
postgres@PostgreSQL:~$ /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data/
server starting
postgres@PostgreSQL:~$ LOG:  database system was interrupted; last known up at 2011-11-20 19:01:12 BRST
LOG:  database system was not properly shut down; automatic recovery in progress
LOG:  consistent recovery state reached at 0/268CCC8
LOG:  redo starts at 0/268CCC8
LOG:  record with zero length at 0/2773E90
LOG:  redo done at 0/2773E50
LOG:  last completed transaction was at log time 2011-11-20 19:01:21.160656-02
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

postgres@PostgreSQL:~$

Leave a Reply

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Esse site utiliza o Akismet para reduzir spam. Aprenda como seus dados de comentários são processados.