您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關(guān)mysql dblink如何鏈接mysql庫(kù),可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
1、查看target端是否安裝了FEDERATED存儲(chǔ)引擎
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 |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
注意:如果沒(méi)有安裝FEDERATED 引擎 執(zhí)行install plugin federated soname 'ha_federated.so';
這里已經(jīng)安裝好了,只是沒(méi)有啟用
2、將federated添加到my.cnf 重啟數(shù)據(jù)庫(kù)
vi /etc/my.cnf
[mysqld]
federated
service mysql restart
mysql> 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 |
| CSV | YES | CSV storage engine | 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 |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| FEDERATED | YES | Federated MySQL storage engine | NO | NO | NO |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
這里FEDERATED 引擎已經(jīng)啟用。
源端:
目標(biāo)的要dblink源端的表結(jié)構(gòu)
show create table F_ORDERINFO_DETAIL\G;
*************************** 1. row ***************************
Table: F_ORDERINFO_DETAIL
Create Table: CREATE TABLE `F_ORDERINFO_DETAIL` (
`SYSTEM_TYPE` varchar(100) DEFAULT NULL,
`ORDER_DATE` int(6) DEFAULT NULL,
`CUSTOMER_ID` varchar(40) DEFAULT NULL,
`UBI_UID` varchar(40) DEFAULT NULL,
`FOI_ORDERTIME` varchar(100) DEFAULT NULL,
`FOI_ORDERNO` varchar(40) DEFAULT NULL,
`FOI_KEY` varchar(2500) DEFAULT NULL,
`FOI_KEYTYPE` varchar(40) DEFAULT NULL,
`CODENAME` varchar(100) DEFAULT NULL,
`ORDER_STATUS` varchar(20) DEFAULT NULL,
`FOI_ORDERTYPE` varchar(60) DEFAULT NULL,
`QYZM` int(11) DEFAULT NULL,
`GDCZ` int(11) DEFAULT NULL,
`GLRY` int(11) DEFAULT NULL,
`QYDWTZ` int(11) DEFAULT NULL,
`FRDWTZ` int(11) DEFAULT NULL,
`FRZWRZ` int(11) DEFAULT NULL,
`CXFR` int(11) DEFAULT NULL,
`CXGD` int(11) DEFAULT NULL,
`CXGG` int(11) DEFAULT NULL,
`ORDER_TYPE` varchar(20) DEFAULT NULL,
`DESC_INFO2` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
mysql> select count(*) from F_ORDERINFO_DETAIL;
+----------+
| count(*) |
+----------+
| 2900 |
+----------+
目標(biāo)端:
CREATE TABLE `t` (
`SYSTEM_TYPE` varchar(100) DEFAULT NULL,
`ORDER_DATE` int(6) DEFAULT NULL,
`CUSTOMER_ID` varchar(40) DEFAULT NULL,
`UBI_UID` varchar(40) DEFAULT NULL,
`FOI_ORDERTIME` varchar(100) DEFAULT NULL,
`FOI_ORDERNO` varchar(40) DEFAULT NULL,
`FOI_KEY` varchar(2500) DEFAULT NULL,
`FOI_KEYTYPE` varchar(40) DEFAULT NULL,
`CODENAME` varchar(100) DEFAULT NULL,
`ORDER_STATUS` varchar(20) DEFAULT NULL,
`FOI_ORDERTYPE` varchar(60) DEFAULT NULL,
`QYZM` int(11) DEFAULT NULL,
`GDCZ` int(11) DEFAULT NULL,
`GLRY` int(11) DEFAULT NULL,
`QYDWTZ` int(11) DEFAULT NULL,
`FRDWTZ` int(11) DEFAULT NULL,
`FRZWRZ` int(11) DEFAULT NULL,
`CXFR` int(11) DEFAULT NULL,
`CXGD` int(11) DEFAULT NULL,
`CXGG` int(11) DEFAULT NULL,
`ORDER_TYPE` varchar(20) DEFAULT NULL,
`DESC_INFO2` varchar(50) DEFAULT NULL
) ENGINE=federated connection = 'mysql://root:123456@192.168.1.5:3306/czb/F_ORDERINFO_DETAIL';
注意:源端表結(jié)構(gòu) engine=federated connection = 'mysql://用戶(hù):密碼@IP地址:端口/庫(kù)名稱(chēng)/表名稱(chēng)';
mysql> select count(*) from F_ORDERINFO_DETAIL;
+----------+
| count(*) |
+----------+
| 2900 |
+----------+
源端:
mysql> insert into F_ORDERINFO_DETAIL select * from F_ORDERINFO_DETAIL;
Query OK, 2900 rows affected (0.28 sec)
Records: 2900 Duplicates: 0 Warnings: 0
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> select count(*) from F_ORDERINFO_DETAIL;
+----------+
| count(*) |
+----------+
| 5800 |
+----------+
1 row in set (0.00 sec)
目標(biāo)端:
mysql> select count(*) from t;
+----------+
| count(*) |
+----------+
| 5800 |
+----------+
1 row in set (0.00 sec)
看完上述內(nèi)容,你們對(duì)mysql dblink如何鏈接mysql庫(kù)有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。