日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

MySQL5.7 Group Replication (MGR)--Mysql的组复制之多主模式

發(fā)布時(shí)間:2024/1/17 数据库 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySQL5.7 Group Replication (MGR)--Mysql的组复制之多主模式 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

MGR——Mysql的組復(fù)制之多主模式

?

以下測試在VMware環(huán)境:

操作系統(tǒng):Centos 6.9 X86_64

數(shù)據(jù)庫:Mysql 5.7 (mysql ?Ver 14.14 Distrib 5.7.21, for Linux (x86_64)?)

所使用虛擬機(jī)共計(jì)三臺(tái),ip分別是192.168.153.157、192.168.153.158、192.168.153.159

MGR模式:多主模式。

?

一、在三臺(tái)db服務(wù)器上面設(shè)置/etc/hosts映射,如下:

[root@mgr157 ~]# cat /etc/hosts

1 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 2 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 3 4 192.168.153.157 mgr157 5 192.168.153.158 mgr158 6 192.168.153.159 mgr159

二、my.cnf文件修改:

vi /etc/my.cnf (157服務(wù)器)

1 # For advice on how to change settings please see 2 # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html 3 4 [mysqld] 5 6 #-------------------gobal variables------------# 7 gtid_mode = ON 8 enforce_gtid_consistency = ON 9 master_info_repository = TABLE 10 relay_log_info_repository = TABLE 11 binlog_checksum = NONE 12 log_slave_updates = ON 13 log-bin = mysql-bin 14 transaction_write_set_extraction = XXHASH64 15 loose-group_replication_group_name = '157be252-2b71-11e6-b8f4-00212889f856' 16 loose-group_replication_start_on_boot = off 17 loose-group_replication_bootstrap_group = off 18 loose-group_replication_local_address = '192.168.153.157:33061' 19 loose-group_replication_group_seeds ='192.168.153.157:33061,192.168.153.158:33061,192.168.153.159:33061' 20 loose-group_replication_single_primary_mode = off 21 loose-group_replication_enforce_update_everywhere_checks = on 22 max_connect_errors = 20000 23 max_connections = 2000 24 wait_timeout = 3600 25 interactive_timeout = 3600 26 net_read_timeout = 3600 27 net_write_timeout = 3600 28 table_open_cache = 1024 29 table_definition_cache = 1024 30 thread_cache_size = 512 31 open_files_limit = 10000 32 character-set-server = utf8 33 collation-server = utf8_bin 34 skip_external_locking 35 performance_schema = 1 36 user = mysql 37 myisam_recover_options = DEFAULT 38 skip-name-resolve 39 local_infile = 0 40 lower_case_table_names = 0 41 42 #--------------------innoDB------------# 43 innodb_buffer_pool_size = 2000M 44 #innodb_data_file_path = ibdata1:200M:autoextend 45 innodb_flush_log_at_trx_commit = 1 46 innodb_io_capacity = 600 47 innodb_lock_wait_timeout = 120 48 innodb_log_buffer_size = 8M 49 innodb_log_file_size = 200M 50 innodb_log_files_in_group = 3 51 innodb_max_dirty_pages_pct = 85 52 innodb_read_io_threads = 8 53 innodb_write_io_threads = 8 54 innodb_support_xa = 1 55 innodb_thread_concurrency = 32 56 innodb_file_per_table 57 innodb_rollback_on_timeout 58 59 #------------session variables-------# 60 join_buffer_size = 8M 61 key_buffer_size = 256M 62 bulk_insert_buffer_size = 8M 63 max_heap_table_size = 96M 64 tmp_table_size = 96M 65 read_buffer_size = 8M 66 sort_buffer_size = 2M 67 max_allowed_packet = 64M 68 read_rnd_buffer_size = 32M 69 70 #------------MySQL Log----------------# 71 log-bin = my3306-bin 72 binlog_format = row 73 sync_binlog = 1 74 expire_logs_days = 15 75 max_binlog_cache_size = 128M 76 max_binlog_size = 500M 77 binlog_cache_size = 64k 78 slow_query_log 79 log-slow-admin-statements 80 log_warnings = 1 81 long_query_time = 0.25 82 83 #---------------replicate--------------# 84 relay-log-index = relay3306.index 85 relay-log = relay3306 86 server-id =157 87 init_slave = 'set sql_mode=STRICT_ALL_TABLES' 88 log-slave-updates 89 [myisamchk] 90 key_buffer = 512M 91 sort_buffer_size = 512M 92 read_buffer = 8M 93 write_buffer = 8M 94 [mysqlhotcopy] 95 interactive-timeout 96 [mysqld_safe] 97 open-files-limit = 8192 98 99 100 # 101 # Remove leading # and set to the amount of RAM for the most important data 102 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. 103 # innodb_buffer_pool_size = 128M 104 # 105 # Remove leading # to turn on a very important data integrity option: logging 106 # changes to the binary log between backups. 107 # log_bin 108 # 109 # Remove leading # to set options mainly useful for reporting servers. 110 # The server defaults are faster for transactions and fast SELECTs. 111 # Adjust sizes as needed, experiment to find the optimal values. 112 # join_buffer_size = 128M 113 # sort_buffer_size = 2M 114 # read_rnd_buffer_size = 2M 115 datadir=/var/lib/mysql 116 socket=/var/lib/mysql/mysql.sock 117 118 # Disabling symbolic-links is recommended to prevent assorted security risks 119 symbolic-links=0 120 121 log-error=/var/log/mysqld.log 122 pid-file=/var/run/mysqld/mysqld.pid View Code

