Centos7设置postgresql自动启动服务

环境:
OS:Centos 7
DB:13.8

 

1.创建postgresql.service

vi /lib/systemd/system/postgresql.service 

[Unit]
Description=redis
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
Type=forking
User=postgres
Group=postgres
ExecStart=/opt/pg13/bin/pg_ctl -D /opt/pg13/data -l /opt/pg13/log/postgres.log start
ExecReload=
ExecStop=/opt/pg13/bin/pg_ctl -D /opt/pg13/data -l /opt/pg13/log/postgres.log stop
PrivateTmp=true

 

2.设置开机启动
chmod 754 /usr/lib/systemd/system/postgresql.service

systemctl enable postgresql.service
systemctl status postgresql.service
systemctl start postgresql.service
systemctl stop postgresql.service

posted @ 2022-10-18 15:31  slnngk  阅读(882)  评论(0)    收藏  举报