• mysql5.6 主从复制


    Master 192.168.59.128
    Slave 192.168.59.129
     
     
    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.6/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 = mysql-bin
    log-bin-index = mysql-bin.index
    sync_binlog=1
    binlog_format=mixed
     
    binlog-ignore-db = mysql
    binlog-ignore-db = performance_schema
    binlog-ignore-db = information_schema
    binlog-ignore-db = test
     
    binlog_checksum=NONE
     
    # These are commonly set, remove the # and set as required.
    # basedir = .....
    # datadir = .....
    # port = .....
    server_id = 128
    # socket = .....
     
    # 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
     
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
     
    • 查看master状态
     
    [root@localhost ~]# mysql -uxiaojf -pxiaojf;
    mysql> show master status;
    +------------------+----------+--------------+--------------------------------------------------+-------------------+
    | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB                                 | Executed_Gtid_Set |
    +------------------+----------+--------------+--------------------------------------------------+-------------------+
    | mysql-bin.000001 |      120 |              | mysql,performance_schema,information_schema,test |                   |
    +------------------+----------+--------------+--------------------------------------------------+-------------------+
    1 row in set (0.00 sec)
    • 修改Slave的 my.cnf 文件
     
    [root@localhost ~]# cat /etc/my.cnf
    [client]
    password        = 123456
    port            = 3306
    default-character-set=utf8
    [mysqld]
    port            = 3306
    character_set_server=utf8
    character_set_client=utf8
    collation-server=utf8_general_ci
    lower_case_table_names=1
    max_connections=1000
     
    log-bin=mysql-bin
    server-id=129
     
    relay-log-index = slave-relay-bin.index
    relay-log = slave-relay-bin
    sync_master_info = 1
    sync_relay_log = 1
    sync_relay_log_info = 1
     
    [mysql]
    default-character-set = utf8
     
    • 执行slave命令
     
    [root@localhost ~]# mysql -uxiaojf -pxiaojf
    mysql> change master to master_host='192.168.59.128',master_user='xiaojf',master_password='xiaojf', master_log_file='mysql-bin.000001',master_log_pos=120;
    mysql> start slave;
    mysql> show slave statusG;
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.59.128
                      Master_User: xiaojf
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000001
              Read_Master_Log_Pos: 401
                   Relay_Log_File: slave-relay-bin.000002
                    Relay_Log_Pos: 564
            Relay_Master_Log_File: mysql-bin.000001
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
                  Replicate_Do_DB:
              Replicate_Ignore_DB:
               Replicate_Do_Table:
           Replicate_Ignore_Table:
          Replicate_Wild_Do_Table:
      Replicate_Wild_Ignore_Table:
                       Last_Errno: 0
                       Last_Error:
                     Skip_Counter: 0
              Exec_Master_Log_Pos: 401
                  Relay_Log_Space: 737
                  Until_Condition: None
                   Until_Log_File:
                    Until_Log_Pos: 0
               Master_SSL_Allowed: No
               Master_SSL_CA_File:
               Master_SSL_CA_Path:
                  Master_SSL_Cert:
                Master_SSL_Cipher:
                   Master_SSL_Key:
            Seconds_Behind_Master: 0
    Master_SSL_Verify_Server_Cert: No
                    Last_IO_Errno: 0
                    Last_IO_Error:
                   Last_SQL_Errno: 0
                   Last_SQL_Error:
      Replicate_Ignore_Server_Ids:
                 Master_Server_Id: 128
                      Master_UUID: f58d1b59-d4e5-11e6-bf21-000c2921ab55
                 Master_Info_File: /var/lib/mysql/master.info
                        SQL_Delay: 0
              SQL_Remaining_Delay: NULL
          Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
               Master_Retry_Count: 86400
                      Master_Bind:
          Last_IO_Error_Timestamp:
         Last_SQL_Error_Timestamp:
                   Master_SSL_Crl:
               Master_SSL_Crlpath:
               Retrieved_Gtid_Set:
                Executed_Gtid_Set:
                    Auto_Position: 0
    1 row in set (0.00 sec)
     
    ERROR:
    No query specified
    Master 192.168.59.128
    Slave 192.168.59.129
     
     
    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/5.6/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 = mysql-bin
    log-bin-index = mysql-bin.index
    sync_binlog=1
    binlog_format=mixed
     
    binlog-ignore-db = mysql
    binlog-ignore-db = performance_schema
    binlog-ignore-db = information_schema
    binlog-ignore-db = test
     
    binlog_checksum=NONE
     
    # These are commonly set, remove the # and set as required.
    # basedir = .....
    # datadir = .....
    # port = .....
    server_id = 128
    # socket = .....
     
    # 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
     
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
     
    • 查看master状态
     
    [root@localhost ~]# mysql -uxiaojf -pxiaojf;
    mysql> show master status;
    +------------------+----------+--------------+--------------------------------------------------+-------------------+
    | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB                                 | Executed_Gtid_Set |
    +------------------+----------+--------------+--------------------------------------------------+-------------------+
    | mysql-bin.000001 |      120 |              | mysql,performance_schema,information_schema,test |                   |
    +------------------+----------+--------------+--------------------------------------------------+-------------------+
    1 row in set (0.00 sec)
    • 修改Slave的 my.cnf 文件
     
    [root@localhost ~]# cat /etc/my.cnf
    [client]
    password        = 123456
    port            = 3306
    default-character-set=utf8
    [mysqld]
    port            = 3306
    character_set_server=utf8
    character_set_client=utf8
    collation-server=utf8_general_ci
    lower_case_table_names=1
    max_connections=1000
     
    log-bin=mysql-bin
    server-id=129
     
    relay-log-index = slave-relay-bin.index
    relay-log = slave-relay-bin
    sync_master_info = 1
    sync_relay_log = 1
    sync_relay_log_info = 1
     
    [mysql]
    default-character-set = utf8
     
    • 执行slave命令
     
    [root@localhost ~]# mysql -uxiaojf -pxiaojf
    mysql> change master to master_host='192.168.59.128',master_user='xiaojf',master_password='xiaojf', master_log_file='mysql-bin.000001',master_log_pos=120;
    mysql> start slave;
    mysql> show slave statusG;
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.59.128
                      Master_User: xiaojf
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: mysql-bin.000001
              Read_Master_Log_Pos: 401
                   Relay_Log_File: slave-relay-bin.000002
                    Relay_Log_Pos: 564
            Relay_Master_Log_File: mysql-bin.000001
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
                  Replicate_Do_DB:
              Replicate_Ignore_DB:
               Replicate_Do_Table:
           Replicate_Ignore_Table:
          Replicate_Wild_Do_Table:
      Replicate_Wild_Ignore_Table:
                       Last_Errno: 0
                       Last_Error:
                     Skip_Counter: 0
              Exec_Master_Log_Pos: 401
                  Relay_Log_Space: 737
                  Until_Condition: None
                   Until_Log_File:
                    Until_Log_Pos: 0
               Master_SSL_Allowed: No
               Master_SSL_CA_File:
               Master_SSL_CA_Path:
                  Master_SSL_Cert:
                Master_SSL_Cipher:
                   Master_SSL_Key:
            Seconds_Behind_Master: 0
    Master_SSL_Verify_Server_Cert: No
                    Last_IO_Errno: 0
                    Last_IO_Error:
                   Last_SQL_Errno: 0
                   Last_SQL_Error:
      Replicate_Ignore_Server_Ids:
                 Master_Server_Id: 128
                      Master_UUID: f58d1b59-d4e5-11e6-bf21-000c2921ab55
                 Master_Info_File: /var/lib/mysql/master.info
                        SQL_Delay: 0
              SQL_Remaining_Delay: NULL
          Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
               Master_Retry_Count: 86400
                      Master_Bind:
          Last_IO_Error_Timestamp:
         Last_SQL_Error_Timestamp:
                   Master_SSL_Crl:
               Master_SSL_Crlpath:
               Retrieved_Gtid_Set:
                Executed_Gtid_Set:
                    Auto_Position: 0
    1 row in set (0.00 sec)
     
    ERROR:
    No query specified
  • 相关阅读:
    《结对-航空购票系统-测试过程》
    《结对-航空购票系统-开发过程》
    课后作业-阅读任务-阅读提问-2
    《1005-构建之法:现代软件工程-阅读笔记》
    《团队-记事本程序-代码设计规范》
    Python作业:jieba库
    Python第四周作业:青蛙跳台阶、欧式距离、验证码校验、大小写互换、凯撒加密、身份证号处理
    Python汉诺塔问题
    第四周(1):利用Python计算π的值,并显示进度条
    Python第二周(1):凯撒密码B,括号配对测试,字符串反码,计算矩形面积,快乐的数字
  • 原文地址:https://www.cnblogs.com/xiaojf/p/6561311.html
Copyright © 2020-2023  润新知