设为首页 加入收藏

TOP

循序渐进PostgreSQL:实现PostgreSQL自启动(一)
2014-11-24 01:33:06 来源: 作者: 【 】 浏览:18
Tags:循序渐进 PostgreSQL: 实现 PostgreSQL 启动
循序渐进PostgreSQL:实现PostgreSQL自启动
在手动安装(针对 源码编译PG或者是解压缩版安装PG的情形)情况下,PG并不是在开机的情况下自动启动,在关机的情况下自动停止,作为DBA人员来说,显然这样的情形是无法接受的。
www.2cto.com
1. windows下的服务自启动
在Windows下, 可以使用pg_ctl命令生成PostgreSQL服务,并让它自启动。实际上,安装版本也是这么做的。 我们不妨看看pg_ctl命令的详细帮助先:
D:\pg921>pg_ctl --help
pg_ctl is a utility to initialize, start, stop, or control a PostgreSQL server.
Usage:
pg_ctl init[db] [-D DATADIR] [-s] [-o "OPTIONS"]
pg_ctl start [-w] [-t SECS] [-D DATADIR] [-s] [-l FILENAME] [-o "OPTIONS"]
pg_ctl stop [-W] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]
pg_ctl restart [-w] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE]
[-o "OPTIONS"]
pg_ctl reload [-D DATADIR] [-s]
pg_ctl status [-D DATADIR]
pg_ctl promote [-D DATADIR] [-s]
pg_ctl kill SIGNALNAME PID
pg_ctl register [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR]
[-S START-TYPE] [-w] [-t SECS] [-o "OPTIONS"]
pg_ctl unregister [-N SERVICENAME]
Common options:
-D, --pgdata=DATADIR location of the database storage area
-s, --silent only print errors, no informational messages
-t, --timeout=SECS seconds to wait when using -w option
-V, --version output version information, then exit
-w wait until operation completes
-W do not wait until operation completes
- , --help show this help, then exit
(The default is to wait for shutdown, but not for start or restart.)
If the -D option is omitted, the environment variable PGDATA is used.
Options for start or restart:
-c, --core-files not applicable on this platform
-l, --log=FILENAME write (or append) server log to FILENAME
-o OPTIONS command line options to pass to postgres
(PostgreSQL server executable) or initdb
-p PATH-TO-POSTGRES normally not necessary
Options for stop or restart:
-m, --mode=MODE MODE can be "smart", "fast", or "immediate"
Shutdown modes are:
smart quit after all clients have disconnected
fast quit directly, with proper shutdown
immediate quit without complete shutdown; will lead to recovery on restart
Allowed signal names for kill:
ABRT HUP INT QUIT TERM USR1 USR2
Options for register and unregister:
-N SERVICENAME service name with which to register PostgreSQL server
-P PASSWORD password of account to register PostgreSQL server
-U USERNAME user name of account to register PostgreSQL server
-S START-TYPE service start type to register PostgreSQL server
Start types are:
auto start service automatically during system startup (default)
demand start service on demand
Report bugs to .
从上边可以看出,pg_ctl register用于生成服务,而pg_ctl unregister -N <服务名>用于删除一个服务。
如:
D:\pg921>pg_ctl register -N pg921 -D d:\pg921\data -S auto -w -t 10 -l d:/pg921/log/pg921.log -o "-p 5433"
此命令,即是要生成一个服务:pg921, 启动方式: -S auto, 自启动,如果想生成手动启动,就用-S demand来指定。
-t 10,意指等待10秒钟, 实际上可以设定的长一些(在生产环境中).
-l d:/pg921/log/pg921.log, 指定生成的日志文件的位置。
-o "-p 5433", 将服务端口号改为5433。
验证一下上述命令生成的效果:
D:\pg921>net start pg921
The pg921 service is starting.
The pg921 service was started successfully.
D:\pg921>psql -p 5433 iihero
psql (9.2.1)
Ty
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇简单的存储过程 下一篇限制MongoDB使用内存大小

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: