mysql8集群搭建

来源:这里教程网 时间:2026-03-01 16:04:49 作者:

集群搭建参考mysql5.7的搭建 http://blog.itpub.net/70004783/viewspace-2838198/ 环境:mysql-8.0.26centos7.9

主库    dbserver01  10.8.98.102

从库1   dbserver02  10.8.98.103

从库2   dbserver03  10.8.98.104 mysql8集群的搭建与5.7只有略微不同 在于主库参数和备库参数 主库参数

[root@dbserver01 ~]# cat /etc/my.cnf 
[mysql]
default-character-set=utf8mb4
socket=/u01/data/3306/mysql.sock
[mysqld]
#skip-name-resolve
port = 3306
socket=/u01/data/3306/mysql.sock
basedir=/u01/app/mysql
datadir=/u01/data/3306/data
character-set-server=utf8mb4
default-storage-engine=INNODB
innodb_buffer_pool_size = 200M
max_allowed_packet=16M
explicit_defaults_for_timestamp=1
log-output=FILE
general_log = 0
general_log_file=/u01/log/3306/3306db-general.err
slow_query_log = ON
slow_query_log_file=/u01/log/3306/3306db-query.err
long_query_time=10
log-error=/u01/log/3306/3306db-error.err
#mysql5.7的密码策略,8.0很多客户端不支持
default-authentication-plugin=mysql_native_password
#mysql cluster master add
bind-address=10.8.98.102
server_id=1023306
skip_name_resolve=ON
expire_logs_days=7
#innodb_support_xa=1
binlog_cache_size=1M
max_binlog_size=2048M
log_bin_trust_function_creators=1
innodb_flush_log_at_trx_commit=1
sync_binlog=1
transaction-isolation=READ-COMMITTED
gtid_mode=ON
enforce_gtid_consistency=1
log-slave-updates=1
binlog_gtid_simple_recovery=1
log_bin=/u01/log/3306/binlog/dbserver-binlog
log_bin_index=/u01/log/3306/binlog/dbserver-binlog.index
binlog_format=ROW
binlog_rows_query_log_events=on
plugin_dir=/u01/app/mysql/lib/plugin/
plugin_load="rpl_semi_sync_source=semisync_source.so;rpl_semi_sync_replica=semisync_replica.so"
loose_rpl_semi_sync_source_enabled=1
loose_rpl_semi_sync_replica_enabled=1
loose_rpl_semi_sync_source_timeout=5000
rpl_semi_sync_source_wait_point=AFTER_SYNC
rpl_semi_sync_source_wait_for_replica_count=1
[root@dbserver01 ~]#

与原来5.7的区别只在于以下几行 #innodb_support_xa=1            ###此行注释掉,启动会报错unknown variable 'innodb_support_xa=1' 以下几个8.0版本参数的名字改了,对应修改即可plugin_load="rpl_semi_sync_source=semisync_source.so;rpl_semi_sync_replica=semisync_replica.so"loose_rpl_semi_sync_source_enabled=1loose_rpl_semi_sync_replica_enabled=1loose_rpl_semi_sync_source_timeout=5000rpl_semi_sync_source_wait_point=AFTER_SYNCrpl_semi_sync_source_wait_for_replica_count=1 备库参数参考

[root@dbserver02 ~]# cat /etc/my.cnf 
[mysql]
default-character-set=utf8mb4
socket=/u01/data/3306/mysql.sock
[mysqld]
#skip-name-resolve
port = 3306
socket=/u01/data/3306/mysql.sock
basedir=/u01/app/mysql
datadir=/u01/data/3306/data
character-set-server=utf8mb4
default-storage-engine=INNODB
innodb_buffer_pool_size = 200M
max_allowed_packet=16M
explicit_defaults_for_timestamp=1
log-output=FILE
general_log = 0
general_log_file=/u01/log/3306/3306db-general.err
slow_query_log = ON
slow_query_log_file=/u01/log/3306/3306db-query.err
long_query_time=10
log-error=/u01/log/3306/3306db-error.err
#mysql5.7的密码策略,8.0很多客户端不支持
default-authentication-plugin=mysql_native_password
#mysql cluster slave add
bind-address=10.8.98.103
server_id=1033306
skip_name_resolve=ON
expire_logs_days=7
#innodb_support_xa=1
binlog_cache_size=1M
max_binlog_size=2048M
log_bin_trust_function_creators=1
innodb_flush_log_at_trx_commit=1
sync_binlog=1
transaction-isolation=READ-COMMITTED
gtid_mode=ON
enforce_gtid_consistency=1
log-slave-updates=1
binlog_gtid_simple_recovery=1
log_bin=/u01/log/3306/binlog/dbserver-binlog
log_bin_index=/u01/log/3306/binlog/dbserver-binlog.index
binlog_format=ROW
binlog_rows_query_log_events=on
relay_log=/u01/log/3306/relaylog/dbserver-relay.log
read_only=1
plugin_dir=/u01/app/mysql/lib/plugin/
plugin_load="rpl_semi_sync_source=semisync_source.so;rpl_semi_sync_replica=semisync_replica.so"
loose_rpl_semi_sync_source_enabled=1
loose_rpl_semi_sync_replica_enabled=1
loose_rpl_semi_sync_source_timeout=5000
rpl_semi_sync_source_wait_point=AFTER_SYNC
rpl_semi_sync_source_wait_for_replica_count=1
[root@dbserver02 ~]#

其余可参考集群mysql5.7的搭建

相关推荐