更新:
本档结尾部分附了一个关于MySQL_5_6_replication_performance的评测文章,可以看看。
第二步, 创建用户
GRANT REPLICATION SLAVE ON *.* TO 'repl_user'@'127.0.0.1' IDENTIFIED BY 'billy';
直接在sandbox里面use,没有权限。。可以在mysql>中su成为其它用户么?
第三步, 从master导出数据
master中设置所有表只读:
mysql> FLUSH TABLES WITH READ LOCK;
Query OK, 0 ROWS affected (0.00 sec)
用mysqldump导出全部数据:
[modify@H209 msb_5_6_10_a]$ /home/modify/mysql/5.6.10/bin/mysqldump -uroot -p -h127.0.0.1 -P5610 –all-databases >all.sql
Enter password:
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don’t want to restore GTIDs, pass –set-gtid-purged=OFF. To make a complete dump, pass –all-databases –triggers –routines –events.
这个warning…..
先这样吧,我猜是需要在slave上面restore gtid的,至于triggers routines和events,也一起导出吧,不过event_scheduler并没有打开,总感觉这东西不太靠谱。
[modify@H209 msb_5_6_10_a]$ /home/modify/mysql/5.6.10/bin/mysqldump -uroot -p -h127.0.0.1 -P5610 --all-databases --triggers --routines --events >all.sql
mysql> UNLOCK TABLES;
Query OK, 0 ROWS affected (0.00 sec)
第四步, slave导入数据
[modify@H209 msb_5_6_10_a]$ /home/modify/mysql/5.6.10/bin/mysql -uroot -p -h127.0.0.1 -P5611 < all.sql
Enter password:
第五步, change master
mysql [localhost] {msandbox} (test) > CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=5610, MASTER_USER='repl_user',MASTER_PASSWORD='billy', master_auto_position=1; Query OK, 0 ROWS affected, 2 warnings (0.01 sec) mysql [localhost] {msandbox} (test) > mysql [localhost] {msandbox} (test) > mysql [localhost] {msandbox} (test) > SHOW warnings; +-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Level | Code | Message | +-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Note | 1759 | Sending passwords IN plain text WITHOUT SSL/TLS IS extremely insecure. | | Note | 1760 | Storing MySQL USER name OR password information IN the master.info repository IS NOT secure AND IS therefore NOT recommended. Please see the MySQL Manual FOR more about this issue AND possible alternatives. | +-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 2 ROWS IN SET (0.00 sec) 这里保存的是明文密码,存在密码泄露的风险。 mysql [localhost] {msandbox} (mysql) > SELECT * FROM mysql.slave_master_info \G *************************** 1. ROW *************************** Number_of_lines: 23 Master_log_name: Master_log_pos: 4 Host: 127.0.0.1 User_name: repl_user User_password: billy Port: 5610 Connect_retry: 60 Enabled_ssl: 0 Ssl_ca: Ssl_capath: Ssl_cert: Ssl_cipher: Ssl_key: Ssl_verify_server_cert: 0 Heartbeat: 1800 Bind: Ignored_server_ids: 0 Uuid: Retry_count: 86400 Ssl_crl: Ssl_crlpath: Enabled_auto_position: 1 1 ROW IN SET (0.00 sec) mysql [localhost] {msandbox} (mysql) > SELECT * FROM mysql.slave_relay_log_info \G *************************** 1. ROW *************************** Number_of_lines: 7 Relay_log_name: ./mysql_sandbox5611-relay-bin.000001 Relay_log_pos: 4 Master_log_name: Master_log_pos: 0 Sql_delay: 0 Number_of_workers: 0 Id: 1 1 ROW IN SET (0.00 sec) mysql [localhost] {msandbox} (mysql) > START slave; Query OK, 0 ROWS affected, 1 warning (0.01 sec) mysql [localhost] {msandbox} (mysql) > mysql [localhost] {msandbox} (mysql) > SHOW warnings; +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Level | Code | Message | +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Note | 1753 | slave_transaction_retries IS NOT supported IN multi-threaded slave mode. IN the event OF a transient failure, the slave will NOT retry the TRANSACTION AND will stop. | +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 ROW IN SET (0.00 sec) 不重试就不重试吧。 multi-threaded slave的副面作用还真多。 从服务器上看一下状态: mysql [localhost] {msandbox} (test) > SHOW slave STATUS \G *************************** 1. ROW *************************** Slave_IO_State: Waiting FOR master TO send event Master_Host: 127.0.0.1 Master_User: repl_user Master_Port: 5610 Connect_Retry: 60 Master_Log_File: black-bin.000001 Read_Master_Log_Pos: 1770 Relay_Log_File: mysql_sandbox5611-relay-bin.000002 Relay_Log_Pos: 1980 Relay_Master_Log_File: black-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: 1770 Relay_Log_Space: 2196 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: 05b47d41-7b10-11e2-9fff-00241db92e69 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 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: 05b47d41-7b10-11e2-9fff-00241db92e69:1-6 Executed_Gtid_Set: 05b47d41-7b10-11e2-9fff-00241db92e69:1-6 Auto_Position: 1 1 ROW IN SET (0.00 sec) 主服务器上面也可以看到一些信息: mysql [localhost] {msandbox} (test) > SHOW master STATUS; +------------------+----------+--------------+------------------+------------------------------------------+ | File | POSITION | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+------------------------------------------+ | black-bin.000001 | 1770 | | | 05b47d41-7b10-11e2-9fff-00241db92e69:1-6 | +------------------+----------+--------------+------------------+------------------------------------------+ 1 ROW IN SET (0.00 sec) mysql [localhost] {msandbox} (test) > mysql [localhost] {msandbox} (test) > SHOW slave hosts; +-----------+------+------+-----------+--------------------------------------+ | Server_id | Host | Port | Master_id | Slave_UUID | +-----------+------+------+-----------+--------------------------------------+ | 2 | blue | 5611 | 1 | 1d1e71e7-7b10-11e2-9fff-00241db92e69 | +-----------+------+------+-----------+--------------------------------------+ 1 ROW IN SET (0.00 sec)
从总体上看来,由于不需要手工确定主服务器的MASTER_LOG_FILE及MASTER_LOG_POS,与5.6之前的主从配置比起来,确实是简单一些了。
第一部分结束。
第二部分将会测试主服务器挂掉,提升从服务器的情况。
======================================================
