MySQL-Group-Replication 是mysql-5.7.17版本开发出来的新特性;它在master-slave 之间实现了强一致性,

但是就目前来说主要是性能不太好。

【1】确定当前的mysql数据库版本为5.7.17及以上

/usr/local/mysql/bin/mysqld --version
/usr/local/mysql/bin/mysqld Ver 5.7. for linux-glibc2. on x86_64 (MySQL Community Server (GPL))

【2】实验环境为一台主机上安装3台mysql,它们三个组成一个group-replication 组

  /tmp/4406.cnf 内容如下:

[mysqld]
####: for global
user =jianglexing # mysql
basedir =/usr/local/mysql # /usr/local/mysql/
datadir =/tmp// # /usr/local/mysql/data
server_id = #
port = #
socket =/tmp//mysql.sock # /tmp/mysql.sock
auto_increment_increment = #
auto_increment_offset = #
lower_case_table_names = #
secure_file_priv = # null ####: for binlog
binlog_format =row # row
log_bin =mysql-bin # off
binlog_rows_query_log_events =on # off
log_slave_updates =on # off
expire_logs_days = #
binlog_cache_size = # (32k)
binlog_checksum =none # CRC32
sync_binlog = # ####: for error-log
log_error =mysql-err.log # /usr/local/mysql/data/localhost.localdomain.err ####: for slow query log ####: for gtid
gtid_mode =on # off
enforce_gtid_consistency =on # off ####: for replication
master_info_repository =table # file
relay_log_info_repository =table # file ####: for group replication
transaction_write_set_extraction =XXHASH64 # off
loose-group_replication_group_name ="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" #
loose-group_replication_start_on_boot =off # off
loose-group_replication_local_address ="127.0.0.1:24901" #
loose-group_replication_group_seeds ="127.0.0.1:24901,127.0.0.1:24902,127.0.0.1:24903"
loose-group_replication_bootstrap_group =off # off ####: for innodb
default_storage_engine =innodb # innodb
default_tmp_storage_engine =innodb # innodb
innodb_data_file_path =ibdata1:12M:autoextend # ibdata1:12M:autoextend
innodb_temp_data_file_path =ibtmp1:12M:autoextend # ibtmp1:12M:autoextend
innodb_log_group_home_dir =./ # ./
innodb_log_files_in_group = #
innodb_log_file_size =48M # (48M)
innodb_file_format =Barracuda # Barracuda
innodb_file_per_table =on # on
innodb_page_size =16k # (16k)
innodb_thread_concurrency = #
innodb_read_io_threads = #
innodb_write_io_threads = #
innodb_purge_threads = #
innodb_print_all_deadlocks =on # off
innodb_deadlock_detect =on # on
innodb_lock_wait_timeout = #
innodb_spin_wait_delay = #
innodb_autoinc_lock_mode = #
innodb_stats_persistent =on # on
innodb_stats_persistent_sample_pages = #
innodb_adaptive_hash_index =on # on
innodb_change_buffering =all # all
innodb_change_buffer_max_size = #
innodb_flush_neighbors = #
innodb_flush_method =O_DIRECT #
innodb_doublewrite =on # on
innodb_log_buffer_size =16M # (16M)
innodb_flush_log_at_timeout = #
innodb_flush_log_at_trx_commit = #
autocommit = # [client]
auto-rehash

  /tmp/5506.cnf 内容如下:

