Centos 7 開機啓動PostgrepSQL 配置

參考:Centos 開機啓動Openresty之中的Nginx

PostgrepSQL是通過源碼編譯安裝,所以沒有postgrepsql.service文件(通過yum install 命令安裝就有這個文件)。

爲了實現Centos7開機自動啓動postgresql,

需要在/usr/lib/systemd/system目錄下,創建postgresql.service文件

[Unit]
Description=PostgreSQL-12 database server
After=network.target

[Service]
Type=forking

User=postgres
Group=postgres

# Port number for server to listen on
Environment=PGPORT=5431

# Location of database directory
Environment=PGDATA=/pgs/usr/local/pgsql/data

# Where to send early-startup messages from the server (before the logging
# options of postgresql.conf take effect)
# This is normally controlled by the global default set by systemd
# StandardOutput=syslog

# Disable OOM kill on the postmaster
OOMScoreAdjust=-1000

#ExecStartPre=/pgs/usr/local/pgsql/bin/postgresql-check-db-dir ${PGDATA}
ExecStart=/pgs/usr/local/pgsql/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300
ExecStop=/pgs/usr/local/pgsql/bin/pg_ctl stop -D ${PGDATA} -s -m fast
ExecReload=/pgs/usr/local/pgsql/bin/pg_ctl reload -D ${PGDATA} -s

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300

[Install]
WantedBy=multi-user.target

 

# 開機啓動
systemctl enable postgresql.service

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章