I. 实现原理
通过创建存储引擎为Federated 的表来实现远程共享服务器表数据。

Federated:能够将多个分离(不在同一台服务器上的机器)的MySQL服务器链接起来,从多个物理服务器创建一个逻辑数据库。十分适合于分布式环境或数据集市环境。

II. 应用注意问题
1. 本地数据库服务必须支持“FEDERATED”存储引擎,远程服务器可以不支持

2. 本地服务器最好不是集成环境,例如 apmxe ,wamp 等,集成环境,启动“FEDERATED”存储引擎会出现其他问题,不能正常启动

3. “FEDERATED”存储引擎是从MySQL5.0开始支持的 。

4. 因为操作本地库中的远程表,就是操作远程库中对应的数据库表,所以在本地库中对应远程表的操作(新增,修改,删除),均为反应都对应的远程表中。

III. 关于延迟问题

1. 本地服务器与远程服务器在同一网段中(局域网),测试延迟时间感觉不到。

2. 延迟与网速和服务器性能有关。

 


I. 检查数据库服务器是否支持远程表
在MySQL命令行使用 “showengines  ;”检查是否支持远程表,实际上是查看当前数据库服务器(想远程共享其他服务器数据库数据的机器)是否支持“FEDERATED”存储引擎。参考语句及结构如下

Mysql基于FEDERATED存储引擎的远程表使用

 

II. 为服务器开启“FEDERATED”存储引擎
第一步:

修改MySQL数据库配置文件 ,参考过程如下:

Mysql基于FEDERATED存储引擎的远程表使用

第二步:

重启MySQL数据库服务

Mysql基于FEDERATED存储引擎的远程表使用

第三步:检查“FEDERATED”存储引擎是否开启

Mysql基于FEDERATED存储引擎的远程表使用

III. “showengines  ;”命令输出结果简单介绍

 Mysql基于FEDERATED存储引擎的远程表使用

A value of NO means that the server wascompiled without support for the engine, so it cannot be enabled at runtime.

A value of DISABLED occurs either because theserver was started with an option that disables the engine, or because not alloptions required to enable it were given. In the latter case, the error logfile should contain a reason indicating why the option is disabled. See Section 5.2.2, “The Error Log”.

You might also see DISABLED for a storageengine if the server was compiled to support it, but was started with a --skip-engine_nameoption. For the NDBCLUSTERstorage engine, DISABLED means the server was compiled withsupport for MySQL Cluster, but was not started with the --ndbclusteroption.

 

本文转载只限于自己备份

相关文章: