安装MySQL后,如何激活联邦引擎?
P粉475126941
P粉475126941 2023-10-18 08:51:44
0
2
635

我有 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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板