Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create nodes of MySQL Group Replication dynamically

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "how to dynamically create MySQL Group Replication nodes", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to dynamically create MySQL Group Replication nodes" this article.

Let's start with two configuration files. This file is the core of dynamic building, each node's port number, node coding (custom), whether the master node and so on are identified one by one.

[root@grtest data] # cat init.lst

24801 s1 24901 Y

24802 s2 24902 N

24803 s3 24903 N

24804 s4 24904 N

24805 s5 24905 N

24806 s6 24906 N

24807 s7 24907 N

24808 s8 24908 N

24809 S9 24909 N is followed by the parameter file, in which the dynamic part uses variables to achieve the effect of dynamic replacement.

[root@grtest data] # cat s.cnf

[mysqld]

# server configuration

Datadir=$ {base_data_dir} / ${node_name}

Basedir=$ {base_dir}

Port=$ {port}

Socket=$ {base_data_dir} / ${node_name} / ${node_name} .sock

Server_id=$ {port}

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=binlog

Binlog_format=ROW

Transaction_write_set_extraction=XXHASH64

Loose-group_replication_group_name= "1bb1b861-f776-11e6-be42-782bcb377193"

Loose-group_replication_start_on_boot=off

Loose-group_replication_local_address= "127.0.0.1 ${v_port}"

Loose-group_replication_group_seeds= "${seed_list}"

The difficulty in loose-group_replication_bootstrap_group= off is that the parameter group_replication_group_seeds= takes some effort to spell out.

Apart from that, there are no other configuration files, just go directly to our core script.

Get_seed_list is the value of the special processing parameter group_replication_group_seeds, and init_node is used to initialize each node.

Base_dir=/usr/local/mysql

Base_data_dir=/home/mysql/data

Function get_seed_list

{

While read line

Do

Tmp_port='127.0.0.1:' `echo $line | awk'{print $3}'`

Echo ${tmp_port}

Done

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report