不停机xtrabackup创建slave节点(四)

2015-07-24 07:40:22 · 作者: · 浏览: 8
ogfile1 mysql xtrabackup_binary xtrabackup_checkpoints [mysql@master2 3307]$ ls data/test/ j1.frm j1.ibd j2.MYD j2.MYI j2.frm t1.frm t1.ibd

?

?
?
3、创建复制环境专用账户
master:
(system@localhost) [(none)]> grant replication slave on *.* to 'repl'@'10.1.1.%' identified by 'replsafe';
Query OK, 0 rows affected (0.09 sec)

(system@localhost) [(none)]> select user,host from mysql.user;
+--------+-----------+
| user   | host      |
+--------+-----------+
| dcw    | %         |
| repl   | 10.1.1.%  |
| test   | 10.1.1.%  |
| system | localhost |
| xtrabk | localhost |
+--------+-----------+

?

?
4、配置slave节点初始化参数文件
[mysql@master1 3306]$ scp my.cnf 10.1.1.18:/data/mysqldata/3307
[mysql@master2 ~]$ vim /data/mysqldata/3307/my.cnf
server-id=2
[mysql@master2 ~]$ sed -i 's/3306/3307/g' /data/mysqldata/3307/my.cnf
[mysql@master2 ~]$ mysqld_safe --defaults-file=/data/mysqldata/3307/my.cnf &
slave节点少创建了tmp和binlog两个文件夹
[mysql@master2 3307]$ mkdir tmp
[mysql@master2 3307]$ mkdir binlog
[mysql@master2 3307]$ ls
binlog  data  lost+found  my.cnf  mysql-error.log  tmp
启动数据库
[mysql@master2 3307]$ mysqld_safe --defaults-file=/data/mysqldata/3307/my.cnf &

?

?
?
?
5、配置slave节点复制环境
查看备份集信息:
[mysql@master2 3307]$ cat data/xtrabackup_binlog_info
mysql-bin.000011        812
[mysql@master2 3307]$ mysql -usystem -p'5ienet.com' -S /data/mysqldata/3307/mysql.sock
(system@localhost) [(none)]> change master to master_host='10.1.1.17',master_port=3306,master_user='repl',master_password='replsafe',master_log_file='mysql-bin.000011',master_log_pos=812;
Query OK, 0 rows affected, 2 warnings (0.09 sec)
(system@localhost) [(none)]> start slave;
Query OK, 0 rows affected (0.14 sec)

?

?
6、检查
(system@localhost) [(none)]> start slave;
Query OK, 0 rows affected (0.14 sec)

(system@localhost) [(none)]> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.1.1.17
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000011
          Read_Master_Log_Pos: 1024
               Relay_Log_File: mysql-relay-bin.000002
                Relay_Log_Pos: 495
        Relay_Master_Log_File: mysql-bin.000011
             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: 1024
              Relay_Log_Space: 668
              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: 1
                  Master_UUID: bd8ce1ca-edb7-11e4-964f-000c291b94c4
             Master_Info_File: /data/mysqldata/3307/data/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