gpt4 book ai didi

MySQL 复制不工作主从

转载 作者:行者123 更新时间:2023-11-29 01:03:29 25 4
gpt4 key购买 nike

我是 MySQL 新手,尝试创建复制这是Master上的my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql

log-bin = /var/lib/mysql/logs/mysql-bin.log
binlog-do-db=fedorareptest1
server-id=1
----

从机上的 My.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql

server-id=2
master-host=130.14.165.25
master-connect-retry=60
master-user=reptest
master-password=nopass!123
replicate-do-db=fedorareptest1
relay-log = /var/lib/mysql/logs/slave-relay.log
relay-log-index = /var/lib/mysql/logs/slave-relay-log.index

--------

注意:“replicate-do-db=fedorareptest1”中提到的数据库是master上的数据库。从站上的这个数据库名称是 fedoratest2。我应该在上面使用它还是应该在 master 上使用它

当我做从状态时:

mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 130.14.165.25
Master_User: reptest
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 107
Relay_Log_File: slave-relay.000005
Relay_Log_Pos: 252
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: fedorareptest1
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: 107
Relay_Log_Space: 549
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:
1 row in set (0.00 sec)
--------------------------------------

当我对表进行更新时,该行不会显示在从站上!

请帮助,我是 MYSQL 的新手。

最佳答案

你应该避免使用 *do-db 选项,因为它们可以 cause problems

检查查询是否通过了您的奴隶:

mysqlbinlog --short-form /path/to/relaylogfile | less

.. 或..

tcpdump -vv -A -i lo0 tcp port 3306 | tee dump.log

更新 重读您的帖子后我注意到了这个问题:您更改了数据库名称但未使用 replicate-rewrite-db

关于MySQL 复制不工作主从,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20710875/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com