开启FEDERATED存储的方法如下:
1.查看是否安装了federated引擎
[plain] view plain copy print?在CODE上查看代码片派生到我的代码片
mysql> show engines;
+————+———+————————————————————+————–+——+————+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+————+———+————————————————————+————–+——+————+
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
+————+———+————————————————————+————–+——+————+
5 rows in set (0.00 sec)
从中可以看出federated引擎没有开启.
2.开启federated引擎
vi /etc/my.cnf
在[mysqld]之后添加:
federated
3.安装federated存储引擎
[plain] view plain copy print?在CODE上查看代码片派生到我的代码片
mysql> install plugin federated soname ‘ha_federated.so’;
Query OK, 0 rows affected, 1 warning (0.07 sec)
4.查看是否安装了federated引擎
[plain] view plain copy print?在CODE上查看代码片派生到我的代码片
mysql> show engines;
+————+———+————————————————————+————–+——+————+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+————+———+————————————————————+————–+——+————+
| FEDERATED | YES | Federated MySQL storage engine | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
+————+———+————————————————————+————–+——+————+
6 rows in set (0.00 sec)
5.创建表语句:
使用FEDERATED建表语句如下:
CREATE TABLE (……) ENGINE =FEDERATED CONNECTION=’mysql://[name]:[pass]@[location]:[port]/[db-name]/[table-name]’