MySQL MGR 安装

安装MGR

1.三个节点分别安装MySQL

版本我选择了8.0.18,三个节点参数文件基本类似,有多主模式和单主模式,我配置的是多主模式
参数文件如下,仅供参考

[client]
port = 3306
socket = /tmp/mysql80.sock

[mysqld]
#skip-grant-tables
character_set_server=utf8
init_connect='SET NAMES utf8'
basedir=/u01/mysql80
datadir=/u01/mysql80_data
socket=/tmp/mysql80.sock
log-error=/u01/mysql80_log/mysqld80.log
#pid-file=/var/run/mysqld/mysqld.pid
lower_case_table_names = 1
max_connections=5000
default-time_zone = '+8:00'
log-bin=/u01/mysql80_log/mysql-bin
server-id=100241
secure-file-priv=''
expire_logs_days=10
max_binlog_size=500M
general_log=OFF
general_log_file=/u01/mysql80_log/mysql80_general.log
slow_query_log =ON
slow_query_log_file=/u01/mysql80_log/mysql80_slow.log
long_query_time = 6
innodb_file_per_table=1
gtid_mode=on
enforce-gtid-consistency=on
master_info_repository=TABLE
relay_log_info_repository=TABLE
binlog_format= ROW
binlog_checksum = NONE
log_slave_updates = ON
log_bin= ON
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=4

transaction_write_set_extraction=XXHASH64
loose-group_replication_enforce_update_everywhere_checks = ON
loose-group_replication_single_primary_mode = OFF
loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
loose-group_replication_start_on_boot=off
loose-group_replication_local_address= "192.169.10.241:33080"
loose-group_replication_group_seeds= "192.169.10.241:33080,192.169.10.242:33080,192.169.10.243:33080"
loose-group_replication_bootstrap_group= off

 配置文件设置好后,三个节点分别进行MySQL初始化,然后运行MySQL

2.安装MGR插件

三个节点都需执行:

mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
Query OK, 0 rows affected (0.35 sec)


3.设置复制账号

mysql> SET SQL_LOG_BIN=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global super_read_only=off;
Query OK, 0 rows affected (0.00 sec)

mysql> create user repl@'%' IDENTIFIED WITH mysql_native_password  BY 'repl';
Query OK, 0 rows affected (0.28 sec)

mysql> GRANT REPLICATION SLAVE ON *.* TO repl@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> SET SQL_LOG_BIN=1;
Query OK, 0 rows affected (0.00 sec)

注:mysql 8.0 默认使用 caching_sha2_password 身份验证机制 —— 从原来的 mysql_native_password 更改为 caching_sha2_password。如果使用默认身份验证机制创建用户的话,后面在连接远程节点时会抛错

2019-10-31T13:42:35.663751Z 103 [System] [MY-010597] [Repl] 'CHANGE MASTER TO FOR CHANNEL 'group_replication_recovery' executed'. Previous state master_host='rhel6', master_port= 3306, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='rhel6', master_port= 3306, master_log_file='', master_log_pos= 4, master_bind=''.
2019-10-31T13:42:35.679618Z 158 [Warning] [MY-010897] [Repl] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
2019-10-31T13:42:35.681183Z 158 [ERROR] [MY-010584] [Repl] Slave I/O for channel 'group_replication_recovery': error connecting to master 'repl@rhel6:3306' - retry-time: 60 retries: 1 message: Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection. Error_code: MY-002061
2019-10-31T13:42:35.708818Z 103 [ERROR] [MY-011582] [Repl] Plugin group_replication reported: 'There was an error when connecting to the donor server. Please check that group_replication_recovery channel credentials and all MEMBER_HOST column values of performance_schema.replication_group_members table are correct and DNS resolvable.'
2019-10-31T13:42:35.708842Z 103 [ERROR] [MY-011583] [Repl] Plugin group_replication reported: 'For details please check performance_schema.replication_connection_status table and error log messages of Slave I/O for channel group_replication_recovery.'

所以我在这边创建用户时,又指定了以前的验证机制(除了我这种办法,应该还有其他解决方案) 

4.设置白名单

mysql> set global group_replication_ip_whitelist='192.169.10.241,192.169.10.242,192.169.10.243';
Query OK, 0 rows affected (0.00 sec)

不设置白名单后面启动mgr会抛错

2019-10-31T13:13:46.305251Z 0 [Warning] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Connection attempt from IP address ::ffff:192.169.10.241 refused. Address is not in the IP whitelist.'
2019-10-31T13:13:46.325156Z 0 [ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Error connecting to the local group communication engine instance.'
2019-10-31T13:13:46.571775Z 0 [ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] The member was unable to join the group. Local port: 33080'

5.启动MGR

任一选择一节点执行

mysql> SET GLOBAL group_replication_bootstrap_group=ON; 
Query OK, 0 rows affected (0.00 sec)

mysql> START GROUP_REPLICATION;
Query OK, 0 rows affected (3.70 sec)

mysql> SET GLOBAL group_replication_bootstrap_group=off;
Query OK, 0 rows affected (0.00 sec)

其他节点执行

mysql> START GROUP_REPLICATION;
Query OK, 0 rows affected (3.79 sec)

6.查看MGR组信息

mysql> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
| group_replication_applier | bb7b1e4d-fbc2-11e9-8bc9-000c294422bc | rhel63      |        3306 | ONLINE       | PRIMARY     | 8.0.18         |
| group_replication_applier | c4ee2859-fbc8-11e9-9f9a-000c296ee978 | rhel6       |        3306 | ONLINE       | PRIMARY     | 8.0.18         |
| group_replication_applier | f8fe41fa-fbb9-11e9-b0c4-000c29d8ba4d | rhel62      |        3306 | ONLINE       | PRIMARY     | 8.0.18         |
+---------------------------+--------------------------------------+-------------+-------------+--------------+-------------+----------------+
3 rows in set (0.00 sec)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章