zoukankan      html  css  js  c++  java
  • mysql主从配置

     mysql 安装在这里就不说了,可以参考我的安装笔记

    http://www.cnblogs.com/vick51/p/7048417.html 

    下面直接开始配置mysql 主从

    mysql 主从环境介绍

    Mysql Master  系统:Centos6.*  mysql version mysql-5.7.17  IP:192.168.1.223
    Mysql Slave    系统:Centos6.*  mysql version mysql-5.7.17  IP:192.168.1.224

    开始配置 mysql 主从:

    1、在master上创建主从用户
    [root@m3 ~]# mysql -uroot -pyou_password
    mysql> grant replication slave on *.* to vick@'192.168.1.224' identified by 'vick_slave';
    mysql> flush privileges;
    mysql> show master statusG
    *************************** 1. row ***************************
    File: mysql-bin.000002
    Position: 997
    Binlog_Do_DB:
    Binlog_Ignore_DB:
    Executed_Gtid_Set: 89a442a1-511d-11e7-b608-000c29789b2f:1-4
    row in set (0.00 sec)

    2、在slave上配置从库
    vim /etc/my.cnf
    server_id = 2 ## 注意数据库的唯一ID不能一样
    [root@m4 ~]# mysql -uroot -pwangkai
    mysql> change master to
    -> master_host='192.168.1.223',
    -> master_user='vick',
    -> master_password='vick_slave',
    -> master_port=3306,
    -> master_log_file='mysql-bin.000002',
    -> master_log_pos=997;

    Query OK, 0 rows affected, 2 warnings (0.02 sec)
    mysql> start slave;
    Query OK, 0 rows affected (0.00 sec)
    mysql> show slave statusG
    *************************** 1. row ***************************
    Slave_IO_State: Waiting for master to send event
    Master_Host: 192.168.1.223
    Master_User: vick
    Master_Port: 3306
    Connect_Retry: 60
    Master_Log_File: mysql-bin.000002
    Read_Master_Log_Pos: 997
    Relay_Log_File: relay.000003
    Relay_Log_Pos: 320
    Relay_Master_Log_File: mysql-bin.000002
    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: information_schema.%,performance_schema.%
    Last_Errno: 0
    Last_Error:
    Skip_Counter: 0
    Exec_Master_Log_Pos: 997
    Relay_Log_Space: 683
    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: 2
    Master_UUID: 89a442a1-511d-11e7-b608-000c29789b2f
    Master_Info_File: mysql.slave_master_info
    SQL_Delay: 0
    SQL_Remaining_Delay: NULL
    Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
    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: 5ee0a7e0-51bf-11e7-93a9-000c2923b43c:1-2
    Auto_Position: 0
    Replicate_Rewrite_DB:
    Channel_Name:
    Master_TLS_Version:
    row in set (0.00 sec)

    当这两项为yes 说明显示正常
    Slave_IO_Running: Yes
    Slave_SQL_Running: Yes

  • 相关阅读:
    一些shell脚本实例
    python 创建虚拟环境python –m venv方式
    jmeter 压测的执行步骤步骤
    jmeter dubbo测试
    python 时间戳转日期 不自动补零 without zero-padding
    windows jetbrains toolbox 无法修改应用安装目录(应用正在运行)的解决方案
    【摘】人生苦短, 每日python
    【摘】人生苦短, 每日python
    【摘】人生苦短,每日python
    【摘】人生苦短,每日python
  • 原文地址:https://www.cnblogs.com/zoupufa/p/7048951.html
Copyright © 2011-2022 走看看