- 论坛徽章:
- 0
|
刚刚搭建了一个mysql5.1热备环境,A(主,192.168.0.7)->B(从,192.168.0.14)A机的/etc/my.cnf只启用了二进制日志,给B机赋予复制的权限,
mysql>grant replication slave on *.* to 'backup'@'192.168.0.14' identified by '123456';指定server-id=1,B机的配置如下:
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 2
master-host=192.168.0.7
master-user=backup
master-password=123456
master-port=3306
master-connect-retry=60
replicate-do-db=leotest
然后在B机上进去MYSQL,输入
mysql> change master to
-> master_host='192.168.0.7',
-> master_user='backup',
-> master_password='123456',
-> master_log_file='mysql-bin.000029',
-> master_log_pos=21901985;
start slave;
在A(主)机上查看主的状态为
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000029 | 31102266 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
mysql>show processlist;
+------+-------------+--------------------+------------+-------------+--------+-----------------------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+------+-------------+--------------------+------------+-------------+--------+-----------------------------------------------------------------------+------------------+
| 2 | system user | | NULL | Connect | 331863 | Has read all relay log; waiting for the slave I/O thread to update it | NULL |
| 5723 | backup | 192.168.0.14:33638 | NULL | Binlog Dump | 17307 | Has sent all binlog to slave; waiting for binlog to be updated | NULL |
B机的状态为
mysql> show slave status;
+----------------------------------+-------------+-------------+-------------+---------------+------------------+---------------------+----------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+
| Slave_IO_State | Master_Host | Master_User | Master_Port | Connect_Retry | Master_Log_File | Read_Master_Log_Pos | Relay_Log_File | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Running | Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignore_Table | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | Last_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Condition | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File | Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seconds_Behind_Master | Master_SSL_Verify_Server_Cert | Last_IO_Errno | Last_IO_Error | Last_SQL_Errno | Last_SQL_Error |
+----------------------------------+-------------+-------------+-------------+---------------+------------------+---------------------+----------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+
| Waiting for master to send event | 192.168.0.7 | backup | 3306 | 60 | mysql-bin.000029 | 31101457 | localhost-relay-bin.000003 | 104045 | mysql-bin.000029 | Yes | Yes | leotest | | | | | | 0 | | 0 | 31101457 | 7468872 | None | | 0 | No | | | | | | 0 | No | 0 | | 0 | |
+----------------------------------+-------------+-------------+-------------+---------------+------------------+---------------------+----------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+
1 row in set (0.00 sec)
mysql> show processlist;
+----+-------------+-----------+------+---------+-------+-----------------------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-------------+-----------+------+---------+-------+-----------------------------------------------------------------------+------------------+
| 2 | system user | | NULL | Connect | 17198 | Waiting for master to send event | NULL |
| 3 | system user | | NULL | Connect | 14 | Has read all relay log; waiting for the slave I/O thread to update it | NULL |
| 4 | root | localhost | leo | Query | 0 | NULL | show processlist |
+----+-------------+-----------+------+---------+-------+-----------------------------------------------------------------------+------------------+
3 rows in set (0.00 sec)
我观察的状态似乎一切正常,但为什么我的leotest这个数据库在MASTER上没有同步到我的SLAVE机上呢?实在想不出原因,盼高手赐教! |
|