PostgreSQL服务器启动和关闭方法介绍_第1页
PostgreSQL服务器启动和关闭方法介绍_第2页
PostgreSQL服务器启动和关闭方法介绍_第3页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、PostgreSQL 服务器启动和关闭方法介绍1. 启动数据库服务器 (posgres 用户 ): plain view plaincopyprint?postgreslocalhost bin$ postgres -D /opt/postgresql/data/ > /opt/postgresql/log/pg_server.log2>&1 &1 4508当然如果设置了环境变量html viewplaincopyprint?PGDATA=/opt/postgresql/dataexportPGDATA后,可使用 pg_ctl 工具进

2、行启动 :plain viewplaincopyprint?postgreslocalhost log$ pg_ctl start -l/opt/postgresql/log/pg_server.logpg_ctl: another server mightbe running; trying to start server anywaypg_ctl: could notstart server Examine the log output. postgreslocalhostlog$因为之前已经启动,所以打印“another server might berunning ”。此时,查看日志,

3、有如下信息:html viewplaincopyprint?postgreslocalhost log$ cat pg_server.logFATAL:lock file "postmaster.pid" already existsHINT: Isanother postmaster (PID 4491) running in data directory"/opt/postgresql/data"? postgreslocalhost log$当然,最简的启动方式是: html viewplaincopyprint?postgreslocalhost

4、 $ pg_ctl startserverstarting postgreslocalhost $ 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文件中加以下语句:plain viewplaincopyprint?/opt/postgresql/bin/pg_ctl start

5、 -l /opt/postgresql/log/pg_server.log -D /opt/postgresql/data2.关闭服务器最简单方法:html viewplaincopyprint?postgreslocalhost $ pg_ctl stopwaitingfor server to shut down. done server stopped与 oracle 相同,在关闭时也可采用不同的模式,简介如下:html viewplaincopyprint?SIGTERM不再允许新的连接,但是允许所有活跃的会话正常完成他们的工作,只有在所有会话都结束任务后才关闭。这是智能关闭。SIGI

6、NT不再允许新的连接,向所有活跃服务器发送SIGTERM( 让它们立刻退出),然后等待所有子进程退出并关闭数据库。这是快速关闭。SIGQUIT令 postgres 向所有子进程发送SIGQUIT并且立即退出 (所有子进程也会立即退出),而不会妥善地关闭数据库系统。这是立即关闭。这样做会导致下次启动时的恢复(通过重放WAL日志 )。我们推荐只在紧急的时候使用这个方法。SIGKILL此选项尽量不要使用,这样会阻止服务器清理共享内存和信号灯资源,那样的话你只能在启动服务器之前自己手工做这件事。另外,SIGKILL直接把postgres 杀掉,而不会等它把信号中继给它的子进程,因此我们还需要手工杀掉每

7、个独立子进程。使用方法举例:html view plaincopyprint?postgreslocalhost $ pg_ctl stop-o SIGTERMLOG:received smart shutdown requestLOG:autovacuum launcher shutting downwaiting forserver to shut down.LOG:shutting downLOG:databasesystem is shut downdoneserver stoppedpostgreslocalhost $最快速关闭方法:kill postgres进程 html vie

8、wplaincopyprint?postgreslocalhost $ kill -INT head -1 /opt/postgresql/data/postmaster.pid postgreslocalhost$ 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 启动后的进程,如下:html

9、viewplaincopyprint?postgreslocalhost $ ps -ef|grep post 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:00root/opt/postgresql/bin/postgrespostgres472647240 14:08 ?00:00:00 postgres: writer processpostgres47274724014:08 ?00:00:00 postgres: wal writer processpostgres47284724014:08 ?00:00:00 postgres:autovacuum launcher process postgres4729 4724 014:08 ?0

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论