Linux下配置MySQL主从复制(二)

2015-07-16 12:09:14 · 作者: · 浏览: 5
------------------------------+
?6 rows in set (0.00 sec)


查看master的情况
mysql> show master status;
+-----------------------+----------+--------------+------------------+-------------------+
| File? ? ? ? ? ? ? ? ? | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-----------------------+----------+--------------+------------------+-------------------+
| mysql_oel1_bin.000004 |? ? ? 520 |? ? ? ? ? ? ? |? ? ? ? ? ? ? ? ? |? ? ? ? ? ? ? ? ? |
+-----------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)


然后到slave端,重新启动一下,配置一下server-id我们设置为2,指定端口为1551
?$MYSQL_BASE/bin/mysqld_safe --user=mysql --basedir=$MYSQL_BASE --datadir=$MYSQL_DATA --port=1551 --log-bin=mysql_oel1_slv1_bin? --log-error=/u02/mysqlslv1/log/log_error.log? --long_query_time=5 --slow-query-log=true --slow-query-log-file=/u02/mysqlslv1/log/slow_qeury.log --socket=/u02/mysqlslv1/mysql_slv1.sock? --server-id=2? &


启动完成之后,运行下面的语句来在slave端配置就可以了,这个过程就如同一个db link的感觉。
mysql> change master to master_host='192.168.27.130', master_user='slaveuser', master_password='slaveuser',master_port=1550;
?Query OK, 0 rows affected, 2 warnings (0.04 sec)


?mysql> start slave;
?Query OK, 0 rows affected (0.01 sec)
启动之后。直接查看show slave status \G就能看到slave端的一个基本情况了。很可能由于操作原因,出现一些复制的问题,我们可以指定skip的范围,下面这样操作。


mysql> stop slave;
?Query OK, 0 rows affected (0.01 sec)


?mysql> SET GLOBAL sql_slave_skip_counter =100;
?Query OK, 0 rows affected (0.02 sec)



?mysql> start slave;
?Query OK, 0 rows affected (0.01 sec)



?mysql> show slave status \G
?*************************** 1. row ***************************
? ? ? ? ? ? ? ? Slave_IO_State: Waiting for master to send event
? ? ? ? ? ? ? ? ? Master_Host: 192.168.27.130
? ? ? ? ? ? ? ? ? Master_User: slaveuser
? ? ? ? ? ? ? ? ? Master_Port: 1550
? ? ? ? ? ? ? ? Connect_Retry: 60
? ? ? ? ? ? ? Master_Log_File: mysql_oel1_bin.000005
? ? ? ? ? Read_Master_Log_Pos: 436
? ? ? ? ? ? ? ? Relay_Log_File: oel1-relay-bin.000010
? ? ? ? ? ? ? ? Relay_Log_Pos: 288
? ? ? ? Relay_Master_Log_File: mysql_oel1_bin.000005
? ? ? ? ? ? ? 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: 98
? ? ? ? ? Exec_Master_Log_Pos: 436
? ? ? ? ? ? ? Relay_Log_Space: 628
? ? ? ? ? ? ? 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: 02c8b5e4-e295-11e4-8db2-000c296415de
? ? ? ? ? ? ? Master_Info_File: /u02/mysqlslv1/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_SSL_Crl:
? ? ? ? ? ? Master_SSL_Crlpath:
? ? ? ? ? ? Retrieved_Gtid_Set