简单的主从配置

复制配置

环境规范
1.一组主从里面,端口要一致,要求每一组复制的端口都是唯一的;
2.要求是每个实例上的server-id由IP最后一位加上端口号组成防止server-id一样;
3.主从尽可能是版本一致;
4.复制建一个专用复制帐号授予replication slave权限。

基本环境介绍

MySQL版本:MySQL 5.6.27

角色

Ip:port

Server-id

必备条件

Master

192.168.247.11

113308

启用log-bin主库上创建复制用户

Slave

192.168.247.12

123308

 


核心配置

Log-bin

Server-id

#禁掉gtid

Gtid_mode=off


主库备份数据从库恢复数据

#mysqldump -P3308 -S/tmp/mysql3308.sock  --master-data=2--single-transaction -A >3308db_full.sqll

#scp 3308db_full.sql 192.168.247.21:/tmp/

--single-transaction --不锁表

--master-data=2 --隐式的在备份文件中包含change语句

# mysql -S /tmp/mytest_3308.sock  </tmp/3308db_full.sql

--master 创建用户用于复制

grant replication slave on *.* to'repl'@'192.168.247.%' identified by '123456';

从库配置MySQL复制

--3308db_full.sql 文件中找到-- CHANGE MASTER TOMASTER_LOG_FILE='mybinlog.000003', MASTER_LOG_POS=252075;

#CHANGE MASTER TOMASTER_LOG_FILE='mybinlog.000007', MASTER_LOG_POS=120;

CHANGE MASTER TO  master_host='192.168.247.11',

master_user='repl',

master_password='123456',

master_port=3308,MASTER_LOG_FILE='mybinlog.000007', MASTER_LOG_POS=120;

#start slave;

#show slave status\G;

*************************** 1. row***************************

               Slave_IO_State: Waiting formaster to send event

                  Master_Host: 192.168.247.11

                  Master_User: repl

                  Master_Port: 3308

                Connect_Retry: 60

              Master_Log_File: mybinlog.000007

         Read_Master_Log_Pos: 415

               Relay_Log_File:mysql-relay-bin.000002

                Relay_Log_Pos: 577

       Relay_Master_Log_File: mybinlog.000007

             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: 415

              Relay_Log_Space: 750

              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: 113308

                  Master_UUID:4fe18743-af17-11e5-8344-000c29b69f06

             Master_Info_File:/data/mysql/mytest_3308/master.info

                    SQL_Delay: 0

         SQL_Remaining_Delay: NULL

     Slave_SQL_Running_State: Slave has read all relay log; waiting for theslave 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)

看见Slave_IO_Running: YesSlave_SQL_Running: Yes说明复制配置成功



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值