Loading... 三台centos7.6 ``` 192.168.1.1 192.168.1.2 192.168.1.3 ``` 三台机器执行: ``` yum install -y corosync pacemaker pcs systemctl start pcsd && systemctl enable pcsd && systemctl status pcsd echo "PCSD_PORT=18888" >> /etc/sysconfig/pcsd systemctl restart pcsd echo '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 123456 pcs cluster setup --force --name haproxy --transport=udpu --mcastport0 19999 192.168.1.1 192.168.1.2 192.168.1.3 pcs cluster start --all pcs cluster enable --all pcs property set stonith-enabled=false crm_verify -L pcs resource create vip1 --disabled ocf:heartbeat:IPaddr nic=eth0 ip=192.168.1.100 cidr_netmask=24 broadcast=192.168.1.255 op monitor interval=5s timeout=20s pcs resource create haproxy1 ocf:heartbeat:docker force_kill=1 image="haproxy-init:v1.0" name=haproxy1 run_opts="-it --net=host --dns=8.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 -Ds" pcs resource group add service1 vip1 haproxy1 pcs resource enable vip1 haproxy1 pcs resource cleanup service1 pcs status ``` 手工创建删除haproxy容器 ```null # docker run -itd --net=host --dns 8.8.8.8 \ --name=haproxy1 -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 ``` 删除容器 ```null # docker rm -f haproxy1 ``` `ocf:heartbeat:docker`允许使用的设置 ```null # 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/docker ocf_run docker run $run_opts $OCF_RESKEY_image $OCF_RESKEY_run_cmd $run_opts默认设置有-d --name=${CONTAINER} ``` 最后修改:2022 年 10 月 20 日 05 : 12 PM © 允许规范转载 赞赏 要多恰饭才能长胖 赞赏作者 支付宝微信