vi /etc/my.cnf (158務(wù)器)

1 # For advice on how to change settings please see 2 # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html 3 4 [mysqld] 5 6 #-------------------gobal variables------------# 7 gtid_mode = ON 8 enforce_gtid_consistency = ON 9 master_info_repository = TABLE 10 relay_log_info_repository = TABLE 11 binlog_checksum = NONE 12 log_slave_updates = ON 13 log-bin = mysql-bin 14 transaction_write_set_extraction = XXHASH64 15 loose-group_replication_group_name = '157be252-2b71-11e6-b8f4-00212889f856' 16 loose-group_replication_start_on_boot = off 17 loose-group_replication_bootstrap_group = off 18 loose-group_replication_local_address = '192.168.153.158:33061' 19 loose-group_replication_group_seeds ='192.168.153.157:33061,192.168.153.158:33061,192.168.153.159:33061' 20 loose-group_replication_single_primary_mode = off 21 loose-group_replication_enforce_update_everywhere_checks = on 22 max_connect_errors = 20000 23 max_connections = 2000 24 wait_timeout = 3600 25 interactive_timeout = 3600 26 net_read_timeout = 3600 27 net_write_timeout = 3600 28 table_open_cache = 1024 29 table_definition_cache = 1024 30 thread_cache_size = 512 31 open_files_limit = 10000 32 character-set-server = utf8 33 collation-server = utf8_bin 34 skip_external_locking 35 performance_schema = 1 36 user = mysql 37 myisam_recover_options = DEFAULT 38 skip-name-resolve 39 local_infile = 0 40 lower_case_table_names = 0 41 42 #--------------------innoDB------------# 43 innodb_buffer_pool_size = 2000M 44 #innodb_data_file_path = ibdata1:200M:autoextend 45 innodb_flush_log_at_trx_commit = 1 46 innodb_io_capacity = 600 47 innodb_lock_wait_timeout = 120 48 innodb_log_buffer_size = 8M 49 innodb_log_file_size = 200M 50 innodb_log_files_in_group = 3 51 innodb_max_dirty_pages_pct = 85 52 innodb_read_io_threads = 8 53 innodb_write_io_threads = 8 54 innodb_support_xa = 1 55 innodb_thread_concurrency = 32 56 innodb_file_per_table 57 innodb_rollback_on_timeout 58 59 #------------session variables-------# 60 join_buffer_size = 8M 61 key_buffer_size = 256M 62 bulk_insert_buffer_size = 8M 63 max_heap_table_size = 96M 64 tmp_table_size = 96M 65 read_buffer_size = 8M 66 sort_buffer_size = 2M 67 max_allowed_packet = 64M 68 read_rnd_buffer_size = 32M 69 70 #------------MySQL Log----------------# 71 log-bin = my3306-bin 72 binlog_format = row 73 sync_binlog = 1 74 expire_logs_days = 15 75 max_binlog_cache_size = 128M 76 max_binlog_size = 500M 77 binlog_cache_size = 64k 78 slow_query_log 79 log-slow-admin-statements 80 log_warnings = 1 81 long_query_time = 0.25 82 83 #---------------replicate--------------# 84 relay-log-index = relay3306.index 85 relay-log = relay3306 86 server-id =158 87 init_slave = 'set sql_mode=STRICT_ALL_TABLES' 88 log-slave-updates 89 [myisamchk] 90 key_buffer = 512M 91 sort_buffer_size = 512M 92 read_buffer = 8M 93 write_buffer = 8M 94 [mysqlhotcopy] 95 interactive-timeout 96 [mysqld_safe] 97 open-files-limit = 8192 98 99 100 # 101 # Remove leading # and set to the amount of RAM for the most important data 102 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. 103 # innodb_buffer_pool_size = 128M 104 # 105 # Remove leading # to turn on a very important data integrity option: logging 106 # changes to the binary log between backups. 107 # log_bin 108 # 109 # Remove leading # to set options mainly useful for reporting servers. 110 # The server defaults are faster for transactions and fast SELECTs. 111 # Adjust sizes as needed, experiment to find the optimal values. 112 # join_buffer_size = 128M 113 # sort_buffer_size = 2M 114 # read_rnd_buffer_size = 2M 115 datadir=/var/lib/mysql 116 socket=/var/lib/mysql/mysql.sock 117 118 # Disabling symbolic-links is recommended to prevent assorted security risks 119 symbolic-links=0 120 121 log-error=/var/log/mysqld.log 122 pid-file=/var/run/mysqld/mysqld.pid View Code

