<p>主上修改my.cnf文件:</p><p>server-id=1
</p><p>log-bin=mysql-bin</p><p>从上修改配置文件 my.cnf</p><pre class="brush:bash;toolbar:false">server-id=2
relay-log=replay-bin
read-only=1
replicate-ignore-db=mysql
replicate-ignore-db=test
replicate-ignore-db=information_schema
replicate-wild-do-table=mysys.channel#需要同步的一个表
replicate-wild-do-table=mysys.isp_channel#需要同步的一个表
创建同步的用户(主上)
GRANTREPLICATIONSLAVE,REPLICATIONCLIENTON*.*torep@'22.2.2.22'identifiedby'slave_password';</pre><p>同步到主库(在从上操作)</p><pre class="brush:sql;toolbar:false">SLAVESTOP;
resetslave;
CHANGEMASTERTOMASTER_HOST='111.11.1.11',
MASTER_USER='rep',
MASTER_PASSWORD='slave_password',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=0;
startslave;
showslavestatus\G</pre><p>在从上验证:</p><pre class="brush:sql;toolbar:false">mysql>showslavestatus\G;
***************************1.row***************************
Slave_IO_State:Waitingformastertosendevent
Master_Host:111.11.1.11
Master_User:rep
Master_Port:3306
Connect_Retry:60
Master_Log_File:mysql-bin.000001
Read_Master_Log_Pos:593
Relay_Log_File:replay-bin.000001
Relay_Log_Pos:730
Relay_Master_Log_File:mysql-bin.000001
Slave_IO_Running:Yes
Slave_SQL_Running:Yes
Replicate_Do_DB:
Replicate_Ignore_DB:mysql,test,information_schema
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:mysys.channel,mysys.isp_channel,mysys.department,mysys.department_business,mysys.sms_key
Replicate_Wild_Ignore_Table:
Last_Errno:0
Last_Error:
Skip_Counter:0
Exec_Master_Log_Pos:593
Relay_Log_Space:730
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
1rowinset(0.00sec)
ERROR:
Noqueryspecified</pre>