- 论坛徽章:
- 0
|
本帖最后由 cenalulu 于 2012-07-08 21:59 编辑
本人在虚拟机下虚拟两台 centos5.4 都装了同一版本的mysql(Server version: 5.0.95-log Source distribution)
在[mysqld]中加入以下内容
server-id=1 #设置服务器的ID号
log-bin #设置同步
logbinlog-do-db=test #设置同步数据库
max_binlog_size=104857600
replicate-same-server-id
master-host=192.168.254.2 #主机IP
master-user=backup
master-password=qawsed
master-port=3306
master-connect-retry=60 #断点重试间隔为60秒
replicate-do-db=test #表示同步test数据库
binlog-ignore-db=mysql #不同步的数据库
两台虚拟机都差不多添加上面的内容 只是ip什么的变了一下
都弄好了以后 在一台虚拟机(A)上
mysql > show master status;
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| mysqld-bin.000002 | 98 | test | mysql |
+-------------------+----------+--------------+------------------+
在另一台虚拟机(B)上
mysql > start slave;
mysql > show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Connecting to master
Master_Host: 192.168.96.133
Master_User: backup
Master_Port: 3306
Connect_Retry: 60
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: mysqld-relay-bin.000002
Relay_Log_Pos: 98
Relay_Master_Log_File:
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB: test
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: 0
Relay_Log_Space: 98
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: NULL
mysql日志error为
120706 1:06:16 [ERROR] Slave I/O thread: error connecting to master 'backup@192.168.96.133:3306': Error: 'Lost connection to MySQL server at 'reading initial communication packet', system error: 113' errno: 2013 retry-time: 60 retries: 86400
求解!!!!
感谢大家。 |
|