redhat/centos 分支
免密执行
# vi /etc/sudoers.d/postgres
postgres ALL=(ALL:ALL) NOPASSWD:ALL
debian/ubutu 分支
免密执行
# vi /etc/sudoers
postgres ALL=(ALL:ALL) NOPASSWD:ALL
或者最小权限
# vi /etc/sudoers
postgres ALL=(ALL:ALL) NOPASSWD:/sbin/ip,/sbin/ifup,/sbin/ifdown,/sbin/ifconfig,/sbin/iptables,/usr/sbin/arping, \
/bin/systemctl stop postgresql, \
/bin/systemctl start postgresql, \
/bin/systemctl restart postgresql, \
/bin/systemctl reload postgresql
额外处理
发现pgpool的日志有如下信息
2019-07-23 14:22:37: pid 107145: DETAIL: arping[/usr/sbin/arping] doesn't have setuid bit
需要执行 +s 权限
# chmod +s /sbin/ip;
chmod +s /sbin/ifup;
chmod +s /sbin/ifdown;
chmod +s /sbin/ifconfig;
chmod +s /sbin/iptables;
chmod +s /usr/sbin/arping;