zoukankan      html  css  js  c++  java
  • MySql 主从同步 (库名不同)

    主库:192.168.1.250

    从库:192.168.1.199

    主库  my.ini

    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
    # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
    # *** default location during install, and will be replaced if you
    # *** upgrade to a newer version of MySQL.
    
    [mysqld]
    
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    # log_bin
    
    # These are commonly set, remove the # and set as required.
    # basedir = .....
    # datadir = .....
    # port = .....
    # server_id = .....
    
    
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M 
    
    # 以下内容手动添加
    [client]
    default-character-set=utf8
    [mysqld]
    port=3306
    server-id=1
    log-bin=mysql-bin
    binlog-do-db=kintech_pd
    sync_binlog=1
    
    basedir=C:ProgramDataMySQLMySQL Server 5.7
    #解压目录下data目录
    datadir=C:ProgramDataMySQLMySQL Server 5.7data
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    [WinMySQLAdmin]
    C:Program FilesMySQLMySQL Server 5.7inmysqld.exe

    从库 my.ini

    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
    # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
    # *** default location during install, and will be replaced if you
    # *** upgrade to a newer version of MySQL.
    
    [mysqld]
    
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    # log_bin
    
    # These are commonly set, remove the # and set as required.
    # basedir = .....
    # datadir = .....
    # port = .....
    # server_id = .....
    
    
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M 
    
    # 以下内容手动添加
    [client]
    default-character-set=utf8
    [mysqld]
    #从库配置
    server_id=2
    #如果库名相同,使用这个
    #replicate-do-db=kintech_pd
    #如果库名不同,使用这个。
    replicate-rewrite-db = kintech_pd -> kps_common
    
    #端口
    port=3306
    character_set_server=utf8
    #解压目录
    basedir=C:ProgramDataMySQLMySQL Server 5.7
    #解压目录下data目录
    datadir=C:ProgramDataMySQLMySQL Server 5.7data
    
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    [WinMySQLAdmin]
    C:Program FilesMySQLMySQL Server 5.7inmysqld.exe

    主库:记住 File 和 Position

    
    CREATE USER 'slave'@'MySql2服务器ip' IDENTIFIED BY '密码';
    GRANT REPLICATION SLAVE ON *.* TO 'slave'@'MySql2服务器ip';
     
    flush privileges;
    
    show master status;

    从库:

    
    CHANGE MASTER TO 
    master_host = 'MySql1服务器ip',   
    master_user = 'slave',  
    master_password = '密码',  
    master_log_file = 'bin_log.000002',  
    master_log_pos = 631;
    
    start slave;
    
    show slave statusG
    
    

    最后显示:

    代表成功。

  • 相关阅读:
    设备树实践
    设备树实例解析
    设备树语法
    设备树基本概念
    设备树中#address-cells和#size-cells作用
    Linux设备驱动详解 宋宝华 硬件基础
    jffs2镜像制作
    ltp-ddt eth_iperf_tcp iperf dualtest遇到的问题
    shell 函数传递参数的几种方式
    windows logstash配置
  • 原文地址:https://www.cnblogs.com/hanjun0612/p/9779704.html
Copyright © 2011-2022 走看看