Error[8]: Undefined offset: 1, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述在手动安装(针对源码编译PG或者是解压缩版安装PG的情形)情况下,PG并不是在开机的情况下自动启动,在关机的情况下自动停止,作为DBA人员来说,显然这样的情形是无法接受的。 1. windows下的服务自启动 在Windows下, 可以使用pg_ctl命令生成PostgreSQL服务,并让它自启动。实际上,安装版本也是这么做的。  我们不妨看看pg_ctl命令的详细帮助先: D:\pg921>pg

在手动安装(针对源码编译PG或者是解压缩版安装PG的情形)情况下,PG并不是在开机的情况下自动启动,在关机的情况下自动停止,作为DBA人员来说,显然这样的情形是无法接受的。


1. windows下的服务自启动


在windows下, 可以使用pg_ctl命令生成Postgresql服务,并让它自启动。实际上,安装版本也是这么做的。 我们不妨看看pg_ctl命令的详细帮助先:

@H_419_12@D:\pg921>pg_ctl --helppg_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 necessaryOptions 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 restartAllowed signal names for kill: ABRT HUP INT QUIT TERM USR1 USR2Options 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 serverStart types are: auto start service automatically during system startup (default) demand start service on demandReport BUGs to <pgsql-BUGs@postgresql.org>.从上边可以看出,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。

验证一下上述命令生成的效果:

@H_419_12@D:\pg921>net start pg921The pg921 service is starting.The pg921 service was started successfully.D:\pg921>psql -p 5433 iiheropsql (9.2.1)Type "help" for help.iihero=# \q


2. linux下的服务自启动


在linux下,我们需要写一个自启动的脚本,至少支持两个命令选项: start 和 stop,并将这个脚本建立适当的链接。我们就以Ubuntu10为例,

先看看系统有没有chkconfig命令工具:

xionghe@seanlinux2:~$ chkconfig
程序“chkconfig”尚未安装。 您可以使用以下命令安装:
sudo apt-get install chkconfig
xionghe@seanlinux2:~$ sudo apt-get install chkconfig

脚本内容如下: 放入目录/etc/init.d目录下边

#! /bin/sh# Installation prefixprefix=/home/xionghe/pgsql# Data directoryPGDATA="/home/xionghe/pgsql/data"# Who to run the postmaster as,usually "postgres".  (NOT "root")PGUSER=xionghe# Where to keep a log filePGLOG="$PGDATA/serverlog"# It's often a good IDea to protect the postmaster from being killed by the# OOM killer (which will tend to preferentially kill the postmaster because# of the way it accounts for shared memory).  Setting the OOM_ADJ value to# -17 will disable OOM kill altogether.  If you enable this,you probably want# to compile Postgresql with "-DliNUX_OOM_ADJ=0",so that indivIDual backends# can still be killed by the OOM killer.#OOM_ADJ=-17## Stop EDITING HERE# The path that is to be used for the scriptPATH=/home/xionghe/pgsql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin# What to use to start up the postmaster.  (If you want the script to wait# until the server has started,you Could use "pg_ctl start -w" here.# But without -w,pg_ctl adds no value.)DAEMON="$prefix/bin/postmaster"# What to use to shut down the postmasterPGCTL="$prefix/bin/pg_ctl"set -e# Only start if we can find the postmaster.test -x $DAEMON ||{	echo "$DAEMON not found"	if [ "" = "stop" ]	then exit 0	else exit 5	fi}# Parse command line parameters.case  in  start)	echo -n "Starting Postgresql: "	test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj	su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1	echo "ok"	;;  stop)	echo -n "StopPing Postgresql: "	su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"	echo "ok"	;;  restart)	echo -n "Restarting Postgresql: "	su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"	test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj	su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1	echo "ok"	;;  reload)        echo -n "Reload Postgresql: "        su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"        echo "ok"        ;;  status)	su - $PGUSER -c "$PGCTL status -D '$PGDATA'"	;;  *)	# Print help	echo "Usage: [+++] {start|stop|restart|reload|status}" 1>&2	exit 1	;;esacexit 0

建立相应链接:

root@seanlinux2:/etc# ln -s /etc/init.d/postgresql /etc/rc0.d/K02postgresqlroot@seanlinux2:/etc# ln -s /etc/init.d/postgresql /etc/rc1.d/K02postgresqlroot@seanlinux2:/etc# ln -s /etc/init.d/postgresql /etc/rc2.d/K02postgresqlroot@seanlinux2:/etc# ln -s /etc/init.d/postgresql /etc/rc3.d/K98postgresqlroot@seanlinux2:/etc# ln -s /etc/init.d/postgresql /etc/rc4.d/K98postgresqlroot@seanlinux2:/etc# ln -s /etc/init.d/postgresql /etc/rc5.d/K98postgresql

总结

以上是内存溢出为你收集整理的循序渐进PostgreSQL: 实现PostgreSQL自启动全部内容,希望文章能够帮你解决循序渐进PostgreSQL: 实现PostgreSQL自启动所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
循序渐进PostgreSQL: 实现PostgreSQL自启动_sql_内存溢出

循序渐进PostgreSQL: 实现PostgreSQL自启动

