mysql8叢集搭建

hellohf123發表於2021-10-20

叢集搭建參考mysql5.7的搭建

http://blog.itpub.net/70004783/viewspace-2838198/



環境:

mysql-8.0.26

centos7.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=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 ~]# 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的搭建

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70004783/viewspace-2838272/,如需轉載,請註明出處,否則將追究法律責任。

相關文章