MySQL存储引擎之Federated

Federated可以不使用复制技术,直接远程服务器主机的数据表。

实现原理

通过创建存储引擎为Federated 的表来实现远程共享服务器表数据。
Federated:能够将多个分离(不在同一台服务器上的机器)的MySQL服务器链接起来,从多个物理服务器创建一个逻辑数据库。十分适合于分布式环境或数据集市环境。

特点

  • 提供了访问远程MySQL服务器上表的方法(连接)
  • 本地不存储数据,数据全部放到远程服务器上
  • 本地需要保存表结构(frm文件)和远程服务器的连接信息

如何使用

默认禁止,启用需要在启动时增加federated参数
mysql://user_name[:password]@host_name[:port_num]/db_name/tbl_name

实例:在本地模拟远程本地
查看是否支持federated

MySQL [test]> show  engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)

具体使用查看这篇博客http://blog.csdn.net/jenminzhang/article/details/50837603<./a>

使用场景:

偶尔的统计分析及手动查询

你可能感兴趣的:(MySQL存储引擎之Federated)