暂无图片
暂无图片
3
暂无图片
暂无图片
暂无图片

mysql8.0 clone插件做主从

原创 游湖 2022-11-23
453

mysql8.0主从

主从机都安装mysql8.0
主机
配置文件 注意主从server_id不能相同
[mysqld]
port = 3306
character_set_server = utf8
socket = /tmp/mysql.sock
basedir = d:\dyy\mysql1
datadir =d:\dyy\mysql1\data
log-error = d:\dyy\mysql1\data\mysql.log
server_id = 1
gtid_mode = ON
enforce_gtid_consistency = ON
log_slave_updates = 1
log-bin = mysql-bin
master_info_repository = TABLE
lower_case_table_names = 1
max_connections = 2000
#chagethis
innodb_buffer_pool_size = 1G
transaction_isolation = READ-COMMITTED
default-storage-engine = InnoDB
binlog_format = ROW
innodb_log_buffer_size = 256M
innodb-log-files-in-group = 3
innodb-log-file-size = 500M
log_timestamps = SYSTEM
expire-logs-days = 15
innodb-log-files-in-group = 3
slow-query-log = 1
slow-query-log-file = d:\dyy\mysql1\data\mysql_slow.log
long_query_time = 1
innodb_temp_data_file_path = ibtmp1:200M;ibtmp2:200M:autoextend:max:5120M
innodb_flush_log_at_trx_commit = 1
sync_binlog = 1
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
explicit_defaults_for_timestamp = true
default-authentication-plugin =mysql_native_password
read_rnd_buffer_size = 2M
join_buffer_size = 128M
sort_buffer_size = 2M
plugin-load-add=mysql_clone.dll
clone=FORCE_PLUS_PERMANENT
log_bin_trust_function_creators=1
lower_case_table_names=1
secure_file_priv=""

[mysql]
default-character-set = utf8
[client]
default-character-set = utf8


从库配置文件
[mysqld]
port = 3306
character_set_server = utf8
socket = /tmp/mysql.sock
basedir = d:\dyy\mysq21
datadir =d:\dyy\mysql2\data
log-error = d:\dyy\mysql2\data\mysql.log
server_id = 2
gtid_mode = ON
enforce_gtid_consistency = ON
log_slave_updates = 1
log-bin = mysql-bin
master_info_repository = TABLE
lower_case_table_names = 1
max_connections = 2000
#chagethis
innodb_buffer_pool_size = 1G
transaction_isolation = READ-COMMITTED
default-storage-engine = InnoDB
binlog_format = ROW
innodb_log_buffer_size = 256M
innodb-log-files-in-group = 3
innodb-log-file-size = 500M
log_timestamps = SYSTEM
expire-logs-days = 15
innodb-log-files-in-group = 3
slow-query-log = 1
slow-query-log-file = d:\dyy\mysql2\data\mysql_slow.log
long_query_time = 1
innodb_temp_data_file_path = ibtmp1:200M;ibtmp2:200M:autoextend:max:5120M
innodb_flush_log_at_trx_commit = 1
sync_binlog = 1
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
explicit_defaults_for_timestamp = true
default-authentication-plugin =mysql_native_password
read_rnd_buffer_size = 2M
join_buffer_size = 128M
sort_buffer_size = 2M
plugin-load-add=mysql_clone.dll
clone=FORCE_PLUS_PERMANENT
log_bin_trust_function_creators=1
lower_case_table_names=1
secure_file_priv=""

[mysql]
default-character-set = utf8
[client]
default-character-set = utf8


主库source
create user s@'%' identified by '123456';
grant backup_admin on *.* to s@'%';
创建复制用户
create user 'replication'@'%' identified by 'replication';
grant replication slave on *.* to 'replication'@'%';

从库target
create user t@'%' identified by '123456';
grant clone_admin on *.* to t@'%';

登录从库
mysql -ut -p123456 -h192.168.3.14 -P3307
从库执行主库的ip和端口
set global clone_valid_donor_list='192.168.3.14:3306';
克隆
CLONE INSTANCE FROM s@'192.168.3.14':3306 identified by '123456';

告诉从库主库的信息:复制的起点
change master to master_host='192.168.3.14',
master_port=3306,
master_user='replication',
master_password='replication',
master_auto_position=1;

start slave
show slave status\G

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论