mysql federated 缺点_MySQL存储引擎--------Federated最佳实战
1. 背景
* 本地MySQL数据库要访问远程MySQL数据库的表中的数据, 必须通过FEDERATED存储引擎来实现.
* 有点类似Oracle中的数据库链接(DBLINK). 要允许这个存储引擎, 当构建MySQL时使用--with-federated-storage-engine来configure.
* 当创建一个FEDERATED表的时候, 服务器在数据库目录创建一个表定义文件. 文件由表的名字开始, 并有一个.frm扩展名.
* 无其它文件被创建, 因为实际的数据在一个远程数据库上.
2. 相关特性
* 允许本地访问远程 MySQL 数据库中表的数据
* 本地不存储任何数据文件
* 仅支持 MySQL 对 MySQL 的访问
* 不支持异构数据库的访问
* MySQL默认不开启Federated存储引擎
3. 环境
两个MySQL 5.7实例
serverA 3306
serverB 3307[root@MySQL ~]# mysql -S /tmp/mysql.sock1 -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.18 |
+-----------+
1 row in set (0.00 sec)
[root@MySQL ~]# mysql -S /tmp/mysql.sock2 -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.18 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.18 |
+-----------+
1 row in set (0.00 sec)
4. Federated存储引擎设置
* 查看Federated是否开启 [ FEDERATED 中Support状态NO表明引擎未开启 ]mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| CSV | YES | CSV storage engine | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.01 sec)
* 配置文件指定开启Federated存储引擎 [ /etc/my.cnf ][mysqld]
federated
* 重启MySQL 再次查看 [ FEDERATED 中Support状态成YES表明引擎开启成功 ]mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| CSV | YES | CSV storage engine | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| FEDERATED | YES | Federated MySQL storage engine | NO | NO | NO |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)
5. 部署
* 在ServerA上有一个数据库dbtestA,在ServerB上有数据库dbtestB,要在ServerB的数据库dbtestB上建立ServerA的数据库dbtestA上的表tabletestA的数据表链接remote_tabletestA,通过普通用户test连接。
* ServerA创建数据库mysql> create database dbtestA;
Query OK, 1 row affected (0.02 sec)
* ServerA在dbtestA数据库中创建tabletestA表mysql> create table tabletestA(
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT
)ENGINE=INNODB;
Query OK, 0 rows affected (0.11 sec)
* ServerA中创建普通用户并授权dbtestA数据库相关权限mysql> create user 'test'@'127.0.0.1' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> grant select on dbtestA.* to 'test'@'127.0.0.1';
Query OK, 0 rows affected (0.00 sec)
* ServerB 中创建数据库 dbtestBmysql> create database dbtestB;
Query OK, 1 row affected (0.00 sec)
* ServerB 在dbtestB中创建链接表remote_tabletestA, 使用普通用户testmysql> use dbtestB;
Database changed
mysql> create table remote_tabletestA(
-> id INT PRIMARY KEY NOT NULL AUTO_INCREMENT
-> )ENGINE=FEDERATED
-> CONNECTION='mysql://test:123456@127.0.0.1:3306/dbtestA/tabletestA';
Query OK, 0 rows affected (0.09 sec)
* 在ServerA dbtestA库tableA表中插入数据Database changed
mysql> use dbtestA;
Database changed
mysql> insert into tabletestA select NULL;
Query OK, 1 row affected (0.01 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> insert into tabletestA select NULL;
Query OK, 1 row affected (0.03 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> insert into tabletestA select NULL;
Query OK, 1 row affected (0.01 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> select * from tabletestA;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
+----+
3 rows in set (0.01 sec)
* ServerB dbtestB库链接表remote_tabletestA查看mysql> use dbtestB;
Database changed
mysql> select * from remote_tabletestA;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
+----+
3 rows in set (0.01 sec)
* ServerB服务器中查看链接表remote_tablestestA相关文件
.frm 表定义文件 [ Federated链接库本地不产生数据文件 ][root@MySQL ~]# ll /data/mysql_data2/dbtestB/
total 16
-rw-r----- 1 mysql mysql 65 Jun 25 10:40 db.opt
-rw-r----- 1 mysql mysql 8556 Jun 25 10:42 remote_tabletestA.frm
6. 总结
以需求驱动技术,技术本身没有优略之分,只有业务之分。
mysql federated 缺点_MySQL存储引擎--------Federated最佳实战相关推荐
- mysql 参照完整性规则_MySQL存储引擎你们知道多少?
MySQL存储引擎技术详解点击观看! MySQL是我们经常使用的数据库处理系统(DBMS),不知小伙伴们有没有注意过其中的"存储引擎"(storage_engine)呢?有时候面试 ...
- mysql数据库应用模式与特点_MySQL存储引擎的实际应用以及对MySQL数据库中各主要存储引擎的独特特点的描述...
MySQL存储引擎的实际应用以及对MySQL数据库中各主要存储引擎的独特特点的描述: 1.MySQL有多种存储引擎: MyISAM.InnoDB.MERGE.MEMORY(HEAP).BDB(Berk ...
- mysql存储引擎静态表_MySQL存储引擎(表类型)的选择
一.MySQL存储引擎概述 MySQL与多数数据库不同的是包含存储引擎这一特性,用户可以根据应用的需要选择合适的存储引擎来使存储和索引数据,以及是否使用事务等.MySQL5.0支持的存储引擎包括MyI ...
- mysql有那么多存储引擎_MySQL的多存储引擎架构
支持多种存储引擎是众所周知的MySQL特性,也是MySQL架构的关键优势之一.如果能够理解MySQL Server与存储引擎之间是怎样通过API交互的,将大大有利于理解MySQL的核心基础架构.本文将 ...
- MySQL存储引擎与数据的关系_MySQL存储引擎与数据类型
1 数据存储引擎 存储引擎的概念是MySQL的一个特性,它指定了表的类型(诸如表怎样存储与索引数据.是否支持事务.外键等),表在计算机中的存储方式. 1.1 MySql支持的数据存储引擎 查看引擎信息 ...
- mysql一共有多少引擎_MySQL存储引擎你们知道多少?
MySQL是我们经常使用的数据库处理系统(DBMS),不知小伙伴们有没有注意过其中的"存储引擎"(storage_engine)呢?有时候面试题中也会问道MySQL几种常用的存储引 ...
- mysql内存报警_[MySQL生产环境] Innodb存储引擎内存报警问题处理过程_MySQL
bitsCN.com [MySQL生产环境] Innodb存储引擎内存报警问题处理过程 1 不停的收到email报警,内存值超过阀值80%了. 2 top下,mysqld进程确实占据了77.5%,再加 ...
- mysql存储引擎 索引优化_MySQL存储引擎,索引及基本优化策略
存储引擎 与Oracle, SQL Server这些数据库不同,MySQL提供了多种存储引擎.什么是存储引擎?存储引擎其实就是一套对于数据如何存储,查询,更新,建立索引等接口的实现.不同存储引擎特性有 ...
- mysql 存储引擎_MySQL存储引擎
数据库存储引擎是数据库底层软件组织,数据库管理系统(DBMS)使用数据引擎进行创建.查询.更新和删除数据.不同的存储引擎提供不同的存储机制.索引技巧.锁定水平等功能,使用不同的存储引擎,还可以获得特定 ...
最新文章
- 为了提高工作效率:通过pycharm的模板代码减少重复工作
- 发动机异响故障诊断与排除_发动机缺缸故障诊断以及排除方法
- Linux 系统学习梳理_【All】
- [转载] 大道至简:软件工程实践者的思想——第六章 谁是解结的人
- 【实验】不会端口映射?看完就会了
- python123基本数据类型_python 基本数据类型
- cacti系统性能监控(CENTOS/UBUNTU)
- 2020牛客多校第1场H-Minimum-cost Flow-最小费用流
- java中强引用、弱引用、软引用、虚引用学习
- -bash-4.1问题
- CNN进行新闻文本分类代码实战,包含分类文本
- linux运行关关采集器,杰奇小说2.3-自动采集-关关采集器高级版
- Java进阶之计算机组成原理概述
- Scrum master成长笔记:如何为Scrum团队设定愿景目标?
- bzoj2429- 聪明的猴子
- 湖人VS爵士!!科比4月14日最后一战,本赛季最高得分!狂得60分!!完美大逆转!!!...
- 合并字符串(c++)
- EE-SX672 光眼
- windows 根据端口杀进程 部署jar包 批处理脚本
- python爬空气污染实时数据_python数据分析综合项目--空气质量指数分析