Linux下设置postgresql数据库开机启动

PostgreSQL的开机自启动脚本位于PostgreSQL源码目录的contrib/start-scripts路径下,linux文件即为linux系统上的启动脚本:

1、将Linux文件复制到 /etc/init.d 目录下,并且将其重名为postgresql

  # cp linux /etc/init.d/postgresql   

2、进入 /etc/init.d 目录下,修改postgresql文件

  # cd /etc/init.d/   

  # vi postgresql   

然后做以下修改:

将prefix设置为postgresql的安装路径:/usr/local/postgresql

将PGDATA设置为postgresql的数据目录路径:/usr/local/postgresql/data

将PGUSER设置为postgresql的用户:admin

将PGLOG 设置为 postgresql 的数据目录的日志文件夹下:$PGDATA/pg_log/serverlog

保存退出!

3、  添加到开机启动

修改文件属性:

# chmod a+x postgresql   

添加开机启动:

# chkconfig --add postgresql  

 

服务正常开启,重启机器测试:

重启之后,开机,服务正常开启:

外部Navicat连接测试正常:

猜你喜欢

转载自www.cnblogs.com/guoxiangyue/p/10956600.html