[mysqld]
####: for global
user =jianglexing # mysql
basedir =/usr/local/mysql # /usr/local/mysql/
datadir =/tmp/ # /usr/local/mysql/data
server_id = #
port = #
socket =/tmp//mysql.sock # /tmp/mysql.sock
auto_increment_increment = #
auto_increment_offset = #
lower_case_table_names = #
secure_file_priv = # null ####: for binlog
binlog_format =row # row
log_bin =mysql-bin # off
binlog_rows_query_log_events =on # off
log_slave_updates =on # off
expire_logs_days = #
binlog_cache_size = # (32k)
binlog_checksum =none # CRC32
sync_binlog = # ####: for error-log
log_error =mysql-err.log # /usr/local/mysql/data/localhost.localdomain.err ####: for slow query log ####: for gtid
gtid_mode =on # off
enforce_gtid_consistency =on # off ####: for replication
master_info_repository =table # file
relay_log_info_repository =table # file ####: for group replication
transaction_write_set_extraction =XXHASH64 # off
loose-group_replication_group_name ="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" #
loose-group_replication_start_on_boot =off # off
loose-group_replication_local_address ="127.0.0.1:24902" #
loose-group_replication_group_seeds ="127.0.0.1:24901,127.0.0.1:24902,127.0.0.1:24903"
loose-group_replication_bootstrap_group =off # off ####: for innodb
default_storage_engine =innodb # innodb
default_tmp_storage_engine =innodb # innodb
innodb_data_file_path =ibdata1:12M:autoextend # ibdata1:12M:autoextend
innodb_temp_data_file_path =ibtmp1:12M:autoextend # ibtmp1:12M:autoextend
innodb_log_group_home_dir =./ # ./
innodb_log_files_in_group = #
innodb_log_file_size =48M # (48M)
innodb_file_format =Barracuda # Barracuda
innodb_file_per_table =on # on
innodb_page_size =16k # (16k)
innodb_thread_concurrency = #
innodb_read_io_threads = #
innodb_write_io_threads = #
innodb_purge_threads = #
innodb_print_all_deadlocks =on # off
innodb_deadlock_detect =on # on
innodb_lock_wait_timeout = #
innodb_spin_wait_delay = #
innodb_autoinc_lock_mode = #
innodb_stats_persistent =on # on
innodb_stats_persistent_sample_pages = #
innodb_adaptive_hash_index =on # on
innodb_change_buffering =all # all
innodb_change_buffer_max_size = #
innodb_flush_neighbors = #
innodb_flush_method =O_DIRECT #
innodb_doublewrite =on # on
innodb_log_buffer_size =16M # (16M)
innodb_flush_log_at_timeout = #
innodb_flush_log_at_trx_commit = #
autocommit = #

  /tmp/6606.cnf 内容如下:

[mysqld]
####: for global
user =jianglexing # mysql
basedir =/usr/local/mysql # /usr/local/mysql/
datadir =/tmp// # /usr/local/mysql/data
server_id = #
port = #
socket =/tmp//mysql.sock # /tmp/mysql.sock
auto_increment_increment = #
auto_increment_offset = #
lower_case_table_names = #
secure_file_priv = # null ####: for binlog
binlog_format =row # row
log_bin =mysql-bin # off
binlog_rows_query_log_events =on # off
log_slave_updates =on # off
expire_logs_days = #
binlog_cache_size = # (32k)
binlog_checksum =none # CRC32
sync_binlog = # ####: for error-log
log_error =mysql-err.log # /usr/local/mysql/data/localhost.localdomain.err ####: for slow query log ####: for gtid
gtid_mode =on # off
enforce_gtid_consistency =on # off ####: for replication
master_info_repository =table # file
relay_log_info_repository =table # file ####: for group replication
transaction_write_set_extraction =XXHASH64 # off
loose-group_replication_group_name ="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" #
loose-group_replication_start_on_boot =off # off
loose-group_replication_local_address ="127.0.0.1:24903" #
loose-group_replication_group_seeds ="127.0.0.1:24901,127.0.0.1:24902,127.0.0.1:24903"
loose-group_replication_bootstrap_group =off # off ####: for innodb
default_storage_engine =innodb # innodb
default_tmp_storage_engine =innodb # innodb
innodb_data_file_path =ibdata1:12M:autoextend # ibdata1:12M:autoextend
innodb_temp_data_file_path =ibtmp1:12M:autoextend # ibtmp1:12M:autoextend
innodb_log_group_home_dir =./ # ./
innodb_log_files_in_group = #
innodb_log_file_size =48M # (48M)
innodb_file_format =Barracuda # Barracuda
innodb_file_per_table =on # on
innodb_page_size =16k # (16k)
innodb_thread_concurrency = #
innodb_read_io_threads = #
innodb_write_io_threads = #
innodb_purge_threads = #
innodb_print_all_deadlocks =on # off
innodb_deadlock_detect =on # on
innodb_lock_wait_timeout = #
innodb_spin_wait_delay = #
innodb_autoinc_lock_mode = #
innodb_stats_persistent =on # on
innodb_stats_persistent_sample_pages = #
innodb_adaptive_hash_index =on # on
innodb_change_buffering =all # all
innodb_change_buffer_max_size = #
innodb_flush_neighbors = #
innodb_flush_method =O_DIRECT #
innodb_doublewrite =on # on
innodb_log_buffer_size =16M # (16M)
innodb_flush_log_at_timeout = #
innodb_flush_log_at_trx_commit = #
autocommit = #

