6

我正在尝试在 MySQL 5.7.21 上启用 MySQL 组复制插件,根据文档 ( https://dev.mysql.com/doc/refman/5.7/en/group-replication.html应该在 5.7 中可用)

$ mysql --version
mysql  Ver 14.14 Distrib 5.7.21, for Linux (x86_64) using  EditLine wrapper

当我尝试通过 MySQL 启用插件时:

$ mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
ERROR 1126 (HY000): Can't open shared library '/usr/lib/mysql/plugin/group_replication.so' (errno: 2 /usr/lib/mysql/plugin/group_replication.so: cannot open shared object file: No such file or directory)

我在 MySQL 中的插件的输出:

$ mysql> SHOW PLUGINS;
+----------------------------+----------+--------------------+---------+---------+
| Name                       | Status   | Type               | Library | License |
+----------------------------+----------+--------------------+---------+---------+
| binlog                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| mysql_native_password      | ACTIVE   | AUTHENTICATION     | NULL    | GPL     |
| sha256_password            | ACTIVE   | AUTHENTICATION     | NULL    | GPL     |
| CSV                        | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| MEMORY                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| InnoDB                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| INNODB_TRX                 | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_LOCKS               | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_LOCK_WAITS          | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP                 | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP_RESET           | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMPMEM              | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMPMEM_RESET        | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP_PER_INDEX       | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_CMP_PER_INDEX_RESET | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_BUFFER_PAGE         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_BUFFER_PAGE_LRU     | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_BUFFER_POOL_STATS   | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_TEMP_TABLE_INFO     | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_METRICS             | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_DEFAULT_STOPWORD | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_DELETED          | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_BEING_DELETED    | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_CONFIG           | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_INDEX_CACHE      | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_FT_INDEX_TABLE      | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_TABLES          | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_TABLESTATS      | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_INDEXES         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_COLUMNS         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_FIELDS          | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_FOREIGN         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_FOREIGN_COLS    | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_TABLESPACES     | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_DATAFILES       | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| INNODB_SYS_VIRTUAL         | ACTIVE   | INFORMATION SCHEMA | NULL    | GPL     |
| MyISAM                     | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| MRG_MYISAM                 | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| PERFORMANCE_SCHEMA         | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| ARCHIVE                    | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| BLACKHOLE                  | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| FEDERATED                  | DISABLED | STORAGE ENGINE     | NULL    | GPL     |
| partition                  | ACTIVE   | STORAGE ENGINE     | NULL    | GPL     |
| ngram                      | ACTIVE   | FTPARSER           | NULL    | GPL     |
+----------------------------+----------+--------------------+---------+---------+
44 rows in set (0.01 sec)

这是插件目录的内容:

$ ls -lah /usr/lib/mysql/plugin/
total 644K
drwxr-xr-x 2 root root 4.0K Sep 26 23:24 .
drwxr-xr-x 3 root root 4.0K Sep 26 23:24 ..
-rw-r--r-- 1 root root  21K Jul 19 14:10 adt_null.so
-rw-r--r-- 1 root root 6.2K Jul 19 14:10 auth_socket.so
-rw-r--r-- 1 root root  44K Jul 19 14:10 connection_control.so
-rw-r--r-- 1 root root 107K Jul 19 14:10 innodb_engine.so
-rw-r--r-- 1 root root  79K Jul 19 14:10 keyring_file.so
-rw-r--r-- 1 root root 151K Jul 19 14:10 libmemcached.so
-rw-r--r-- 1 root root 9.7K Jul 19 14:10 locking_service.so
-rw-r--r-- 1 root root  11K Jul 19 14:10 mypluglib.so
-rw-r--r-- 1 root root 6.2K Jul 19 14:10 mysql_no_login.so
-rw-r--r-- 1 root root  55K Jul 19 14:10 rewriter.so
-rw-r--r-- 1 root root  56K Jul 19 14:10 semisync_master.so
-rw-r--r-- 1 root root  15K Jul 19 14:10 semisync_slave.so
-rw-r--r-- 1 root root  27K Jul 19 14:10 validate_password.so
-rw-r--r-- 1 root root  31K Jul 19 14:10 version_token.so

这些是我的配置的内容:

猫 /etc/mysql/my.cnf

    [mysqld_safe]
    nice                                    = 0
    socket                                  = /var/run/mysqld/mysqld.sock

    [mysqld]
    basedir                                 = /usr
    bind_address                            = 123.45.67.89
    binlog_checksum                         = NONE
    binlog_format                           = ROW
    datadir                                 = /var/lib/mysql
    enforce_gtid_consistency                = ON
    expire_logs_days                        = 10
    general_log                             = 1
    general_log_file                        = /var/log/mysql/mysql.log
    gtid_mode                               = ON
    key_buffer_size                         = 8388608
    lc_messages_dir                         = /usr/share/mysql
    log_bin                                 = binlog
    log_error                               = /var/log/mysql/mysql_error.log
    log_slave_updates                       = ON
    long_query_time                         = 60
    loose-group_replication_bootstrap_group = OFF
    loose-group_replication_enforce_update_everywhere_checks= ON
    loose-group_replication_group_name      = 34dee7cd-d20d-4f59-9500-f56ada9a1abz
    loose-group_replication_group_seeds     = 123.45.67.88:33061,123.45.67.89:33061
    loose-group_replication_ip_whitelist    = 123.45.67.88,123.45.67.89
    loose-group_replication_local_address   = 123.45.67.89:33061
    loose-group_replication_recovery_use_ssl= 1
    loose-group_replication_single_primary_mode= OFF
    loose-group_replication_ssl_mode        = REQUIRED
    loose-group_replication_start_on_boot   = OFF
    master_info_repository                  = TABLE
    max_allowed_packet                      = 16M
    max_binlog_size                         = 100M
    max_connect_errors                      = 100000000
    pid-file                                = /var/run/mysqld/mysqld.pid
    port                                    = 3306
    query_cache_limit                       = 1M
    query_cache_size                        = 16M
    relay_log                               = my-project-prod-relay-bin
    relay_log_info_repository               = TABLE
    report_host                             = 123.45.67.88
    require_secure_transport                = ON
    server_id                               = 2
    skip_external_locking
    slow_query_log                          = 1
    slow_query_log_file                     = /var/log/mysql/mysql-slow-query.log
    socket                                  = /var/run/mysqld/mysqld.sock
    thread_cache_size                       = 8
    thread_stack                            = 192K
    tmpdir                                  = /tmp
    transaction_write_set_extraction        = XXHASH64
    user                                    = mysql

    [mysqldump]
    max_allowed_packet                      = 16M
    quick
    quote_names

    [mysql]
    no-auto-rehash

    [isamchk]
    key_buffer_size                         = 16M

    [client]
    port                                    = 3306
    socket                                  = /var/run/mysqld/mysqld.sock

    !includedir /etc/mysql/conf.d/

我想知道我是否使用了错误版本的 MySQL,或者是否需要其他一些步骤来安装组复制插件?

4

2 回答 2

5

FWIW 我下载了 5.7.19 社区版 https://dev.mysql.com/doc/refman/5.7/en/group-replication.html以在沙箱中运行它,并确认存在组复制 .so 文件.

就像您尝试的那样,我使用 INSTALL PLUGIN 语句加载了插件。

首先我必须添加一些配置设置,这些设置记录在https://dev.mysql.com/doc/refman/5.7/en/group-replication-configuring-instances.html

server_id=1 # or any value unique among your replica set
gtid_mode=ON
enforce_gtid_consistency=ON
master_info_repository=TABLE
relay_log_info_repository=TABLE
binlog_checksum=NONE
log_slave_updates=ON
log_bin=binlog
binlog_format=ROW

当然,在编辑配置设置后重新启动 mysqld。

根据此处的讨论,看起来组复制插件可能已被故意排除在普通 MySQL 服务器版本之外。

要知道您是否正在运行社区版,请运行 mysql:

> mysql -u root -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.20-log MySQL Community Server (GPL)
.....

要手动安装 Community Edition 5.7(或此处的其他存档版本:https ://downloads.mysql.com/archives/community/ ),请运行以下命令:

sudo apt-get install libaio1
sudo apt-get install libmecab2
curl -OL https://downloads.mysql.com/archives/get/file/mysql-common_5.7.20-1ubuntu16.04_amd64.deb
curl -OL https://downloads.mysql.com/archives/get/file/mysql-community-client_5.7.20-1ubuntu16.04_amd64.deb
curl -OL https://downloads.mysql.com/archives/get/file/mysql-client_5.7.20-1ubuntu16.04_amd64.deb
curl -OL https://downloads.mysql.com/archives/get/file/mysql-community-server_5.7.20-1ubuntu16.04_amd64.deb
sudo dpkg -i mysql-common_5.7.20-1ubuntu16.04_amd64.deb
sudo dpkg -i mysql-community-client_5.7.20-1ubuntu16.04_amd64.deb
sudo dpkg -i mysql-client_5.7.20-1ubuntu16.04_amd64.deb
sudo dpkg -i mysql-community-server_5.7.20-1ubuntu16.04_amd64.deb   
于 2017-10-03T19:34:14.400 回答
3

碰到同样的问题。比尔的回答以及为什么它不包含在标准版本中的链接为我指明了正确的方向,然后我在这里找到了路易斯的回答。链接指南显示,安装 mysql-apt-config 后,apt-get install mysql-server默认获取社区版本。这使我可以继续安装插件,尽管我有一个额外的错误:

ERROR 1123 (HY000): Can't initialize function 'group_replication'; Plugin initialization function failed.

当我检查 /var/log/mysql/error.log 时,我发现它失败了,因为:

2018-07-04T14:19:36.039987Z 5 [ERROR] For the creation of replication channels the master info and relay log info repositories must be set to TABLE

为 MySQL 提供正确的 Group Replication-ready 配置解决了这个问题。在我的情况下,这只是重新启动 MySQL 服务器,因为我已经使用 Ansible 对其进行了配置,但它没有生效。希望对任何处理组复制的人有所帮助。

编辑:虽然上述方法有效,但在使用 Geerlingguy Ansible 角色时会产生问题,因此我没有安装社区服务器,而是直接使用以下 Ansible 代码配置插件:

    - name: Provision the MySQL group_replication plugin
  copy:
    src: group_replication.so
    dest: /usr/lib/mysql/plugin/group_replication.so
    mode: 0644

虽然我从 MySQL 的社区版本中获得了插件,但我可以说这是另一种更适合某些情况的有效方法。

于 2018-07-04T14:48:55.010 回答