安裝MySQL後,如何啟動聯邦引擎?
P粉475126941
P粉475126941 2023-10-18 08:51:44
0
2
627

我有 mysql 5.1.44:

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 中啟用聯合引擎。我該怎麼做?

P粉475126941
P粉475126941

全部回覆(2)
P粉296080076

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

當透過 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

使用 root(或具有足夠權限的其他帳戶)登入 mysql CLI。

Type:   show engines;

此時您應該看不到 FEDERATED 引擎,如下所示:

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)

您現在可以安全地將「federated」行新增至 /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重新啟動等...)

重啟後,回傳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)

您已完成...繼續建立聯邦表...

祝你好運!

P粉457445858

編輯 /etc/my.cnf 並在 [mysqld] 部分中新增以下行:

federated

相當於在命令列中指定--federated

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板