<delect id="sj01t"></delect>
  1. <em id="sj01t"><label id="sj01t"></label></em>
  2. <div id="sj01t"></div>
    1. <em id="sj01t"></em>

            <div id="sj01t"></div>

            PostgreSQL服務器啟動及關閉方法

            時間:2024-08-21 23:08:07 IBM認證 我要投稿
            • 相關推薦

            PostgreSQL服務器啟動及關閉方法

              PostgreSQL采用C/S(客戶機/服務器)模式結構。應用層通過INET或者Unix Socket利用既定的協議與數據庫服務器進行通信。下面yjbys小編為大家搜集相關的PostgreSQL服務器啟動及關閉方法!

            PostgreSQL服務器啟動及關閉方法

              1. 啟動數據庫服務器(posgres用戶):

              [postgres@localhost bin]$ postgres -D /opt/postgresql/data/ > /opt/postgresql/log/pg_server.log 2>&1 &

              [1] 4508

              當然如果設置了環境變量

              PGDATA=/opt/postgresql/data

              export PGDATA

              后,可使用pg_ctl工具進行啟動:

              [postgres@localhost log]$ pg_ctl start -l /opt/postgresql/log/pg_server.log

              pg_ctl: another server might be running; trying to start server anyway

              pg_ctl: could not start server

              Examine the log output.

              [postgres@localhost log]$

              因為之前已經啟動,所以打印“another server might be running”。此時,查看日志,有如下信息:

              [postgres@localhost log]$ cat pg_server.log

              FATAL: lock file "postmaster.pid" already exists

              HINT: Is another postmaster (PID 4491) running in data directory "/opt/postgresql/data"?

              [postgres@localhost log]$

              當然,最簡的啟動方式是:

              [postgres@localhost ~]$ pg_ctl start

              server starting

              [postgres@localhost ~]$ LOG: database system was shut down at 2011-07-09 13:58:00 CST

              LOG: autovacuum launcher started

              LOG: database system is ready to accept connections

              如果要在操作系統啟動時就啟動PG,可以在/etc/rc.d/rc.local 文件中加以下語句:

              /opt/postgresql/bin/pg_ctl start -l /opt/postgresql/log/pg_server.log -D /opt/postgresql/data

              2.關閉服務器

              最簡單方法:

              [postgres@localhost ~]$ pg_ctl stop

              waiting for server to shut down.... done

              server stopped

              與Oracle相同,在關閉時也可采用不同的模式,簡介如下:

              SIGTERM

              不再允許新的連接,但是允許所有活躍的會話正常完成他們的工作,只有在所有會話都結束任務后才關閉。這是智能關閉。

              SIGINT

              不再允許新的連接,向所有活躍服務器發送 SIGTERM(讓它們立刻退出),然后等待所有子進程退出并關閉數據庫。這是快速關閉。

              SIGQUIT

              令 postgres 向所有子進程發送 SIGQUIT 并且立即退出(所有子進程也會立即退出),而不會妥善地關閉數據庫系統。這是立即關閉。這樣做會導致下次啟動時的恢復(通過重放 WAL 日志)。我們推薦只在緊急的時候使用這個方法。

              SIGKILL

              此選項盡量不要使用,這樣會阻止服務器清理共享內存和信號燈資源,那樣的話你只能在啟動服務器之前自己手工做這件事。另外,SIGKILL 直接把 postgres 殺掉,而不會等它把信號中繼給它的子進程,因此我們還需要手工殺掉每個獨立子進程。

              使用方法舉例:

              [postgres@localhost ~]$ pg_ctl stop -o SIGTERM

              LOG: received smart shutdown request

              LOG: autovacuum launcher shutting down

              waiting for server to shut down....LOG: shutting down

              LOG: database system is shut down

              done

              server stopped

              [postgres@localhost ~]$

              最快速關閉方法:kill postgres 進程

              [postgres@localhost ~]$ kill -INT `head -1 /opt/postgresql/data/postmaster.pid`

              [postgres@localhost ~]$ LOG: received fast shutdown request

              LOG: aborting any active transactions

              LOG: autovacuum launcher shutting down

              LOG: shutting down

              LOG: database system is shut down

              附:postgre啟動后的進程,如下:

              [postgres@localhost ~]$ ps -ef|grep post

              root 4609 4543 0 13:57 pts/2 00:00:00 su - postgres

              postgres 4610 4609 0 13:57 pts/2 00:00:00 -bash

              postgres 4724 1 0 14:08 pts/2 00:00:00 /opt/postgresql/bin/postgres

              postgres 4726 4724 0 14:08 ? 00:00:00 postgres: writer process

              postgres 4727 4724 0 14:08 ? 00:00:00 postgres: wal writer process

              postgres 4728 4724 0 14:08 ? 00:00:00 postgres: autovacuum launcher process

              postgres 4729 4724 0 14:08 ? 00:00:00 postgres: stats collector process

              postgres 4752 4610 0 14:11 pts/2 00:00:00 ps -ef

              postgres 4753 4610 0 14:11 pts/2 00:00:00 grep post

              [postgres@localhost ~]$


            【PostgreSQL服務器啟動及關閉方法】相關文章:

            計算機啟動與關閉類故障03-29

            fireworks關閉隱藏邊緣選項的方法03-04

            服務器常規維修與判斷方法03-10

            java實現web服務器的方法03-30

            電工常見電機啟動方法08-07

            scsi設置硬盤啟動的方法07-07

            機房服務器硬件維護方法大全03-07

            服務器硬件管理和維護方法03-30

            Linux系統守護進程的啟動方法12-15

            <delect id="sj01t"></delect>
            1. <em id="sj01t"><label id="sj01t"></label></em>
            2. <div id="sj01t"></div>
              1. <em id="sj01t"></em>

                      <div id="sj01t"></div>
                      黄色视频在线观看