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 [email protected].$i;done
    192.168.115.130
        ssh-keygen
        for i in 128 131 132;do ssh-copy-id [email protected].$i;done
    192.168.115.131
        ssh-keygen
        for i in 130 128 132;do ssh-copy-id [email protected].$i;done
    192.168.115.132
        ssh-keygen
        for i in 130 131 128;do ssh-copy-id [email protected].$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

mariadb高可用mha_第1张图片

mha上安装node 加 manager

四、配置mha

mariadb高可用mha_第2张图片

mariadb高可用mha_第3张图片

 

 

 

 

 

mariadb高可用mha_第4张图片

mariadb高可用mha_第5张图片

mariadb高可用mha_第6张图片

mariadb高可用mha_第7张图片

mariadb高可用mha_第8张图片

mariadb高可用mha_第9张图片

 

 

你可能感兴趣的:(mariadb)