暂无图片
启动 PostgreSQL 服务器,怎么加入自启动服务
我来答
分享
redgame
2023-06-18
启动 PostgreSQL 服务器,怎么加入自启动服务
如题
我来答
添加附件
收藏
分享
问题补充
1条回答
默认
最新
Zixin Huo

1、查找自启动服务文件路径;
[root@localhost]# find / -name start-scripts
/opt/postgresql/postgresql-9.6.0/contrib/start-scripts

2、将linux文件拷贝到/etc/init.d/目录下,并命名为postgresql;(服务名为postgresql)

[root@localhost ]# cp
/opt/postgresql/postgresql-9.6.0/contrib/start-scripts/linux /etc/init.d/postgresql

3、修改服务文件 /etc/init.d/postgresql

#Installation prefix
#prefix=/usr/local/pgsql
#安装路径
prefix=/home/postgres
#echo “-----$prefix-----”
#Data directory
#PGDATA="/usr/local/pgsql/data"
#数据存放路径
PGDATA="/home/postgres/pgdata"

4、修改文件执行权限

[root@localhost ]#chmod a+x postgresql

[root@localhost]# ll /etc/init.d/
total 40
-rw-r–r–. 1 root root 18281 Aug 24 2018 functions
-rwxr-xr-x. 1 root root 3657 Aug 24 2018 postgresql
-rw-r–r–. 1 root root 1160 Oct 31 2018 README

5、启动服务

[root@localhost]# service postgresql restart
Restarting PostgreSQL: ok
[root@localhost]# service postgresql stop
Stopping PostgreSQL: ok
[root@localhost]# service postgresql start
Starting PostgreSQL: ok

6、设置开机自启动

[root@localhost]# chkconfig --add postgresql
[root@localhost]# chkconfig --list postgresql

Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.


  If you want to list systemd services use 'systemctl list-unit-files'.
  To see services enabled on particular target use
  'systemctl list-dependencies [target]'.


postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off

暂无图片 评论
暂无图片 有用 4
暂无图片
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