Linux pg_ctl命令控制PostgreSQL服务

功能描述

pg_ctl是一个启动、停止、重新启动、重新加载配置文件、报告PostgreSQL服务器的状态,或者是杀掉PostgreSQL进程的工具。

命令语法

pg_ctl [命令] [选项]

选项含义

选项含义
-D<数据目录>指定数据存储的位置
-s只显示错误信息,没有其他信息
-t<等待时间>指定当使用-w选项时需要等待的秒数
-W不用等待操作完成
-w等待直到操作完成
-l<日志文件>写入或追加PostgreSQL服务器日志到指定文件中
-c允许postgres进程产生核心文件
-m<关闭模式>停止或重启的选项,关闭模式有以下几种方式
smart:所有客户端断开连接后退出
fast:直接退出,正确的关闭
immediate:不完全的关闭退出,重启后恢复
命令描述
start启动postgresql服务
stop停止postgresql服务
restart重新启动postgresql服务
reload重新加载postgresql服务配置
status查看postgresql服务运行状态

启动postgresql服务
[root@liinuxlz.com~]# su – postgres
$ pg_ctl start

查看postgresql服务运行状态
[root@liinuxlz.com~]# su – postgres
$ pg_ctl status

停止postgresql服务
[root@liinuxlz.com~]# su – postgres
$ pg_ctl stop

重新启动postgresql服务
[root@liinuxlz.com~]# su – postgres
$ pg_ctl restart

重新加载postgresql服务配置
[root@liinuxlz.com~]# su – postgres
$ pg_ctl reload

正文完
 0