mariadb高可用mha

一、ssh免密登录
    所有节点配置hosts
        192.168.115.128    mgt
        192.168.115.130    master
        192.168.115.131    slave1
        192.168.115.132    slave2
    192.168.115.128
        ssh-keygen
        for i in 130 131 132;do ssh-copy-id root@192.168.115.$i;done
    192.168.115.130
        ssh-keygen
        for i in 128 131 132;do ssh-copy-id root@192.168.115.$i;done
    192.168.115.131
        ssh-keygen
        for i in 130 128 132;do ssh-copy-id root@192.168.115.$i;done
    192.168.115.132
        ssh-keygen
        for i in 130 131 128;do ssh-copy-id root@192.168.115.$i;done
    测试
        for i in 128 130 131;do ssh 192.168.115.$i hostname;done

二、构建mha

主从复制
    安装mariadb数据库并启动
        for i in 130 131 132;do ssh 192.168.115.$i yum install -y mariadb mariadb-server  mariadb;done
    配置主从复制
        master
            vim  /etc/my.cnf
            [mysqld]
server-id = 20
log-bin = master-bin
log-slave-updates = true
            systemctl restart mariadb
            mysql -e "grant replication slave on *.* to 'myslave'@'192.168.115.%' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.115.%' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.115.128' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.115.131' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.115.132' identified by '123.com';"

            mysql -e "show master status";
        slave
            server-id=30
log-bin=master-bin
relay-log=relay-log-bin
relay-log-index=relay-log-bin.index

            mysql -e "grant replication slave on *.* to 'myslave'@'192.168.115.%' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.115.%' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.115.128' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.115.131' identified by '123.com';"
mysql -e "grant all privileges on *.* to 'mha'@'192.168.115.132' identified by '123.com';"
            mysql -e "change master to master_host='192.168.115.130',master_
user='myslave',master_password='123.com',master_log_file='master-bin.000003',master_log_pos=1166;"
        验证
            master
                mysql -e "create database jx;"
            slave
                mysql -e "show databases;"

三、mha安装

所有节点安装perl环境
    yum install epel-release -y
    yum -y install perl-DBD-MySQL perl-ExtUtils-MakeMaker perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager perl-Time-HiRes perl-CPAN

所有节点安装node
    tar xf mha4mysql-node-0.57.tar.gz
    cd mha4mysql-node-0.57
    perl Makefile.PL && make && make install

验证
    cd /usr/local/bin
    看到脚本就OK

mha上安装node 加 manager

四、配置mha

 

 

 

 

 

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值