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)

 

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