Replicate_Do_DB 参数发现跨库操作时从库数据不更新

问题:使用复制是设置  Replicate_Do_DB 参数发现跨库操作时从库数据不更新

1 设置从库的 replicate_do_db = test

2 主库的sql语句是跨库的insert    在test7 上插入数据到test.a 的表上。

use test7;

3 主库数据更新后查看从库信息发现数据并没有插入

4 原因是mysql 在执行sql前检查的当前默认库,所以跨库的sql语句不会被执行。

解决方案:

1 使用参数   replicate-wild-ignore-table =test.%

主库插入数据

从库查看数据


----------2 使用复制的组合过滤规则:replicate-do-dbreplicate-do-table两个参数的过滤规则-------------暂时测试失败

参数说明

Replicate_Do_DB :

The effects of this option depend on whether statement-based or row-based replication is in use.

Statement-based replication.  Tell the slave SQL thread to restrict replication to statements where the default database (that is, the one selected by USE) is db_name. To specify more than one database, use this option multiple times, once for each database; however, doing so does not replicate cross-database statements such asUPDATE some_db.some_table SET foo=‘bar‘ while a different database (or no database) is selected.

Warning

To specify multiple databases you must use multiple instances of this option. Because database names can contain commas, if you supply a comma separated list then the list will be treated as the name of a single database

  • replicate-do-db =db_name  告诉从库sql线程限制复制sql语句,只复制默认的数库,多个数据库可以使用","

    跨库sql不被执行的原因:“检查默认的数据库”行为是从sql语句中很难得知是否复制。 sql进程检查的只是默认的数据库,而不是所有的数据

意义与replicate-do-db =db_name 相反是告诉从库数据库sql进程忽略指定的数据库,不进行任何复制。

USE prices;
UPDATE sales.january SET amount=amount+1000;

The UPDATE statement is replicated in such a case because --replicate-ignore-db applies only to the default database (determined by the USE statement). Because the sales database was specified explicitly in the statement, the statement has not been filtered. However, when using row-based replication, the UPDATEstatement‘s effects are not propagated to the slave, and the slave‘s copy of the sales.january table is unchanged; in this instance, --replicate-ignore-db=sales causes all changes made to tables in the master‘s copy of the sales database to be ignored by the slave.

同样是因为“检查默认的数据库”导致被忽略的数据库数据更新

  • replicate-do-table =db_name.tbl_name

    告诉从库sql进程仅复制指定的表,指定多个表多次使用这个选项。 这个选项适用于跨库的更新和默认的数据库更新,

  • This option affects only statements that apply to tables. It does not affect statements that apply only to other database objects, such as stored routines. To filter statements operating on stored routines, use one or more of the

从库的sql进程复制任何更新表的操作到指定的数据库名和表名,模式可以包含‘%’和“——”通配符,like模式匹配符的操作。适用于跨库操作

这个选项适用于表、视图和触发器。 它并不适用于存储过程和函数,或事件。过滤语句后面的对象上的操作,

This option applies to tables, views, and triggers. It does not apply to stored procedures and functions, or events. To filter statements operating on the latter objects, use one or more of the

从库的sql进程不复制任何更新表的操作到指定的数据库名和表名,模式可以包含‘%’和“——”通配符,like模式匹配符的操作。

参考:http://dev.mysql.com/doc/refman/5.1/en/replication-options-slave.html

参数的使用可以参考: http://dev.mysql.com/doc/refman/5.1/en/replication-rules.html

时间: 2024-07-31 15:13:07

Replicate_Do_DB 参数发现跨库操作时从库数据不更新的相关文章

MyBatis进行insert操作时不能将数据插入到数据库

MyBatis进行数据库增删改查时,明明表里有数据却查不出结果,同样主键的数据可以多次插表成功但是其实并未真正插入到表里,经过几次尝试,发现问题在于MyBatis_config.xml文件的transactionManager属性配置不正确,将type从JDBC改到MANAGED则可正常操作.公司的电脑则需要将MANAGED改为JDBC才可以正常操作. 查看了下transactionManager属性的说明,MANAGED是不会自动提交和回滚的,原因还在进一步查明中,先记下来. <?xml ve

