博客
关于我
Haproxy+pacemake+fence实现高mycat的可用
阅读量:519 次
发布时间:2019-03-07

本文共 2051 字,大约阅读时间需要 6 分钟。

Haproxy+Pacemake+Fence高可用性Mycat部署

部署Haproxy

安装xinetd(server7、server8)

在Mycat服务主机(server7、server8)上,需要安装xinetd并配置Mycat存活状态检测脚本。

  • 安装软件:
  • yum -y install xinetd
    1. 配置xinetd及Mycat状态检测服务:
      • 打开配置文件:
      vim /etc/xinetd.conf
      • 添加或确认存在 /etc/xinetd.d/mycat_status 文件:
      touch /etc/xinetd.d/mycat_status
      1. 配置mycat_status检测脚本:
        • 创建如下脚本:
        vim /usr/local/bin/mycat_status
        #!/bin/bashMycat=`/usr/local/mycat/bin/mycat status | grep 'not running' | wc -l`if [ "$Mycat" = "0" ]; then    echo -e "HTTP/1.1 200 OK\r"else    echo -e "HTTP/1.1 503 Service Unavailable\r"fi
        1. 赋予脚本执行权限:
        2. chmod +x /usr/local/bin/mycat_status
          1. 启动xinetd服务:
          2. systemctl start xinetd.service
            1. 验证配置:
            2. systemctl status xinetd.service

              在终端执行命令 netstat -antup|grep 48700 检查是否监听成功。

              部署Haproxy

              安装Haproxy

              yum install haproxy -y

              配置Haproxy

              编辑配置文件:

              vim /etc/haproxy/haproxy.cfg

              配置示例

              global=log 127.0.0.1 local0 infochroot /usr/share/haproxygroup haproxyuser haproxydaemonnbproc 1maxconn 4096timeout connect 5000mstimeout client 50000mstimeout server 50000mslisten mycat_serversbind :80stats /admin-statusstats auth admin:adminmode httploglisten mycat_serversbind :3307mode tcplogbalance roundrobinserver mycat_01 172.25.12.7:8066 check port 48700 inter 2000ms rise 2 fall 3 weight 10server mycat_02 172.25.12.8:8066 check port 48700 inter 2000ms rise 2 fall 3 weight 10

              启动服务

              systemctl start haproxy.service

              Pacemaker集群部署

              配置Pacemaker

              启动Pacemaker并注册VIP和Haproxy资源:

              pcs resource create vip ocf:heartbeat:IPaddr2 ip=172.25.12.100 op monitor interval=30pcs resource create haproxy systemd:haproxy op monitor interval=60

              绑定资源组

              将VIP和Haproxy绑定到同一组:

              pcs resource group add haproxy-group haproxy vip

              处理网络故障

              在server5上执行以下命令:

              ip link set down eth0

              然后重启服务5,自动转移到server6。

              添加Fence设备

              安装Fence

              yum install fence-virt -y

              配置Fence资源

              创建虚拟机保护资源:

              pcs stonith create vmfence fence_xvm pcmk_host_map="server5:demo5;server6:demo6" op monitor interval=60

              启用STONITH

              在Pacemaker中启用STONITH:

              pcs property set stonith-enabled=true

              验证集群配置:

              crm_verify -LV

              测试高可用性

              执行命令访问Mycat服务:

              mysql -uroot -h172.25.12.100 -P3307 westos

              通过以上步骤,成功部署了Haproxy+Pacemake+Fence实现Mycat的高可用性解决方案。

    转载地址:http://beknz.baihongyu.com/

    你可能感兴趣的文章
    PostgreSQL 10.1 手册_部分 III. 服务器管理_第 21 章 数据库角色
    查看>>
    Qt开发——网络编程UDP网络广播软件之服务器端
    查看>>
    Postgresql 12.9如何配置允许远程连接
    查看>>
    PostgreSQL 9.6 同步多副本 与 remote_apply事务同步级别 应用场景分析
    查看>>
    Postgresql CopyManager 流式批量数据入库
    查看>>
    PostgreSQL cube 插件 - 多维空间对象
    查看>>
    PostgreSQL Daily Maintenance - cluster table
    查看>>
    PostgreSQL on Linux 最佳部署手册
    查看>>
    PostgreSQL Oracle 兼容性之 - pipelined
    查看>>
    PostgreSQL Point-In-Time Recovery (Incremental Backup)
    查看>>
    postgresql Streaming Replication监控与注意事项
    查看>>
    postgresql 不需要付费_使用数据传输在PostgreSQL执行 外部连接运算符
    查看>>
    postgresql 主从配置_生产环境postgresql主从环境配置
    查看>>
    postgresql 函数&存储过程 ; 递归查询
    查看>>
    PostgreSQL 分组聚合查询中 filter 子句替换 case when
    查看>>
    PostgreSQL 同步流复制锁瓶颈分析
    查看>>
    PostgreSQL 备份与还原命令 pg_dump
    查看>>
    Postgresql 外部表插件postgres_fdw的安装和使用
    查看>>
    PostgreSQL 如何从崩溃状态恢复(上)
    查看>>
    PostgreSQL 存储过程基本语法
    查看>>