vi /etc/my.cnf (159務(wù)器)

1 # For advice on how to change settings please see 2 # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html 3 4 [mysqld] 5 6 #-------------------gobal variables------------# 7 gtid_mode = ON 8 enforce_gtid_consistency = ON 9 master_info_repository = TABLE 10 relay_log_info_repository = TABLE 11 binlog_checksum = NONE 12 log_slave_updates = ON 13 log-bin = mysql-bin 14 transaction_write_set_extraction = XXHASH64 15 loose-group_replication_group_name = '157be252-2b71-11e6-b8f4-00212889f856' 16 loose-group_replication_start_on_boot = off 17 loose-group_replication_bootstrap_group = off 18 loose-group_replication_local_address = '192.168.153.159:33061' 19 loose-group_replication_group_seeds ='192.168.153.157:33061,192.168.153.158:33061,192.168.153.159:33061' 20 loose-group_replication_single_primary_mode = off 21 loose-group_replication_enforce_update_everywhere_checks = on 22 max_connect_errors = 20000 23 max_connections = 2000 24 wait_timeout = 3600 25 interactive_timeout = 3600 26 net_read_timeout = 3600 27 net_write_timeout = 3600 28 table_open_cache = 1024 29 table_definition_cache = 1024 30 thread_cache_size = 512 31 open_files_limit = 10000 32 character-set-server = utf8 33 collation-server = utf8_bin 34 skip_external_locking 35 performance_schema = 1 36 user = mysql 37 myisam_recover_options = DEFAULT 38 skip-name-resolve 39 local_infile = 0 40 lower_case_table_names = 0 41 42 #--------------------innoDB------------# 43 innodb_buffer_pool_size = 2000M 44 #innodb_data_file_path = ibdata1:200M:autoextend 45 innodb_flush_log_at_trx_commit = 1 46 innodb_io_capacity = 600 47 innodb_lock_wait_timeout = 120 48 innodb_log_buffer_size = 8M 49 innodb_log_file_size = 200M 50 innodb_log_files_in_group = 3 51 innodb_max_dirty_pages_pct = 85 52 innodb_read_io_threads = 8 53 innodb_write_io_threads = 8 54 innodb_support_xa = 1 55 innodb_thread_concurrency = 32 56 innodb_file_per_table 57 innodb_rollback_on_timeout 58 59 #------------session variables-------# 60 join_buffer_size = 8M 61 key_buffer_size = 256M 62 bulk_insert_buffer_size = 8M 63 max_heap_table_size = 96M 64 tmp_table_size = 96M 65 read_buffer_size = 8M 66 sort_buffer_size = 2M 67 max_allowed_packet = 64M 68 read_rnd_buffer_size = 32M 69 70 #------------MySQL Log----------------# 71 log-bin = my3306-bin 72 binlog_format = row 73 sync_binlog = 1 74 expire_logs_days = 15 75 max_binlog_cache_size = 128M 76 max_binlog_size = 500M 77 binlog_cache_size = 64k 78 slow_query_log 79 log-slow-admin-statements 80 log_warnings = 1 81 long_query_time = 0.25 82 83 #---------------replicate--------------# 84 relay-log-index = relay3306.index 85 relay-log = relay3306 86 server-id =159 87 init_slave = 'set sql_mode=STRICT_ALL_TABLES' 88 log-slave-updates 89 [myisamchk] 90 key_buffer = 512M 91 sort_buffer_size = 512M 92 read_buffer = 8M 93 write_buffer = 8M 94 [mysqlhotcopy] 95 interactive-timeout 96 [mysqld_safe] 97 open-files-limit = 8192 98 99 100 # 101 # Remove leading # and set to the amount of RAM for the most important data 102 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. 103 # innodb_buffer_pool_size = 128M 104 # 105 # Remove leading # to turn on a very important data integrity option: logging 106 # changes to the binary log between backups. 107 # log_bin 108 # 109 # Remove leading # to set options mainly useful for reporting servers. 110 # The server defaults are faster for transactions and fast SELECTs. 111 # Adjust sizes as needed, experiment to find the optimal values. 112 # join_buffer_size = 128M 113 # sort_buffer_size = 2M 114 # read_rnd_buffer_size = 2M 115 datadir=/var/lib/mysql 116 socket=/var/lib/mysql/mysql.sock 117 118 # Disabling symbolic-links is recommended to prevent assorted security risks 119 symbolic-links=0 120 121 log-error=/var/log/mysqld.log 122 pid-file=/var/run/mysqld/mysqld.pid View Code

