zoukankan      html  css  js  c++  java
  • mysql 主从复制

    一、master 服务器配置

    1、master 服务器my.cnf配置

    server_id=1
    log-bin=mysql-bin

    2、master 重启并查看master 状态

    show master status;
    
    结果;
    +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000001 | 2043 | | | | +------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)

    3、master 开启远程访问权限

    grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
    FLUSH PRIVILEGES

    4、master 关闭防火墙

    systemctl stop firewalld.service

    二、slave 服务器配置

    1、slave 服务器my.cnf 配置

    server_id=2
    log-bin=mysql-bin
    binlog_do_db=test

    2、slave 服务器重启并配置指向master

    change master to master_host='192.168.1.7',master_user='root',master_password='123456', master_log_file='mysql-bin.000001',master_log_pos=154;

    3、slave 开启同步

    start slave

    4、查看slave 状态

    show slave status G;
    
    结果:
    Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.1.7
                      Master_User: root
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000001
              Read_Master_Log_Pos: 2043
                   Relay_Log_File: msyqlslave-relay-bin.000004
                    Relay_Log_Pos: 576
            Relay_Master_Log_File: mysql-bin.000001
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
  • 相关阅读:
    架构之路(六):把框架拉出来
    读取mdb文件
    基类、子类之间的类型转换
    WPF Trigger
    WPF 打开txt文件
    C# 匿名方法
    自定义显隐式类型转换
    枚举获得Description扩展方法
    IFormattable和IFormatProvider
    WPF DataGrid下滑动态加载数据
  • 原文地址:https://www.cnblogs.com/lufei33180/p/14223155.html
Copyright © 2011-2022 走看看