root用户
cd /usr/lib/systemd/system
vi postgresql.service #增加下面内容,并根据实际内容修改
[Unit]
Description=PostgreSQL database server
After=network.target
[Service]
Type=forking
User=postgres
Group=postgres
OOMScoreAdjust=-1000
Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
Environment=PG_OOM_ADJUST_VALUE=0
Environment=PGSTARTTIMEOUT=300
Environment=PGDATA=/opt/pg12.4/data
ExecStart=/opt/pg12.4/bin/pg_ctl start -D ${PGDATA} -l /home/postgres/logfile -s -w -t ${PGSTARTTIMEOUT}
ExecStop=/opt/pg12.4/bin/pg_ctl stop -D ${PGDATA} -s -m fast
ExecReload=/opt/pg12.4/bin/pg_ctl reload -D ${PGDATA} -s
[Install]
WantedBy=multi-user.target
在建立文件后,postgresql.serivce需要将文件加载进systemctl并且在打开enable
systemctl daemon-reload
systemctl enable postgresql
systemctl start postgresql
systemctl list-units --type=service --state=active
systemctl list-units --type=service --state=running
本文详细指导了如何在Ubuntu系统中对postgresql.service文件进行编辑,添加启动、停止、重启及状态检查命令,确保PostgreSQL数据库服务器的顺利运行。
572

被折叠的 条评论
为什么被折叠?



