


下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 社会工作者考试备考指南与试题及答案
- 系统分析师案例分析的技巧及试题及答案
- 网络规划设计师行业未来趋势试题及答案
- 2025年网络规划设计师考试中的合规性与企业风险管控探讨试题及答案
- 高效沟通在软件评测师考试中的试题及答案
- 2025年系统集成考试通关秘籍试题及答案
- 2025年网络规划设计师备考入门试题及答案
- 如何备考2025年多媒体应用设计师考试的试题及答案
- 虚拟化技术对网络的影响试题及答案
- 2025年系统分析师考试有效反馈试题及答案
- 合资公司的组织结构与运营规范
- 成都设计咨询集团有限公司2025年社会公开招聘(19人)笔试参考题库附带答案详解
- 基层医疗卫生机构信息化建设中的医疗信息化服务创新与产业链协同发展路径报告
- 海南省历年中考作文题与审题指导(2003-2023)
- 幼儿照护知到课后答案智慧树章节测试答案2025年春铁门关职业技术学院
- 2025衢州辅警考试题库
- 出差工作总结模版
- GB/T 10810.2-2025眼镜镜片第2部分:渐变焦
- 复旦大学面试题及答案
- 八年级语文上册第四单元整体公开课一等奖创新教学设计
- 2025年电潜螺杆泵项目可行性研究报告
评论
0/150
提交评论