循序渐进PostgreSQL: 实现PostgreSQL自启动,第1张

概述在手动安装(针对源码编译PG或者是解压缩版安装PG的情形)情况下,PG并不是在开机的情况下自动启动,在关机的情况下自动停止,作为DBA人员来说,显然这样的情形是无法接受的。 1. windows下的服务自启动 在Windows下, 可以使用pg_ctl命令生成PostgreSQL服务,并让它自启动。实际上,安装版本也是这么做的。  我们不妨看看pg_ctl命令的详细帮助先: D:\pg921>pg

在手动安装(针对源码编译PG或者是解压缩版安装PG的情形)情况下,PG并不是在开机的情况下自动启动,在关机的情况下自动停止,作为DBA人员来说,显然这样的情形是无法接受的。


1. windows下的服务自启动


在windows下, 可以使用pg_ctl命令生成Postgresql服务,并让它自启动。实际上,安装版本也是这么做的。 我们不妨看看pg_ctl命令的详细帮助先:

@H_419_12@D:\pg921>pg_ctl --helppg_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 necessaryOptions 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 restartAllowed signal names for kill: ABRT HUP INT QUIT TERM USR1 USR2Options 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 serverStart types are: auto start service automatically during system startup (default) demand start service on demandReport BUGs to <pgsql-BUGs@postgresql.org>.从上边可以看出,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。

验证一下上述命令生成的效果:

@H_419_12@D:\pg921>net start pg921The pg921 service is starting.The pg921 service was started successfully.D:\pg921>psql -p 5433 iiheropsql (9.2.1)Type "help" for help.iihero=# \q


2. linux下的服务自启动


在linux下,我们需要写一个自启动的脚本,至少支持两个命令选项: start 和 stop,并将这个脚本建立适当的链接。我们就以Ubuntu10为例,

先看看系统有没有chkconfig命令工具:

xionghe@seanlinux2:~$ chkconfig
程序“chkconfig”尚未安装。 您可以使用以下命令安装:
sudo apt-get install chkconfig
xionghe@seanlinux2:~$ sudo apt-get install chkconfig

脚本内容如下: 放入目录/etc/init.d目录下边

#! /bin/sh# Installation prefixprefix=/home/xionghe/pgsql# Data directoryPGDATA="/home/xionghe/pgsql/data"# Who to run the postmaster as,usually "postgres".  (NOT "root")PGUSER=xionghe# Where to keep a log filePGLOG="$PGDATA/serverlog"# It's often a good IDea to protect the postmaster from being killed by the# OOM killer (which will tend to preferentially kill the postmaster because# of the way it accounts for shared memory).  Setting the OOM_ADJ value to# -17 will disable OOM kill altogether.  If you enable this,you probably want# to compile Postgresql with "-DliNUX_OOM_ADJ=0",so that indivIDual backends# can still be killed by the OOM killer.#OOM_ADJ=-17## Stop EDITING HERE# The path that is to be used for the scriptPATH=/home/xionghe/pgsql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin# What to use to start up the postmaster.  (If you want the script to wait# until the server has started,you Could use "pg_ctl start -w" here.# But without -w,pg_ctl adds no value.)DAEMON="$prefix/bin/postmaster"# What to use to shut down the postmasterPGCTL="$prefix/bin/pg_ctl"set -e# Only start if we can find the postmaster.test -x $DAEMON ||{	echo "$DAEMON not found"	if [ "" = "stop" ]	then exit 0	else exit 5	fi}# Parse command line parameters.case  in  start)	echo -n "Starting Postgresql: "	test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj	su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1	echo "ok"	;;  stop)	echo -n "StopPing Postgresql: "	su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"	echo "ok"	;;  restart)	echo -n "Restarting Postgresql: "	su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"	test x"$OOM_ADJ" != x && echo "$OOM_ADJ" > /proc/self/oom_adj	su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1	echo "ok"	;;  reload)        echo -n "Reload Postgresql: "        su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"        echo "ok"        ;;  status)	su - $PGUSER -c "$PGCTL status -D '$PGDATA'"	;;  *)	# Print help	echo "Usage:  {start|stop|restart|reload|status}" 1>&2	exit 1	;;esacexit 0

建立相应链接:

root@seanlinux2:/etc# ln -s /etc/init.d/postgresql /etc/rc0.d/K02postgresqlroot@seanlinux2:/etc# ln -s /etc/init.d/postgresql /etc/rc1.d/K02postgresqlroot@seanlinux2:/etc# ln -s /etc/init.d/postgresql /etc/rc2.d/K02postgresqlroot@seanlinux2:/etc# ln -s /etc/init.d/postgresql /etc/rc3.d/K98postgresqlroot@seanlinux2:/etc# ln -s /etc/init.d/postgresql /etc/rc4.d/K98postgresqlroot@seanlinux2:/etc# ln -s /etc/init.d/postgresql /etc/rc5.d/K98postgresql

总结

以上是内存溢出为你收集整理的循序渐进PostgreSQL: 实现PostgreSQL自启动全部内容,希望文章能够帮你解决循序渐进PostgreSQL: 实现PostgreSQL自启动所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1178423.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存