文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

MySQL5.7 MGR安装配置

2024-04-02 19:55

关注

MySQL5.7 MGR安装配置

一、服务器规划

mysql_mgr_01 192.168.10.223

mysql_mgr_02 192.168.10.224

mysql_mgr_03 192.168.10.225



二、配置文件

1. mysql_mgr_01

[root@mysql_mgr_01 tmp]# cat /etc/my.cnf

[mysqld]

sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

server-id=330601

port = 3306

log_bin = /data/mysql/binlog/mysql_mgr01-bin

#expire_logs_days=10

explicit_defaults_for_timestamp=true

datadir=/data/mysql/data

socket=/data/mysql/run/mysql.sock

skip-external-locking

pid-file=/data/mysql/run/mysql.pid

innodb_file_per_table = on

#skip_name_resolve = on

 

character-set-server = utf8mb4

character-set-client-handshake = FALSE

collation-server = utf8mb4_unicode_ci

init_connect='SET NAMES utf8mb4'

 

slow_query_log = on

long_query_time = 2 

slow_query_log_file = /data/mysql/slow_logs/mysql-slow.log

binlog_rows_query_log_events=ON

relay-log=/data/mysql/relaylog/mysql_mgr_01-relay-bin


#

# Replication configuration parameters

#

gtid_mode=ON

enforce_gtid_consistency=ON

master_info_repository=TABLE

relay_log_info_repository=TABLE

binlog_checksum=NONE

log_slave_updates=ON

binlog_format=ROW


#

# Group Replication configuration

#

transaction_write_set_extraction=XXHASH64

loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"

loose-group_replication_start_on_boot=off

loose-group_replication_local_address= "192.168.10.223:24901"

loose-group_replication_group_seeds= "192.168.10.223:24901,192.168.10.224:24902,192.168.10.225:24903"

loose-group_replication_bootstrap_group=off

group_replication_member_weight = 100


symbolic-links=0

 

[mysqld_safe]

log-error=/data/mysql/logs/mysql.log

pid-file=/data/mysql/run/mysql.pid

 

[mysql]

default-character-set = utf8mb4

socket=/data/mysql/run/mysql.sock

 

[client]

#default-character-set = utf8mb4

socket=/data/mysql/run/mysql.sock


2. mysql_mgr_02

[root@mysql_mgr_02 tmp]# cat /etc/my.cnf

[mysqld]

sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

server-id=330602

port = 3306

log_bin = /data/mysql/binlog/mysql_mgr02-bin

#expire_logs_days=10

explicit_defaults_for_timestamp=true

datadir=/data/mysql/data

socket=/data/mysql/run/mysql.sock

skip-external-locking

pid-file=/data/mysql/run/mysql.pid

innodb_file_per_table = on

#skip_name_resolve = on

relay-log=/data/mysql/relaylog/mysql_mgr_02-relay-bin

 

character-set-server = utf8mb4

character-set-client-handshake = FALSE

collation-server = utf8mb4_unicode_ci

init_connect='SET NAMES utf8mb4'

 

slow_query_log = on

long_query_time = 2 

slow_query_log_file = /data/mysql/slow_logs/mysql-slow.log

 

symbolic-links=0


#

# Replication configuration parameters

#

gtid_mode=ON

enforce_gtid_consistency=ON

master_info_repository=TABLE

relay_log_info_repository=TABLE

binlog_checksum=NONE

log_slave_updates=ON

binlog_format=ROW


#

# Group Replication configuration

#

transaction_write_set_extraction=XXHASH64

loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"

loose-group_replication_start_on_boot=off

loose-group_replication_local_address= "192.168.10.224:24902"

loose-group_replication_group_seeds= "192.168.10.223:24901,192.168.10.224:24902,192.168.10.225:24903"

loose-group_replication_bootstrap_group=off

group_replication_member_weight = 80


[mysqld_safe]

log-error=/data/mysql/logs/mysql.log

pid-file=/data/mysql/run/mysql.pid


[mysql]

default-character-set = utf8mb4

socket=/data/mysql/run/mysql.sock


[client]

#default-character-set = utf8mb4

socket=/data/mysql/run/mysql.sock


3. mysql_mgr_03

[root@mysql_mgr_03 tmp]# cat /etc/my.cnf

[mysqld]

sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

server-id=330603

port = 3306

log_bin = /data/mysql/binlog/mysql_mgr03-bin

#expire_logs_days=10

explicit_defaults_for_timestamp=true

datadir=/data/mysql/data

socket=/data/mysql/run/mysql.sock

skip-external-locking

pid-file=/data/mysql/run/mysql.pid

innodb_file_per_table = on

#skip_name_resolve = on

relay-log=/data/mysql/relaylog/mysql_mgr_03-relay-bin

 

character-set-server = utf8mb4

character-set-client-handshake = FALSE

collation-server = utf8mb4_unicode_ci

init_connect='SET NAMES utf8mb4'

 

slow_query_log = on

long_query_time = 2 

slow_query_log_file = /data/mysql/slow_logs/mysql-slow.log

 

symbolic-links=0


#

# Replication configuration parameters

#

gtid_mode=ON

enforce_gtid_consistency=ON

master_info_repository=TABLE

relay_log_info_repository=TABLE

binlog_checksum=NONE

log_slave_updates=ON

binlog_format=ROW


#

# Group Replication configuration

#

transaction_write_set_extraction=XXHASH64

loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"

loose-group_replication_start_on_boot=off

loose-group_replication_local_address= "192.168.10.225:24903"

loose-group_replication_group_seeds= "192.168.10.223:24901,192.168.10.224:24902,192.168.10.225:24903"

loose-group_replication_bootstrap_group=off

group_replication_member_weight = 90


[mysqld_safe]

log-error=/data/mysql/logs/mysql.log

pid-file=/data/mysql/run/mysql.pid


[mysql]

default-character-set = utf8mb4

socket=/data/mysql/run/mysql.sock


[client]

#default-character-set = utf8mb4

socket=/data/mysql/run/mysql.sock




三、MGR配置

1. mysql_mgr_01

[mysql_mgr_01]


#关闭SQL_LOG_BIN

SET SQL_LOG_BIN=0;


#创建组复制使用的帐号密码

CREATE USER rpl_user@'%' IDENTIFIED BY 'password';

GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%';


FLUSH PRIVILEGES;


#开启SQL_LOG_BIN

SET SQL_LOG_BIN=1;


#安装组复制插件group_replication.so

INSTALL PLUGIN group_replication SONAME 'group_replication.so';


CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='password' FOR CHANNEL 'group_replication_recovery';


#初始化主节点

SET GLOBAL group_replication_bootstrap_group=ON;

START GROUP_REPLICATION;

SET GLOBAL group_replication_bootstrap_group=OFF;


#查看组复制成员状态

SELECT * FROM performance_schema.replication_group_members;


#备份

mysqldump -uroot -p --all-databases --master-data=2 --single-transaction>/tmp/all.sql


2. mysql_mgr_02

[mysql_mgr_02]


#恢复备份


#安装组复制插件group_replication.so

INSTALL PLUGIN group_replication SONAME 'group_replication.so';


CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='password' FOR CHANNEL 'group_replication_recovery';


#启动组复制

START GROUP_REPLICATION;



3. mysql_mgr_03

[mysql_mgr_03]


#恢复备份


#安装组复制插件group_replication.so

INSTALL PLUGIN group_replication SONAME 'group_replication.so';


CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='password' FOR CHANNEL 'group_replication_recovery';


#启动组复制

START GROUP_REPLICATION;


阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     807人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     351人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     314人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     433人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     221人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