如何在安装后在mysql中启用联合引擎?

我有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中启用联邦引擎,我该怎么办?

回答(3)

2 years ago

编辑/etc/my.cnf并在[mysqld]部分中添加以下行:

federated

它相当于在命令行中指定--federated

2 years ago

我知道帖子有点旧,但似乎很多人都遇到了联邦引擎的问题 .

当通过yum安装mysql二进制文件时,您已经拥有HA(高可用性)插件 . 您只需要在mysql CLI中加载插件 .

这是基本过程:

如果尚未启动mysqld,请启动它 . 此时确保“联合”不在/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)
  • END PASTE < -

要启用联邦引擎,请键入以下内容:

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)

你完成了......出去创建联邦表...

祝好运!

2 years ago

从MySQL 5.0.64开始,默认情况下,在正在运行的服务器中未启用FEDERATED存储引擎;要启用FEDERATED,您必须使用--federated选项启动MySQL服务器二进制文件 . - MySQL文档

要在配置文件中使用 --federated option,请删除 -- .

示例

my.cnf

[mysqld]
federated