三、配置 group_replication

組內(nèi)每臺(tái)主機(jī),都需要先安裝組復(fù)制插件.否則會(huì)導(dǎo)致啟動(dòng)失敗.
?mysql>INSTALL PLUGIN group_replication SONAME 'group_replication.so';?

1.server157:

1 mysql>GRANT REPLICATION SLAVE ON *.* TO 'repl'@'192.168.153.%' IDENTIFIED BY 'RKYSrkys123!@#'; 2 mysql>CHANGE MASTER TO MASTER_USER='repl',MASTER_PASSWORD='RKYSrkys123!@#' FOR CHANNEL 'group_replication_recovery'; 3 mysql>set global group_replication_ip_whitelist="127.0.0.1/32,192.168.153.0/24"; 4 mysql>SET GLOBAL group_replication_bootstrap_group = ON; 5 mysql>START GROUP_REPLICATION; 6 mysql>SET GLOBAL group_replication_bootstrap_group = OFF;

?2.server158、159:

1 mysql>CHANGE MASTER TO MASTER_USER='repl',MASTER_PASSWORD='RKYSrkys123!@#' FOR mysql>CHANNEL 'group_replication_recovery'; 2 mysql>set global group_replication_ip_whitelist="127.0.0.1/32,192.168.153.0/24"; 3 mysql>set global group_replication_allow_local_disjoint_gtids_join=ON; 4 mysql>START GROUP_REPLICATION;

?3.查看SELECT * FROM performance_schema.replication_group_members;

server157、158、159上都執(zhí)行SQL語句查看組狀態(tài)
mysql> SELECT * FROM performance_schema.replication_group_members; +---------------------------+--------------------------------------+-------------+-------------+--------------+ | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | +---------------------------+--------------------------------------+-------------+-------------+--------------+ | group_replication_applier | c8a5168d-2103-11e8-a3e1-000c29cb1157 | mgr157 | 3306 | ONLINE | | group_replication_applier | c8a5168d-2103-11e8-a3e1-000c29cb1159 | mgr159 | 3306 | ONLINE | | group_replication_applier | c8a5168d-2103-11e8-a3e1-000c29cb1ae2 | mgr158 | 3306 | ONLINE | +---------------------------+--------------------------------------+-------------+-------------+--------------+
online代表已經(jīng)設(shè)置成功。

四、檢驗(yàn):

1: server157、158、159(分別創(chuàng)建test157、test158和test159測試)

server157上: mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec)mysql> create database test157; Query OK, 1 row affected (0.04 sec)mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | test157 | +--------------------+ 5 rows in set (0.00 sec) server158上: mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys |
| test157       | +--------------------+ 5 rows in set (0.02 sec)mysql> create database test158; Query OK, 1 row affected (0.04 sec)mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | test157 | | test158 | +--------------------+ 6 rows in set (0.00 sec) server159上: mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys |
| test157       |
| test158       |
+--------------------+ 6 rows in set (0.00 sec)mysql> create database test159; Query OK, 1 row affected (0.05 sec)mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | test157 | | test158 | | test159 | +--------------------+ 7 rows in set (0.00 sec)

