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

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 
posted @ 2020-08-18 10:09  左上  阅读(1029)  评论(0编辑  收藏  举报