【DRP】【SQL】-悲观锁-防止多用户同时操作时出现脏数据

1 /** 2 * 根据表名生成该表的序列 3 * @param tableName 4 * @return 返回生成的序列 5 */ 6 //全局方法 -加锁 7 //public static synchronized int generate(String tableName) { 8 //局部成员方法-加锁 9 //public synchronized int generate(String tableName) { 10 //synchronized(this) { 11 publi

ios ASIHttpRequest库进行DELETE操作时delete带有参数表单的使用方法

1,普通的DELETE只需加上下述一句code: [request setRequestMethod:@"DELETE"]; 2,附带有参数表单的情况(一次删除请求): ASIFormDataRequest *request; NSURL *baseURL = [NSURL URLWithString:@"http://www.baidu.com/xx/"]; request = [ASIFormDataRequest requestWithURL:baseURL]

一次由MySQL跨库操作所引发的主从复制中断

今天,所有MySQL从服务器上的主从复制都被异常中断了,登陆到其中一台上执行show slave status\G,发现如下错误:--Last_Error: Error 'Operation DROP USER failed for 'guest'@'localhost'' on query. Default database: 'work'. Query: 'drop user 'guest'@'localhost''--也就是说,是 drop user 'guest'@'localhost'

无法将类型为“Excel.ApplicationClass”的 COM 对象强制转换为接口类 型“Excel._Application”。此操作失败的原因是对 IID 为“{000208D5 -0000-0000-C000-000000000046}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: 加载类型库/DLL 时出错。 (异常来 自 HRESULT:

无法将类型为“Excel.ApplicationClass”的 COM 对象强制转换为接口类 型“Excel._Application”.此操作失败的原因是对 IID 为“{000208D5 -0000-0000-C000-000000000046}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: 加载类型库/DLL 时出错. (异常来 自 HRESULT:0x80029C4A (TYPE_E_CANTLOADLIBRARY)) 经过多般折腾,还是没什么更好的办法.

扩展BindingList,防止增加、删除项时自动更新界面而不出现“跨线程操作界面控件 corss thread operation”异常

在做界面程序时,常常需要一些数据类,界面元素通过绑定等方式显示出数据,然而由于UI线程不是线程安全的,一般都需要通过Invoke等方式来调用界面控件.但对于数据绑定bindingList而言,没法响应listchang事件,导致后端的grid等控件不能更新数据.废了好大的劲终于找到一个UIBindingList,实现线程数据的同步! using System; using System.ComponentModel; using System.Threading; using System.Wi

简单几部搞定laravel/lumen跨库操作

1.跨库数据库配置  在网站跟目录下的config文件中增加database.php作为数据库配置文件.配置如下: //当前默认数据库 'mysql' => [     'driver' => 'mysql',     'host' => env('DB_HOST', 'localhost'),     'port' => env('DB_PORT', 3306),     'database' => env('DB_DATABASE', 'forge'),     'use

Oracle跨库操作实现

跨库操作是指从当前数据库中查询其他数据库的数据. 创建语句如下: create [public] database link linkName connect to username identified by “*” using ‘romoteHost’; 语句解释: public: 为可选项,如果为public,则当前实例下所有schema都可用,如果没有public,则是由当前创建的schema可用. linkName: 自定义链接的名称. username: 目标用户的用户名. *: 特

Dataframe操作时出现 KeyError: &#39;列名xxx&#39;

python确实很用来很爽很苏服,代码不多 各种库出于易用目的,做了很多默认设置,但要是不认真看API,那就会掉到坑里了. df1.groupby(['Dn','UserLabel','BeginTime']).first() df1['city']=df1['UserLabel'].str.slice(0,2) 出现 df1['UserLabel'] File "D:\script\Python279\lib\site-packages\pandas\core\frame.py",