5.mysql slave 配置
5.1 在master 赋予slave 权限(任一节点操作)
[root@ha1 ~]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.31-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> GRANT RELOAD, REPLICATION SLAVE ON *.* TO 'slave162'@'10.0.0.162'
IDENTIFIED BY 'nslave162';
mysql> show master status\G;
*************************** 1. row ***************************
File: master.000001
Position: 106
Binlog_Do_DB:
Binlog_Ignore_DB:
1 row in set (0.00 sec)
5.2 slave 同步
因为没有数据,所以省略数据同步的步骤,在slalve 执行下列命令:
mysql> CHANGE MASTER TO MASTER_HOST='10.0.0.180',
MASTER_PORT = 3306,
MASTER_USER='slave162',
MASTER_PASSWORD='nslave162',
MASTER_LOG_FILE='master.000001',
MASTER_LOG_POS = 000000106;
Query OK, 0 rows affected (0.01 sec)
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State:Waiting for master to send event
Master_Host: 10.0.0.180
Master_User: slave162
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: master.000001
Read_Master_Log_Pos: 106
Relay_Log_File: mysql2-relay-bin.000002
Relay_Log_Pos: 248
Relay_Master_Log_File: master.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
1 row in set (0.00 sec)