注意事項:
- 主要就是ExedStart的路徑
- 安裝兩個版本,9.5端口默認5432,10端口默認是5433,按理可以啓動兩個服務,通過端口判斷使用那個pg服務.
- 9.5的配置中如果使用具體的路徑總是有問題,先按原來系統的走,但是必須指明配置文件,否則對應的5432端口起不來,pg服務就起不來.
- 如果要使用其中一個,最好把另一個服務stop,項目中注意配置端口,否則默認是5432
- 查看pg啓動的參數命令:ps aux | grep postgresql
Postgresql 10的service配置
[Unit]
Description=PostgreSQL-10 database server
Documentation=man:postgres(1)
[Service]
Type=notify
User=postgres
ExecStart=/usr/lib/postgresql/10/bin/postgres -D /var/lib/postgresql/10/main -c config_file=/etc/postgresql/10/main/postgresql.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
KillSignal=SIGINT
TimeoutSec=0
[Install]
WantedBy=multi-user.target
Postgresql 9.5的service配置
[Unit]
Description=PostgreSQL RDBMS
[Service]
Type=oneshot
ExecStart=/bin/true -c config_file=/etc/postgresql/9.5/main/postgresql.conf
ExecReload=/bin/true
RemainAfterExit=on
[Install]
WantedBy=multi-user.target