首页新闻找找看学习计划

mysql federated引擎

0
悬赏园豆:160 [已关闭问题] 关闭于 2017-02-03 17:38

mysql中federated引擎,它可以查询远程表(即实现同步),但是我发现这种同步是双向的,在本地表中添加数据,远程表可以看见,可是在远程表中添加数据本地表也可以看见,那么可不可以只实现在本地表添加数据,同步到远程表中?哪位大神帮忙一下?万分感谢!!!

吃辣椒的小毛驴的主页 吃辣椒的小毛驴 | 初学一级 | 园豆:49
提问于:2017-01-08 19:53
< >
分享
所有回答(2)
0

在你不需要同步的库上执行:

mysql> stop slave;

 

CaiYongji | 园豆:1267 (小虾三级) | 2017-01-09 11:25

这好像是主从同步吧,好像整个服务都停止了

支持(0) 反对(0) 吃辣椒的小毛驴 | 园豆:49 (初学一级) | 2017-01-09 11:28
1

The FEDERATED storage engine lets you access data from a remote MySQL database without using replication or cluster technology. Querying a local FEDERATED table automatically pulls the data from the remote (federated) tables. No data is stored on the local tables.

http://dev.mysql.com/doc/refman/5.7/en/federated-storage-engine.html

A FEDERATED table consists of two elements:

  • A remote server with a database table, which in turn consists of the table definition (stored in the .frm file) and the associated table. The table type of the remote table may be any type supported by the remote mysqld server, including MyISAM or InnoDB.

  • A local server with a database table, where the table definition matches that of the corresponding table on the remote server. The table definition is stored within the .frm file. However, there is no data file on the local server. Instead, the table definition includes a connection string that points to the remote table.

When executing queries and statements on a FEDERATED table on the local server, the operations that would normally insert, update or delete information from a local data file are instead sent to the remote server for execution, where they update the data file on the remote server or return matching rows from the remote server.

http://dev.mysql.com/doc/refman/5.7/en/federated-description.html

 这个引擎的设计就是不将数据存在本地表。你所做的修改都会自动的发送到服务器上——即你在本地修改的任何数据都会自动同步,而你一旦查询这个本地的表,它就会自动从远程服务器拉取数据。

你的想法是美好的,现实是残酷的。

c99 | 园豆:1838 (小虾三级) | 2017-01-09 16:22

那怎么把本地多个服务器的数据同步到同一个远程服务器呢?我用的mysql服务器,windows系统

支持(0) 反对(0) 吃辣椒的小毛驴 | 园豆:49 (初学一级) | 2017-01-09 16:26

@北风吹: 无论你有多少个本地服务器,你其实都是修改的同一个远程服务器的数据。这个引擎其实是将远程服务器的数据给你偷偷拉过来,然后将你的修改偷偷发送到远程服务器上,给你一个在修改本地数据的错觉。你要记住——本地的表是不存储任何数据的。

支持(0) 反对(0) c99 | 园豆:1838 (小虾三级) | 2017-01-09 16:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册