zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    spring mvc给参数起别名
    聊聊分布式定时任务中间件架构及其实现--转
    Batch Normalization的算法本质是在网络每一层的输入前增加一层BN层(也即归一化层),对数据进行归一化处理,然后再进入网络下一层,但是BN并不是简单的对数据进行求归一化,而是引入了两个参数λ和β去进行数据重构
    终端安全工具 gartner 排名
    When Cyber Security Meets Machine Learning 机器学习 安全分析 对于安全领域的总结很有用 看未来演进方向
    DNS隧道之DNS2TCP实现——dns2tcpc必须带server IP才可以,此外ssh可以穿过墙的,设置代理上网
    DNS隧道之DNS2TCP使用心得教程——是可以用来穿透qiang的,ubuntu下直接apt install dns2tcp
    DNS隧道工具汇总——补充,还有IP over DNS的工具NSTX、Iodine、DNSCat
    Data Mining and Machine Learning in Cybersecurity PDF
    ES failed to notify ClusterStateListener java.lang.IllegalStateException: environment is not locked
  • 原文地址:https://www.cnblogs.com/xiaojf/p/6561311.html
Copyright © 2011-2022 走看看