使用systemd管理repmgrd服務

為方便服務管理以及讓repmgrd能夠開機自動啟動,建議新增repmgrd的systemd config

~$ sudo vim /lib/systemd/system/repmgrd.service

加入以下內容

[Unit]
Description=repmgrd monitor service
After=network.target auditd.service

[Service]
Type=simple
ExecStart=/usr/bin/repmgrd -m 
KillMode=process
Restart=on-failure
ExecStop=/bin/kill -s TERM $MAINPID
User=postgres

[Install]
WantedBy=multi-user.target

~$ sudo systemctl enable repmgrd.service
Synchronizing state of repmgrd.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable repmgrd

啟用repmgrd服務

~$ sudo systemctl enable repmgrd.service
Synchronizing state of repmgrd.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable repmgrd

啟動服務並觀察狀態

~$ sudo systemctl start repmgrd.service
~$ sudo systemctl status repmgrd.service 
● repmgrd.service - repmgrd monitor service
   Loaded: loaded (/lib/systemd/system/repmgrd.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Tue 2017-11-07 14:14:00 CST; 4s ago
  Process: 44385 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
  Process: 44381 ExecStart=/usr/bin/repmgrd -m -d (code=exited, status=0/SUCCESS)
 Main PID: 44381 (code=exited, status=0/SUCCESS)

Nov 07 14:14:00 pgdbnode2 systemd[1]: Started repmgrd monitor service.

除了透過systemctl管服務外,也可以透過以下方式啟動與停止服務

~$ sudo service repmgrd start

~$ sudo service repmgrd stop

results matching ""

    No results matching ""