2011-03-06 45 views
29


我有mysql 44年5月1日如何在安裝後在mysql中啓用聯合引擎?

 
mysql> show engines; 
+------------+---------+ 
| Engine  | Support | 
+------------+---------+ 
| ndbcluster | NO  | 
| MRG_MYISAM | YES  | 
| BLACKHOLE | YES  | 
| CSV  | YES  | 
| MEMORY  | YES  | 
| FEDERATED | NO  | 
| ARCHIVE | YES  | 
| InnoDB  | YES  | 
| MyISAM  | DEFAULT | 

現在,我需要能夠在MySQL聯邦引擎,我怎麼能這樣做呢?

回答

51

編輯/etc/my.cnf中和在的[mysqld]部分中,添加行:

 
federated 

它的相當於指定 - 在命令行上執行

+3

在Windows上,要修改的文件是安裝目錄中的my.ini文件(例如'C:\ Program Files \ MySQL \ MySQL Server 5.1') – 2012-12-10 08:23:57

+1

在Windows中,它也必須是下一件事在[mysqld]之後加上換行符,就像這樣 - > [mysqld](換行符) 聯合 – 2013-07-11 07:55:07

+2

無法得到這個工作,打開my.ini並在'[mysqld]'之後的新行中添加'federated',仍然沒有看到它啓用。我正在使用Windows 8上的MySQL 5.6.12。任何想法可能是錯的? – 2013-07-29 06:01:03

5

與MySQL 5.0.64開始, FEDERATED存儲引擎是在運行 服務器不 默認啓用;要啓用FEDERATED,您必須使用 --federated選項啓動MySQL服務器二進制文件 。 — MySQL Documentation

要使用--federatedoption在配置文件中刪除--

的my.cnf

[mysqld] 
federated 
25

我知道這篇文章有點舊,但似乎很多人都遇到聯合引擎的問題。

當通過yum安裝mysql二進制文件時,您已經擁有HA(高可用性)插件。您只需在mysql CLI中加載插件即可。

這裏的基本過程是:

啓動mysqld如果它尚未啓動。確保'federated'不在/etc/my.cnf中。

EX:此時的/etc/my.cnf看起來像這樣從一個標準的YUM安裝....

[mysqld] 
datadir=/var/lib/mysql 
socket=/var/lib/mysql/mysql.sock 
user=mysql 
# Disabling symbolic-links is recommended to prevent assorted security risks 
symbolic-links=0 

[mysqld_safe] 
log-error=/var/log/mysqld.log 
pid-file=/var/run/mysqld/mysqld.pid 

登錄到MySQL的CLI以root(或具有足夠權限的另一個帳戶)。

Type: show engines; 

你應該看不到任何聯邦引擎在這一點上,像這樣:

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) 

- >糊底< -

爲了使盟員引擎,鍵入以下內容:

install plugin federated soname 'ha_federated.so' 

現在,當你'顯示引擎'時,你會看到FEDERATED引擎,但關閉.. 。

它看起來是這樣的:

 

    mysql> show engines; 
    +------------+---------+------------------------------------------------------------+--------------+------+------------+ 
    | Engine  | Support | Comment             | Transactions | XA | Savepoints | 
    +------------+---------+------------------------------------------------------------+--------------+------+------------+ 
    | FEDERATED | NO  | Federated MySQL storage engine        | NULL   | NULL | NULL  | 
    | 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) 

您現在可以安全地添加行 '聯合' 到/etc/my.cnf文件裏是這樣的:

 

    [mysqld] 
    datadir=/var/lib/mysql 
    socket=/var/lib/mysql/mysql.sock 
    user=mysql 
    # Disabling symbolic-links is recommended to prevent assorted security risks 
    symbolic-links=0 
    federated 

    [mysqld_safe] 
    log-error=/var/log/mysqld.log 
    pid-file=/var/run/mysqld/mysqld.pid 

重啓mysqld(服務mysqld restart等)

重啓後,回到mysql CLI。

Type 'show engines;' 

您現在應該看到FEDERATED引擎可用,並且以SUPPORT方式顯示爲YES。

 

    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) 

和你做......出去並建立聯合表...

祝你好運!

+1

基本上,只能在my.cnf(或windows中的my.ini)中添加下一行:'[mysqld] federated',它可以被添加到文件末尾。 – 2014-04-10 12:50:36

+0

正如你所說,yum安裝版本的mysql服務器不會添加「聯合」支持。你的回答非常好,你救了我的一天! – serfer2 2015-06-29 09:42:48

+0

爲我工作。謝謝。 – Shashank 2017-01-05 08:34:22