In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "MySQL8.0 MIC high availability cluster building process", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "the construction process of MySQL 8.0 MIC high availability cluster"!
1. Cluster deployment
1.1 Installation environment;
Operating System: Linux, Version: CentOS-7-x86
Media preparation: None
environmental clean-up
Release the yum process
[root@bug ~]# ps -ef|grep yum root 22481 1694 5 17:23 ? 00:00:03 /usr/bin/python /usr/share/PackageKit/helpers/yum/yumBackend.py get-updates none root 22591 22507 1 17:24 pts/ 00:00:00 grep --color=auto yum [root@bug ~]# kill -9 22481
Check if there are redundant systems and uninstall if there are
1
2
[root@bug ~]# rpm -qa|grep mairadb
[root@bug ~]# rpm -qa|grep mysql
turn off the firewall
1
2
3
4
[root@bug ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Turn off selinux and restart the system to take effect
[root@bug selinux]# vi /etc/selinux/config SELINUX=disabled
[root@bug selinux]# reboot
1.2 Install MySQL 8.0
1
2
3
[root@bug ~]# yum install -y wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
[root@bug ~]# yum list|grep mysql
[root@bug ~]# yum install -y mysql-community-client.x86_64 mysql-router.x86_64 mysql-shell.x86_64
Using YUM source installation method, the total download volume is about 400M,
1.3 Automated cluster deployment
Deployment Node 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@bug ~]# mysqlsh
MySQL JS > dba.deploySandboxInstance(3310);
A new MySQL sandbox instance will be created on this host in
/root/mysql-sandboxes/3310
Warning: Sandbox instances are only suitable for deploying and
running on your local machine for testing purposes and are not
accessible from external networks.
Please enter a MySQL root password for the new instance: ******
Deploying new MySQL instance...
Instance localhost:3310 successfully deployed and started.
Use shell.connect('root@localhost:3310'); to connect to the instance.
The deployment of the first node is complete, port is set to 3310, login account is root@localhost, password *****
Log in to the database instance using local authentication to verify.
1
2
3
[root@bug ~]# mysql -uroot -porange -S /root/mysql-sandboxes/3310/sandboxdata/mysqld.sock
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
The same way, deploy Node 2 and Node 3.
1
2
3
MySQL JS > dba.deploySandboxInstance(3320);
MySQL JS > dba.deploySandboxInstance(3330);
1.4 creating a cluster
This lab uses a simple method of creating a local cluster.
1
2
3
4
5
6
7
8
9
10
11
12
MySQL JS > \connect root@localhost:3310
Creating a session to 'root@localhost:3310'
*****************************************************
MySQL localhost:3310 ssl JS > var cluster=dba.createCluster('test')
A new InnoDB cluster will be created on instance 'root@localhost:3310'.
*********************************************************
Cluster successfully created. Use Cluster.addInstance() to add MySQL instances.
At least 3 instances are needed for the cluster to be able to withstand up to
one server failure.
At least 3 instances are needed for the cluster to be able to stand up to one server failure.
1
2
3
4
5
6
7
8
MySQL localhost:3310 ssl JS > cluster.addInstance( 'root@localhost:3320')
The instance 'root@localhost:3320' was successfully added to the cluster.
MySQL localhost:3310 ssl JS > cluster.addInstance( 'root@localhost:3330')
The instance 'root@localhost:3330' was successfully added to the cluster.
View Cluster Status
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
MySQL localhost:3310 ssl JS > dba.getCluster().status()
{
"clusterName": "test",
"defaultReplicaSet": {
"name": "default",
"primary": "localhost:3310",
"ssl": "REQUIRED",
"status": "OK",
"statusText": "Cluster is ONLINE and can tolerate up to ONE failure. ",
"topology": {
"localhost:3310": {
"address": "localhost:3310",
"mode": "R/W",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
},
"localhost:3320": {
"address": "localhost:3320",
"mode": "R/O",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
},
"localhost:3330": {
"address": "localhost:3330",
"mode": "R/O",
"readReplicas": {},
"role": "HA",
"status": "ONLINE"
}
}
},
"groupInformationSourceMember": "mysql://root@localhost:3310"
}
A simple three-node cluster has been created. It can complete data synchronization, read and write separation and other functions. For example, at this moment, the state of port 3310 is "R/W", read and write at the same time, and the state of 3320 and 3330 is "R/O", read-only mode.
1.5 Configure middleware
At this time, the high availability of the cluster is not complete, and MySQL-router is needed to complete the connection between the cluster and the outside, and realize automatic switching, failover and other functions.
MySQL-router acts like keepalived middleware. When the host fails, the application is automatically switched to another instance.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@bug ~]# mysqlrouter --bootstrap root@localhost:3310 --user=mysqlrouter
Please enter MySQL password for root: *****
Bootstrapping system MySQL Router instance...
Checking for old Router accounts
Creating account mysql_router2_j05xzi45m81x@'%'
MySQL Router has now been configured for the InnoDB cluster 'test'.
The following connection information can be used to connect to the cluster.
Classic MySQL protocol connections to cluster 'test':
- Read/Write Connections: localhost:6446
- Read/Only Connections: localhost:6447
X protocol connections to cluster 'test':
- Read/Write Connections: localhost:64460
- Read/Only Connections: localhost:64470
Existing configurations backed up to '/etc/mysqlrouter/mysqlrouter.conf.bak'
[root@bug ~]# mysqlrouter&
[1] 25602
[root@bug ~]# ps -ef|grep router
mysqlro+ 25602 22507 8 19:35 pts/0 00:00:01 mysqlrouter
root 25619 22507 0 19:36 pts/0 00:00:00 grep --color=auto router
Verify MySQL-router installation
In the default configuration of MySQL router,
Host port: 6446
Slave port: 6447
1
2
3
4
5
[root@bug ~]# mysql -uroot -h 127.0.0.1 -P 6446 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
********************************************************8
mysql>
Prove that MySQL-router configuration is complete and available.
1.6 Verify cluster effect
1. Log in to three nodes at the same time through router to view the port number.
2. Construct the data at node 1, and compare the status at nodes 2 and 3 to verify data synchronization.
3. Node 1 (host) is offline, check cluster status and node 2, node 3 status, verify disaster recovery capability.
At this point, I believe everyone has a deeper understanding of the "MySQL 8.0 MIC high availability cluster building process," may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.