我正在尝试在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
这些是我配置的内容:
cat /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版本,或者是否需要安装组复制插件?
答案 0 :(得分:3)
FWIW我下载了5.7.19社区Edihttps://dev.mysql.com/doc/refman/5.7/en/group-replication.htmltion以在沙箱中运行它,我确认组复制.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。
根据讨论here,看起来群组复制插件可能被故意排除在正常的MySQL服务器版本之外。
要知道您是否正在运行Community Edition,请运行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
答案 1 :(得分:1)
遇到同样的问题。 Bill的答案以及为什么不将其包含在标准版本中的链接为我指明了正确的方向,然后我找到了Luis的答案here。链接的guide显示在安装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提供正确的组复制就绪配置即可解决。就我而言,那只是重启MySQL服务器,因为我已经为它配置了Ansible,但没有生效。希望对任何处理组复制的人有所帮助。
编辑:尽管上述方法可行,但在使用Geerlingguy Ansible角色时却产生了问题,因此,我没有安装Community Server,而是直接使用以下Ansible代码配置了插件:
- name: Provision the MySQL group_replication plugin
copy:
src: group_replication.so
dest: /usr/lib/mysql/plugin/group_replication.so
mode: 0644
虽然我从MySQL的社区版本中获得了该插件,但是我可以说这是另一种有效的方法,更适合某些情况。