在server157、158上也分別驗(yàn)證:
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | test157 | | test158 | | test159 | +--------------------+

2:模擬宕機(jī)一個(gè)節(jié)點(diǎn)驗(yàn)證

(1)關(guān)閉159的數(shù)據(jù)庫實(shí)例
  service mysqld stop
(2)在157節(jié)點(diǎn)操作
查詢組成員,發(fā)現(xiàn)159已不在組中?

mysql> SELECT * FROM performance_schema.replication_group_members; +---------------------------+--------------------------------------+-------------+-------------+--------------+ | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | +---------------------------+--------------------------------------+-------------+-------------+--------------+ | group_replication_applier | c8a5168d-2103-11e8-a3e1-000c29cb1157 | mgr157 | 3306 | ONLINE | | group_replication_applier | c8a5168d-2103-11e8-a3e1-000c29cb1ae2 | mgr158 | 3306 | ONLINE | +---------------------------+--------------------------------------+-------------+-------------+--------------+ 2 rows in set (0.00 sec)

?(3)寫入數(shù)據(jù)

server157,158,159上:
mysql> use test157 Database changed mysql> show tables; Empty set (0.00 sec)mysql> CREATE TABLE tb1(id int not null primary key); Query OK, 0 rows affected (0.41 sec)server157,158上:
mysql
> show tables; +-------------------+ | Tables_in_test157 | +-------------------+ | tb1 | +-------------------+ 1 row in set (0.01 sec)


server159上: mysql> show tables; Empty set (0.00 sec)

(4)啟動(dòng)159的數(shù)據(jù)庫

#修改配置文件,自動(dòng)啟動(dòng)組復(fù)制
#loose-group_replication_start_on_boot = on
#group_replication_allow_local_disjoint_gtids_join = on?

mysql> STOP GROUP_REPLICATION; Query OK, 0 rows affected (9.30 sec)

(5)再次查看組成員,發(fā)現(xiàn)159已重新加入組

mysql> SELECT * FROM performance_schema.replication_group_members; +---------------------------+--------------------------------------+-------------+-------------+--------------+ | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | +---------------------------+--------------------------------------+-------------+-------------+--------------+ | group_replication_applier | c8a5168d-2103-11e8-a3e1-000c29cb1157 | mgr157 | 3306 | ONLINE | | group_replication_applier | c8a5168d-2103-11e8-a3e1-000c29cb1159 | mgr159 | 3306 | ONLINE | | group_replication_applier | c8a5168d-2103-11e8-a3e1-000c29cb1ae2 | mgr158 | 3306 | ONLINE | +---------------------------+--------------------------------------+-------------+-------------+--------------+ 3 rows in set (0.00 sec)

(6)查看數(shù)據(jù),發(fā)現(xiàn)數(shù)據(jù)已同步

在server157、158、159上: mysql> show tables; +-------------------+ | Tables_in_test157 | +-------------------+ | tb1 | +-------------------+ 1 row in set (0.01 sec)

?到此,已完畢。

?

######################################################################################################################?

附:參考資料

#[client]
#port = 3306
#socket = /usr/local/mysql/tmp/mysql.sock

[mysqld]
#port = 3306
#socket = /usr/local/mysql/tmp/mysql.sock
back_log = 80
basedir = /usr/local/mysql
tmpdir = /tmp
datadir = /usr/local/mysql/data

