当前位置:首页 > 编程笔记 > 正文
已解决

Ubuntu Postgresql开机自启动服务

来自网友在路上 141841提问 提问时间:2023-09-27 08:25:45阅读次数: 41

最佳答案 问答题库418位专家为你答疑解惑

 1. 建立service文件

sudo vim /etc/systemd/system/postgresql.service
2. postgresql service文件
[Unit]
Description=PostgreSQL 14 database server
Documentation=man:postgres(1)
Documentation=http://www.postgresql.org/docs/14/static/
After=network.target[Service]
Type=forking
User=postgres
Group=postgres
ExecStart=/usr/bin/pg_ctl start -D /usr/local/postgresql-11.4/data -l /usr/local/postgresql-11.4/log/pg_server.log 
ExecStop=/usr/bin/pg_ctl stop -D /usr/local/postgresql-11.4/data -l /usr/local/postgresql-11.4/log/pg_server.log
ExecReload=/usr/bin/pg_ctl reload -D /usr/local/postgresql-11.4/data -l /usr/local/postgresql-11.4/log/pg_server.log
PIDFile=/usr/local/postgresql-11.4/data/postmaster.pid
TimeoutStopSec=0
Restart=always
User=postgres
Group=postgres
RuntimeDirectory=postgresql
RuntimeDirectoryMode=2755
UMask=007
PrivateTmp=yes
LimitNOFILE=65535
PrivateDevices=yes
ProtectHome=yes
ReadOnlyDirectories=/
ReadWriteDirectories=-/usr/local/postgresql-11.4
ReadWriteDirectories=-/etc/postgresql[Install]
WantedBy=multi-user.target
Alias=postgresql.service
3. 启动服务并检查状态
$ systemctl daemon-reload
$ systemctl start postgresql
$ systemctl status postgresql
$ systemctl restart postgresql

4. 开机自启动 

$ systemctl enable postgresql

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"Ubuntu Postgresql开机自启动服务":http://eshow365.cn/6-14540-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!