• mysql备份之主从同步


    主实例配置:

    [mysqld]
    log-bin=mysql-bin   #/ [必须]启用二进制日志
    server-id=1         # [必须]服务器唯一ID
    

    从实例配置:

    [mysqld]
    log-bin=mysql-bin   # [非必须]Slave可以不启用二进制日志,配置二进制日志可以便于Master和Slave交换角色
    server-id=2         # [必须]服务器唯一ID
    

    在Master上使用root用户登录建立同步账户并授权Slave

    mysql> GRANT REPLICATION SLAVE ON *.* to 'lover'@'%' identified by 'kiss';
    mysql> FLUSH PRIVILEGES;
    

    使用root账户登录Master查看Master状态

    mysql> show master status;
    +------------------+----------+--------------+------------------+-------------------+
    | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
    +------------------+----------+--------------+------------------+-------------------+
    | mysql-bin.000002 |     6584 | thisonedb    | mysql            |                   |
    +------------------+----------+--------------+------------------+-------------------+
    

    配置Slave跟踪Master日志的位置

    mysql> change master to master_host='127.0.0.1',master_user='lover',master_password='kiss',master_log_file='mysql-bin.000002',master_log_pos=6584 ;
    mysql> start slave;
    

    使用root账户登录MySQL核对Slave状态,看到如下信息就说明配置成功了

    mysql> show slave statusG;
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event 
                      Master_Host: 10.16.13.128
                      Master_User: username
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000002
              Read_Master_Log_Pos: 6584
                   Relay_Log_File: bx-13-129-relay-bin.000003
                    Relay_Log_Pos: 6797
            Relay_Master_Log_File: mysql-bin.000002
                 Slave_IO_Running: Yes 
                Slave_SQL_Running: Yes
    
  • 相关阅读:
    PAT(乙级)2020年冬季考试
    Educational Codeforces Round 105 (Rated for Div. 2)【ABC】
    三省吾身
    初识SpringBoot
    Controller 层中,到底是 返回界面 还是JSON?(转)
    IDEA控制台中文乱码解决
    springboot引入外部依赖jar包(转)
    Java7的try-with-resources声明(转)
    Java对象的序列化和反序列化(转)
    AcWing1303. 斐波那契前 n 项和(递推/矩阵快速幂)
  • 原文地址:https://www.cnblogs.com/hicolin/p/12427395.html
Copyright © 2020-2023  润新知