#-------------------gobal variables------------#
gtid_mode = ON
enforce_gtid_consistency = ON
master_info_repository = TABLE
relay_log_info_repository = TABLE
binlog_checksum = NONE
log_slave_updates = ON
log-bin = /usr/local/mysql/log/mysql-bin
transaction_write_set_extraction = XXHASH64 #以便在server收集寫集合的同時(shí)將其記錄到二進(jìn)制日志。寫集合基于每行的主鍵,并且是行更改后的唯一標(biāo)識(shí)此標(biāo)識(shí)將用于檢測沖突。
loose-group_replication_group_name = 'ce9be252-2b71-11e6-b8f4-00212889f856' #組的名字可以隨便起,但不能用主機(jī)的GTID(為mgr高可用組起一個(gè)名字,這個(gè)名字一定要是uuid格式的。)【此處三臺(tái)一致】
loose-group_replication_start_on_boot = off #為了避免每次啟動(dòng)自動(dòng)引導(dǎo)具有相同名稱的第二個(gè)組,所以設(shè)置為OFF。
loose-group_replication_bootstrap_group = off #同上
loose-group_replication_local_address = '192.168.153.157:33061' 【三臺(tái)分別是192.168.153.157:33061/192.168.153.158:33061/192.168.153.159:33061】 #寫自己主機(jī)所在IP(mgr各實(shí)例之前都是要進(jìn)行通信的、這個(gè)配置項(xiàng)設(shè)置的就是本實(shí)例所監(jiān)聽的ip:端口)
loose-group_replication_group_seeds ='192.168.153.157:33061,192.168.153.158:33061,192.168.153.159:33061' #(各mgr實(shí)例所監(jiān)聽的ip:端口信息) 【三臺(tái)一致】
loose-group_replication_single_primary_mode = off #關(guān)閉單主模式的參數(shù)
loose-group_replication_enforce_update_everywhere_checks = on #開啟多主模式的參數(shù)
max_connect_errors = 20000 #max_connect_errors是一個(gè)MySQL中與安全有關(guān)的計(jì)數(shù)器值,它負(fù)責(zé)阻止過多嘗試失敗的客戶端以防止暴力破解密碼的情況。max_connect_errors的值與性能并無太大關(guān)系。默認(rèn)情況下,my.cnf文件中可能沒有此行,如果需要設(shè)置此數(shù)值,手動(dòng)添加即可。
max_connections = 2000
wait_timeout = 3600
interactive_timeout = 3600
net_read_timeout = 3600
net_write_timeout = 3600
table_open_cache = 1024
table_definition_cache = 1024
thread_cache_size = 512
open_files_limit = 10000
character-set-server = utf8
collation-server = utf8_bin
skip_external_locking
performance_schema = 1
user = mysql
myisam_recover_options = DEFAULT
skip-name-resolve
local_infile = 0
lower_case_table_names = 0?
#lower_case_table_names: 此參數(shù)不可以動(dòng)態(tài)修改,必須重啟數(shù)據(jù)庫
#lower_case_table_names = 1 表名存儲(chǔ)在磁盤是小寫的,但是比較的時(shí)候是不區(qū)分大小寫
#lower_case_table_names=0 表名存儲(chǔ)為給定的大小和比較是區(qū)分大小寫的?
#lower_case_table_names=2, 表名存儲(chǔ)為給定的大小寫但是比較的時(shí)候是小寫的


#--------------------innoDB------------#
innodb_buffer_pool_size = 2000M
#innodb_data_file_path = ibdata1:200M:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_io_capacity = 600
innodb_lock_wait_timeout = 120
innodb_log_buffer_size = 8M
innodb_log_file_size = 200M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 85
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_support_xa = 1
innodb_thread_concurrency = 32
innodb_file_per_table
innodb_rollback_on_timeout

#------------session variables-------#
join_buffer_size = 8M
key_buffer_size = 256M
bulk_insert_buffer_size = 8M
max_heap_table_size = 96M
tmp_table_size = 96M
read_buffer_size = 8M
sort_buffer_size = 2M
max_allowed_packet = 64M
read_rnd_buffer_size = 32M

#------------MySQL Log----------------#
log-bin = my3306-bin
binlog_format = row #組復(fù)制依賴基于行的復(fù)制格式
sync_binlog = 1
expire_logs_days = 15
max_binlog_cache_size = 128M
max_binlog_size = 500M
binlog_cache_size = 64k
slow_query_log
log-slow-admin-statements
log_warnings = 1
long_query_time = 0.25

#---------------replicate--------------#
relay-log-index = relay3306.index
relay-log = relay3306
server-id =157 #【每個(gè)db的id唯一】
init_slave = 'set sql_mode=STRICT_ALL_TABLES'
log-slave-updates
[myisamchk]
key_buffer = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
#log-error = /usr/local/mysql/log/mysqld_error.log
######################################################################################################################

轉(zhuǎn)載于:https://www.cnblogs.com/ctulzq/p/8631097.html

總結(jié)

以上是生活随笔為你收集整理的MySQL5.7 Group Replication (MGR)--Mysql的组复制之多主模式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。