MySQL MGR單主模式詳細搭建過程
環境:
節點1:192.168.157.128 CentOS 7.6
資料庫:mysql-5.7.27-linux-glibc2.12-x86_64
節點2:192.168.157.129 CentOS 7.6
資料庫:mysql-5.7.27-linux-glibc2.12-x86_64
節點3:192.168.157.130 CentOS 7.6
資料庫:mysql-5.7.27-linux-glibc2.12-x86_64
1、安裝MySQL
在三臺db伺服器上面設定/etc/hosts對映,如下:
192.168.157.128 mgr1
192.168.157.129 mgr2
192.168.157.130 mgr3
安裝的資料庫伺服器:
IP地址: 埠號:資料目錄: Server-id:
192.168.157.128(mgr1) 3306 /opt/mysql/data 20
192.168.157.129(mgr2) 3306 /opt/mysql/data 21
192.168.157.130(mgr3) 3306 /opt/mysql/data 22
安裝過程略。。。。。
配置my.cnf:
注意每個節點的server_id、loose-group_replication_local_address、loose-group_replication_group_seeds都配置成自己的相應的引數
配置my.cnf:
[client]
port = 3306
socket = /opt/mysql/tmp/mysql.sock
[mysqld]
port = 3306
socket = /opt/mysql/tmp/mysql.sock
back_log = 80
basedir = /opt/mysql
tmpdir = /tmp
datadir = /opt/mysql/data
pid-file=/opt/mysql/tmp/mysqld.pid
#-------------------gobal variables------------#
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 = /opt/mysql/log/mysql-bin
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = 'ce9be252-2b71-11e6-b8f4-00212844f856'
loose-group_replication_start_on_boot = off
loose-group_replication_local_address = '192.168.157.128:33061'
loose-group_replication_group_seeds ='192.168.157.128:33061,192.168.157.129:33061,192.168.157.130:33061'
loose-group_replication_bootstrap_group = off
loose-group_replication_single_primary_mode = true
loose-group_replication_enforce_update_everywhere_checks = false
max_connect_errors = 20000
max_connections = 2000
wait_timeout = 3600
interactive_timeout = 3600
net_read_timeout = 3600
net_write_timeout = 3600
table_open_cache = 1024
table_definition_cache = 1024
thread_cache_size = 512
open_files_limit = 10000
character-set-server = utf8
collation-server = utf8_bin
skip_external_locking
performance_schema = 1
user = mysql
myisam_recover_options = DEFAULT
skip-name-resolve
local_infile = 0
lower_case_table_names = 0
#--------------------innoDB------------#
innodb_buffer_pool_size = 2000M
innodb_data_file_path = ibdata1:1000M:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_io_capacity = 600
innodb_lock_wait_timeout = 120
innodb_log_buffer_size = 8M
innodb_log_file_size = 2000M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 85
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_support_xa = 1
innodb_thread_concurrency = 32
innodb_file_per_table
innodb_rollback_on_timeout
#------------session variables-------#
join_buffer_size = 8M
key_buffer_size = 256M
bulk_insert_buffer_size = 8M
max_heap_table_size = 96M
tmp_table_size = 96M
read_buffer_size = 8M
sort_buffer_size = 2M
max_allowed_packet = 64M
read_rnd_buffer_size = 32M
#------------MySQL Log----------------#
log-bin = my3306-bin
binlog_format = row
sync_binlog = 1
expire_logs_days = 15
#max_binlog_cache_size = 128M
#max_binlog_size = 500M
binlog_cache_size = 64k
slow_query_log
log-slow-admin-statements
log_warnings = 1
long_query_time = 0.25
#---------------replicate--------------#
relay-log = /opt/mysql/log/mysql-relay-bin
relay-log-index = relay3306.index
relay-log = relay3306
server-id = 20
init_slave = 'set sql_mode=STRICT_ALL_TABLES'
log-slave-updates
[myisamchk]
key_buffer = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
log-error = /opt/mysql/log/mysql.err
2、建立MGR
在mgr1/mgr2/mgr3上建立複製賬號:
mysql>
set sql_log_bin=0;
grant replication slave on *.* to 'repl'@'%' identified by '123456';
flush privileges;
set sql_log_bin=1;
安裝group replication外掛
在mgr1、mgr2、mgr3上依次安裝group replication外掛
mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';
配置group replication引數
確保binlog_format是row格式。
mysql> show variables like 'binlog_format';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW |
+---------------+-------+
1 row in set (0.00 sec)
配置檔案配置:
(1) mgr1上的my.cnf配置:
server-id=20
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = "ce9be252-2b71-11e6-b8f4-00212844f856"
loose-group_replication_start_on_boot = off
loose-group_replication_local_address = "192.168.157.128:33061"
loose-group_replication_group_seeds = "192.168.157.128:33061,192.168.157.129:33061,192.168.157.130:33061"
loose-group_replication_bootstrap_group = off
loose-group_replication_single_primary_mode = true
loose-group_replication_enforce_update_everywhere_checks = false
(2)mgr2上的my.cnf配置:
server-id=21
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = "ce9be252-2b71-11e6-b8f4-00212844f856"
loose-group_replication_start_on_boot = off
loose-group_replication_local_address = "192.168.157.129:33061"
loose-group_replication_group_seeds = "192.168.157.128:33061,192.168.157.129:33061,192.168.157.130:33061"
loose-group_replication_bootstrap_group = off
loose-group_replication_single_primary_mode = true
loose-group_replication_enforce_update_everywhere_checks = false
(3)mgr3上的my.cnf配置:
server-id=22
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = "ce9be252-2b71-11e6-b8f4-00212844f856"
loose-group_replication_start_on_boot = off
loose-group_replication_local_address = "192.168.157.130 :33061"
loose-group_replication_group_seeds = "192.168.157.128:33061,192.168.157.129:33061,192.168.157.130:33061"
loose-group_replication_bootstrap_group = off
loose-group_replication_single_primary_mode = true
loose-group_replication_enforce_update_everywhere_checks = false
配置完後,重啟3個db上的mysql服務
[root@mha01 etc]# mysqladmin -uroot -p -S /opt/mysql/tmp/mysql.sock shutdown
Enter password:
2019-08-19T07:58:22.734405Z mysqld_safe mysqld from pid file /opt/mysql/tmp/mysqld.pid ended
[1]+ Done /opt/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf
[root@mha01 etc]# /opt/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
[1] 85384
[root@mha01 etc]# 2019-08-19T07:58:58.536554Z mysqld_safe Logging to '/opt/mysql/log/mysql.err'.
2019-08-19T07:58:58.570079Z mysqld_safe Starting mysqld daemon with databases from /opt/mysql/data
啟動mgr群集
開始構建group replication叢集,通常操作命令
在mgr1、mgr2、mgr3上依次執行
mysql> CHANGE MASTER TO MASTER_USER='repl', MASTER_PASSWORD='123456' FOR CHANNEL 'group_replication_recovery';
Query OK, 0 rows affected, 2 warnings (0.02 sec)
Db1上建立基本主庫master庫:
# 設定group_replication_bootstrap_group為ON是為了標示以後加入叢集的伺服器以這臺伺服器為基準,以後加入的就不需要設定。
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 (1.03 sec)
mysql> select * from performance_schema.replication_group_members;
Db2上啟動group_replication:
Db2上mysql命令列上執行啟動:
mysql> set global group_replication_allow_local_disjoint_gtids_join=ON;
mysql> start group_replication;
mysql> select * from performance_schema.replication_group_members;
Db3上啟動group_replication:
-- Db3命令列上執行:
mysql> set global group_replication_allow_local_disjoint_gtids_join=ON;
mysql> start group_replication;
-- 再去master庫mgr1上,檢視group_replication成員,會有mgr3的顯示,而且已經是ONLINE了
mysql> select * from performance_schema.replication_group_members;
最後檢視叢集狀態,都為ONLINE就表示OK:
mysql> select * from performance_schema.replication_group_members;
Done.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22996654/viewspace-2654442/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL MGR 叢集搭建(單主模式)MySql模式
- MySQL MHA詳細搭建過程MySql
- MySQL組複製(MGR)全解析 Part 5 MGR單主模式部署指南MySql模式
- 在Docker中安裝MySQL 8.0.19之MGR(單主模式&多主模式)+新增節點DockerMySql模式
- MySQL組複製(MGR)全解析 Part 4 MGR單主模式部署前準備MySql模式
- MySQL+MGR 單主模式和多主模式的叢集環境 - 部署手冊 (Centos7.5)MySql模式CentOS
- mysql5.7.23安裝詳細過程MySql
- 新手搭建雲伺服器詳細過程伺服器
- 單機MGR搭建
- MySQL MGR 叢集搭建MySql
- mysql8.0.31 mgr搭建MySql
- MySQL之MGR白名單MySql
- MySQL 8.0.20 MGR資料遷移過程以及注意事項MySql
- nginx配置https詳細過程NginxHTTP
- Hexo的詳細搭建過程——小白的血淚經歷QAQHexo
- MySQL:MGR 學習(2):Write set(寫集合)的寫入過程MySql
- MGR(MySQL Group Replication)部署搭建測試MySql
- 泊松過程的詳細理解
- MYSQL Group Replication搭建過程記錄MySql
- 入門 | Tensorflow實戰講解神經網路搭建詳細過程神經網路
- Visual Studio 2010詳細安裝過程
- mysql MGR搭建和模擬切換演練MySql
- 2、超詳細的域滲透過程
- Webpack安裝配置及打包詳細過程Web
- 詳細瞭解 synchronized 鎖升級過程synchronized
- ESXI 6.7 系統安裝詳細過程
- Https原理解析及詳細推演過程HTTP
- centos7安裝的詳細過程CentOS
- ubuntu系統安裝mysql並支援遠端連線的詳細過程UbuntuMySql
- MySQL8.0的MGR多主搭建與測試MySql
- SQL Server 2000詳細安裝過程及配置SQLServer
- SQL Server 2005詳細安裝過程及配置SQLServer
- vue原始碼解析-圖解diff詳細過程Vue原始碼圖解
- 超詳細講解頁面載入過程
- MySQL主主模式+Keepalived高可用MySql模式
- 超詳細的ArrayList擴容過程(配合原始碼詳解)原始碼
- MGR測試過程中出現的問題彙總
- Visual Basic 6.0(VB6.0)詳細安裝過程