亚洲精品中文字幕无乱码_久久亚洲精品无码AV大片_最新国产免费Av网址_国产精品3级片

IBM認(rèn)證

PostgreSQL服務(wù)器啟動(dòng)及關(guān)閉方法

時(shí)間:2024-07-30 07:54:09 IBM認(rèn)證 我要投稿
  • 相關(guān)推薦

PostgreSQL服務(wù)器啟動(dòng)及關(guān)閉方法

  PostgreSQL采用C/S(客戶機(jī)/服務(wù)器)模式結(jié)構(gòu)。應(yīng)用層通過(guò)INET或者Unix Socket利用既定的協(xié)議與數(shù)據(jù)庫(kù)服務(wù)器進(jìn)行通信。下面yjbys小編為大家搜集相關(guān)的PostgreSQL服務(wù)器啟動(dòng)及關(guān)閉方法!

PostgreSQL服務(wù)器啟動(dòng)及關(guān)閉方法

  1. 啟動(dòng)數(shù)據(jù)庫(kù)服務(wù)器(posgres用戶):

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

  [1] 4508

  當(dāng)然如果設(shè)置了環(huán)境變量

  PGDATA=/opt/postgresql/data

  export PGDATA

  后,可使用pg_ctl工具進(jìn)行啟動(dòng):

  [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]$

  因?yàn)橹耙呀?jīng)啟動(dòng),所以打印“another server might be running”。此時(shí),查看日志,有如下信息:

  [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]$

  當(dāng)然,最簡(jiǎn)的啟動(dòng)方式是:

  [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

  如果要在操作系統(tǒng)啟動(dòng)時(shí)就啟動(dòng)PG,可以在/etc/rc.d/rc.local 文件中加以下語(yǔ)句:

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

  2.關(guān)閉服務(wù)器

  最簡(jiǎn)單方法:

  [postgres@localhost ~]$ pg_ctl stop

  waiting for server to shut down.... done

  server stopped

  與Oracle相同,在關(guān)閉時(shí)也可采用不同的模式,簡(jiǎn)介如下:

  SIGTERM

  不再允許新的連接,但是允許所有活躍的會(huì)話正常完成他們的工作,只有在所有會(huì)話都結(jié)束任務(wù)后才關(guān)閉。這是智能關(guān)閉。

  SIGINT

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

  SIGQUIT

  令 postgres 向所有子進(jìn)程發(fā)送 SIGQUIT 并且立即退出(所有子進(jìn)程也會(huì)立即退出),而不會(huì)妥善地關(guān)閉數(shù)據(jù)庫(kù)系統(tǒng)。這是立即關(guān)閉。這樣做會(huì)導(dǎo)致下次啟動(dòng)時(shí)的恢復(fù)(通過(guò)重放 WAL 日志)。我們推薦只在緊急的時(shí)候使用這個(gè)方法。

  SIGKILL

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

  使用方法舉例:

  [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 ~]$

  最快速關(guān)閉方法:kill postgres 進(jìn)程

  [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啟動(dòng)后的進(jìn)程,如下:

  [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服務(wù)器啟動(dòng)及關(guān)閉方法】相關(guān)文章:

計(jì)算機(jī)啟動(dòng)與關(guān)閉類故障09-25

WEB服務(wù)器的優(yōu)化方法07-08

sata硬盤啟動(dòng)的方法09-24

word遇到問(wèn)題需要關(guān)閉的方法06-02

java實(shí)現(xiàn)web服務(wù)器的方法09-26

服務(wù)器常規(guī)維修與判斷方法10-14

服務(wù)器硬盤選擇方法及優(yōu)點(diǎn)07-03

WEB服務(wù)器的優(yōu)化方法簡(jiǎn)介09-17

服務(wù)器硬盤故障處理方法09-30

機(jī)房服務(wù)器硬件維護(hù)方法06-24