美文网首页
MMM架构(Multi-Master Replication M

MMM架构(Multi-Master Replication M

作者: hemingkung | 来源:发表于2020-06-26 08:40 被阅读0次

    MMM(pertl语言)

    监控了Mysql主从复制健康情况
    主动主动模式的主主复制
    主动被动模式的主主复制

    f171d138bd6a2fa914c532643fa9386.png

    开启mysql的binlog日志功能,在/etc/my.cf上添加以下两行:


    ecbe50af9118434a69ea30e7cb9365a.png
    mysql -uroot -p123456
    show variables like 'binlog_format';
    set session binlog_format=statement;
    show binary logs;
    flush logs;
    
    查看binlog日志(/var/lib/mysql)
    find / -name mysql-bin.index
    nysqlbinlog mysql-bin.000002
    
    
    set session binlog_format=row;
    show binary logs;
    flush logs;
    
    binlog_row_image
    
    在DB服务器上建立复制账号
    create user 'repl'  @'IP段' identified by 'PassW0rd'
     
    grant replication slave on *.* to 'repl' @'IP段';
    
    
    从数据库用户repl的建立
    开放网段192.168.43.%
    create user repl@'192.168.43.%' identified by '123456';
    授权
    grant replication slave on *.* to repl@'192.168.43.%';
    
    备份原有的数据
    mysqldump --single-transaction --master-data --triggers --routines --all-databases -uroot -p123456 >>all.sql
    
    1、主数据库的数据库及其数据转移到从数据库
    从数据库进行数据的初始化
    备份主数据库的数据:
    mysqldump --single-transaction --master-data --triggers --routines --all-databases -uroot -p123456 >>all.sql
    
    传入从数据库:
    确保主从数据库都有装scp命令集
    
    将到处的数据库初始化数据传输到从服务器的根目录下
    scp all.sql root@192.168.43.156:/root
    
    从服务器执行all.sql
    mysql -uroot -p < all.sql
    
    从节点中查看数据是否同步成功
    show databases;
    
    从服务器中  配置主从复制
    
    主服务器中查看MASTER_LOG_FILE文件名及偏移量
    MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS=1013;
    
    从服务器:
    mysql -uroot -p123456
    
    change master to master_host='192.168.43.230', master_user='repl' , master_password='123456' , MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS=1013;
    
    
    show slave status \G
    
    start slave
    
    show slave status \G
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    相关文章

      网友评论

          本文标题:MMM架构(Multi-Master Replication M

          本文链接:https://www.haomeiwen.com/subject/nzasfktx.html