【3】初始化三个数据库实例

cd /usr/local/mysql/
./bin/mysqld --defautls-file=/tmp/.cnf --datadir=/tmp/ --initialize-insecrue ./bin/mysqld --defautls-file=/tmp/.cnf --datadir=/tmp/ --initialize-insecrue ./bin/mysqld --defautls-file=/tmp/.cnf --datadir=/tmp/ --initialize-insecrue

【4】配置group-replication 的初始实例

/usr/local/mysql/bin/mysqld --defaults-file=/tmp/.cnf &
mysql -h127.0.0.1 -uroot -P4406

-- 增加用户
set sql_log_bin=0;
create user rpl_user@'%' identified by '';
grant replication slave,replication client on *.* to rpl_user@'%';
create user rpl_user@'127.0.0.1' identified by '';
grant replication slave,replication client on *.* to rpl_user@'127.0.0.1';
create user rpl_user@'localhost' identified by '';
grant replication slave,replication client on *.* to rpl_user@'localhost';
set sql_log_bin=1; -- 增加复制凭证
change master to
master_user='rpl_user',
master_password=''
for channel 'group_replication_recovery'; -- 安装组复制物件
install plugin group_replication soname 'group_replication.so'; -- 启动组复制
set global group_replication_bootstrap_group=on;
start group_replication;
set global group_replication_bootstrap_group=off;

【5】5506 实例的配置过程如下:

/usr/local/mysql/bin/mysqld --defaults-file=/tmp/5506.cnf &
 mysql -h127.0.0.1 -uroot -P5506

-- 增加用户
set sql_log_bin=0;
create user rpl_user@'%' identified by '';
grant replication slave,replication client on *.* to rpl_user@'%';
create user rpl_user@'127.0.0.1' identified by '';
grant replication slave,replication client on *.* to rpl_user@'127.0.0.1';
create user rpl_user@'localhost' identified by '';
grant replication slave,replication client on *.* to rpl_user@'localhost';
set sql_log_bin=1; -- 增加复制凭证
change master to
master_user='rpl_user',
master_password=''
for channel 'group_replication_recovery'; -- 安装组复制物件
install plugin group_replication soname 'group_replication.so'; -- 启动组复制
start group_replication; # 注意这里不是初始化了,只要加入就行

【6】6606 实例的操作与5506的操作一样,这样group replication 的配置就完成了。

-----------

最新文章

  1. MySQL 系列(四)主从复制、备份恢复方案生产环境实战
  2. git与github安装、配置、pull、push
  3. 【Android测试】【第六节】Monkey——认识和使用
  4. (一)stm32之CMSIS标准、库目录、GPIO
  5. AndrdoidStudio 2个jar包引起的异常Duplicate files copied in APK META-INF/LICENSE.txt
  6. samba共享修改匿名用户为非nobody
  7. ZOJ1109_Language of FatMouse(STL/map)
  8. winform 禁用鼠标滚轮
  9. Java反射学习(java reflect)(二)
  10. Properties配置文件
  11. mysql如何执行关联查询与优化
  12. redis底层设计(二)——内存映射数据结构
  13. 【PHP】解析PHP中的变量
  14. 【Android】Android的快速开发框架Afinal
  15. (转)Awsome Domain-Adaptation
  16. 常用官方php版本下载链接
  17. Docker镜像制作
  18. awk备忘
  19. gradle多项目构建及依赖
  20. poj 2002 Squares 几何二分 || 哈希

热门文章

  1. QPS相关的概念收集(吞吐量(TPS)、QPS、并发数、响应时间(RT))
  2. 在WPF中使用FontAwesome之类的字体图标
  3. 修复CentOS文件系统
  4. 如何解决weblogic server启动中在IIOP后运行缓慢
  5. 万里长征第二步——django个人博客(第七步 ——上传文件)
  6. LINUX提权笔记
  7. python matplotlib.pyplot学习记录
  8. centos7 keepalived以及防火墙配置
  9. apache2.4 的安装
  10. 【android开发】10款实用的Android UI工具,非常有用!