如何删除mariaDB指定的Connection_name以进行多源复制

时间:2016-10-19 06:48:21

标签: mysql replication mariadb

我在mariaDB上有几个复制设置(最新版本:10.1.8)。请确保我使用Multiple replication而不是遗留Single replication

我已使用CHANGE MASTER "blah" TO命令添加了一些设置。现在我想从show all slaves status中删除其中一个。

mysql -e "show all slaves status\G;" | grep "Connection_name\|Running"
              Connection_name: 
             Slave_IO_Running: No
            Slave_SQL_Running: Yes
              Connection_name: asi.exapmle.com
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes
              Connection_name: bee.exapmle.com
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes
              Connection_name: dild.exapmle.com
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Connection_name: datr.exapmle.com
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes
              Connection_name: db.exapmle.com
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes
              Connection_name: nop.exapmle.com
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes

如何在不影响其他复制的情况下从此复制列表中仅删除db.exapmle.com

2 个答案:

答案 0 :(得分:6)

最后我找到了解决方案!

RESET SLAVE 'Connection_name' all是我想要的。 不只是RESET SLAVE您需要在最后添加ALL

  

https://mariadb.com/kb/en/mariadb/reset-slave-connection_name/

[root@maria ~]# mysql -e "show all slaves status\G;" | grep "Connection_name\|Running"
              Connection_name:              # <- empty name and wanna remove
             Slave_IO_Running: No
            Slave_SQL_Running: Yes
              Connection_name: wanna-remove-db       # <- wanna remove
             Slave_IO_Running: No
            Slave_SQL_Running: Yes
              Connection_name: wanna-keep-db         # <- don't wanna remove '
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes
[root@maria ~]# mysql -e "STOP SLAVE 'wanna-remove-db';"
[root@maria ~]# mysql -e "RESET SLAVE 'wanna-remove-db' all;" 
[root@maria ~]# mysql -e "show all slaves status\G;" | grep "Connection_name\|Running"
              Connection_name: 
             Slave_IO_Running: No
            Slave_SQL_Running: Yes
              Connection_name: wanna-keep-db
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes
[root@maria ~]# mysql -e "STOP SLAVE ''"
[root@maria ~]# mysql -e "RESET SLAVE '' all;" 
[root@maria ~]# mysql -e "show all slaves status\G;" | grep "Connection_name\|Running"
              Connection_name: wanna-keep-db
             Slave_IO_Running: Connecting
            Slave_SQL_Running: Yes

答案 1 :(得分:0)

登录您的奴隶(db.exapmle.com)并执行STOP SLAVE命令。

如果您无法访问奴隶,则需要将其列入黑名单,例如通过撤销从属用户的GRANTS。后者仍然允许从属设备连接但不进行身份验证(因此您应该考虑通过使用例如iptables来禁止连接)。