pacemaker控制haproxy容器
三台centos7.6192.168.1.1192.168.1.2192.168.1.3三台机器执行yum install -y corosync pacemaker pcssystemctl start pcsd systemctl enable pcsd systemctl status pcsdecho PCSD_PORT18888 /etc/sysconfig/pcsdsystemctl restart pcsdecho 123456 | passwd --stdin hacluster选择一台执行pcs cluster auth 192.168.1.1:18888 192.168.1.2:18888 192.168.1.3:18888 -u hacluster -p 123456pcs cluster setup --force --name haproxy --transportudpu --mcastport0 19999 192.168.1.1 192.168.1.2 192.168.1.3pcs cluster start --allpcs cluster enable --allpcs property set stonith-enabledfalsecrm_verify -Lpcs resource create vip1 --disabled ocf:heartbeat:IPaddr niceth0 ip192.168.1.100 cidr_netmask24 broadcast192.168.1.255 op monitor interval5s timeout20spcs resource create haproxy1 ocf:heartbeat:docker force_kill1 imagehaproxy-init:v1.0 namehaproxy1 run_opts-it --nethost --dns8.8.8.8 -h haproxy1 -v /root/haproxy.cfg:/etc/haproxy/haproxy.cfg:ro --privileged run_cmd/usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -Dspcs resource group add service1 vip1 haproxy1pcs resource enable vip1 haproxy1pcs resource cleanup service1pcs status手工创建删除haproxy容器# docker run -itd --nethost --dns 8.8.8.8 \--namehaproxy1 -h haproxy1 \-v /etc/localtime:/etc/localtime:ro \-v /root/linz/haproxy.cfg:/etc/haproxy/haproxy.cfg:ro \--privileged \haproxy-init:v1.0 \/usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -Ds删除容器# docker rm -f haproxy1ocf:heartbeat:docker允许使用的设置# pcs resource describe ocf:heartbeat:docker可设置选项: allow_pull, force_kill, image, monitor_cmd, mount_points, name, query_docker_health, reuse, run_cmd, run_opts, trace_file, trace_ra# cat /usr/lib/ocf/resource.d/heartbeat/dockerocf_run docker run $run_opts $OCF_RESKEY_image $OCF_RESKEY_run_cmd$run_opts默认设置有-d --name${CONTAINER}