In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "the operation of MySQL database cluster". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the operation of MySQL database cluster.
MySQL cluster with 2 servers. And the implementation of any server problems or downtime when the MySQL can continue to run.
2MySQL2MySQL3VMWare
three
Server2MySQLServer3Server3MySQLServer3Server3
Install MySQL on Server1 and Server2
[url] http://www.mysql.com[/url]mysql-max-4.1.9-pc-linux-gnu-i686.tar.gzmaxMySQLStandardServer1Server2
Install and configure the management node server (Server3)
= = as a management node server, Server3 requires two files, ndb_mgm and ndb_mgmd: download mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz from [url] http://www.mysql.com[/url]
# mkdir / usr/src/mysql-mgm
# cd / usr/src/mysql-mgm
# tar-zxvf mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz
# rm mysql-max-4.1.9-pc-linux-gnu-i686.tar.gz
# cd mysql-max-4.1.9-pc-linux-gnu-i686
# mv bin/ndb_mgm.
# mv bin/ndb_mgmd.
# chmod + x ndb_mg*
# mv ndb_mg* / usr/bin/
# cd
# rm-rf / usr/src/mysql-mgm now starts to create a configuration file for this management node server:
# mkdir / var/lib/mysql-cluster
# cd / var/lib/mysql-cluster
# vi config.ini add the following to config.ini:
[NDBD DEFAULT]
NoOfReplicas=2
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# Managment Server
[NDB_MGMD]
HostName=192.168.0.3 # IP address of the management node server Server3
# Storage Engines
[NDBD]
HostName=192.168.0.1 # IP address of the MySQL cluster Server1
DataDir= / var/lib/mysql-cluster
[NDBD]
HostName=192.168.0.2 # IP address of the MySQL cluster Server2
DataDir=/var/lib/mysql-cluster
# the following two [MYSQLD] can enter the hostnames of Server1 and Server2.
# however, in order to replace the servers in the cluster more quickly, it is recommended to leave it blank, otherwise the configuration must be changed after the server is replaced.
[MYSQLD]
[MYSQLD] after saving and exiting, start the management node server Server3:
After # ndb_mgmd starts the management node, you should note that this is only the management node service, not the management terminal. So you don't see any information about the output after startup.
Configure the cluster server and start MySQL
= = the following changes are required in both Server1 and Server2:
# vi / etc/my.cnf
[mysqld]
Ndbcluster
IP address of ndb-connectstring=192.168.0.3 # Server3
[mysql_cluster]
After saving and exiting the IP address of ndb-connectstring=192.168.0.3 # Server3, set up the data directory and start MySQL:
# mkdir / var/lib/mysql-cluster
# cd / var/lib/mysql-cluster
# / usr/local/mysql/bin/ndbd-initial
# / etc/rc.d/init.d/mysqld start can add / usr/local/mysql/bin/ndbd to / etc/rc.local to boot. Note: you need to use the-- initial parameter only when you start ndbd for the first time or after making changes to Server3's config.ini!
5. Check the working status
= return to the management node server Server3 and start the management terminal:
# / usr/bin/ndb_mgm Type the show command to view the current working status: (the following is an example of status output)
[root@mysql3 root] # / usr/bin/ndb_mgm
-NDB Cluster-Management Client--
Ndb_mgm > show
Connected to Management Server at: localhost:1186
Cluster Configuration
-
[ndbd (NDB)] 2 node (s)
Id=2 @ 192.168.0.1 (Version: 4.1.9, Nodegroup: 0, Master)
Id=3 @ 192.168.0.2 (Version: 4.1.9, Nodegroup: 0)
[ndb_mgmd (MGM)] 1 node (s)
Id=1 @ 192.168.0.3 (Version: 4.1.9)
[mysqld (API)] 2 node (s)
Id=4 (Version: 4.1.9)
Id=5 (Version: 4.1.9)
Ndb_mgm >
If there is no problem above, now start testing MySQL: note that this document does not set the root password for MySQL, it is recommended that you set your own MySQL root password for Server1 and Server2. In Server1:
# / usr/local/mysql/bin/mysql-u root-p
> use test
> CREATE TABLE ctest (I INT) ENGINE=NDBCLUSTER
> INSERT INTO ctest () VALUES (1)
> SELECT * FROM ctest; should be able to see the 1 row returned message (return value 1). If the above is normal, switch to Server2 and repeat the above test to observe the effect. If successful, perform INSERT in Server2 and switch back to Server1 to see if it works properly. If there is no problem, then congratulations on your success! VI. Destructive testing
= unplug the network cable from Server1 or Server2 and see if another cluster server is working properly (you can use SELECT query to test). After the test, reinsert the network cable. If you do not have access to the physical server, which means you cannot unplug the network cable, you can also test it like this: on Server1 or Server2:
# ps aux | grep ndbd will see all ndbd process information:
Root 5578 0.0 0.3 6220 1964? S 03:14 0:00 ndbd
Root 5579 0.0 20.4 492072 102828? R 03:14 0:04 ndbd
Root 23532 0.0 0.1 3680 684 pts/1 S 07:59 0:00 grep ndbd and then kill a ndbd process for the purpose of destroying the MySQL cluster server:
# kill-9 5578 5579 and then test with SELECT queries on another clustered server. And execute the show command in the management terminal of the management node server to see the status of the corrupted server. After the test is complete, simply restart the ndbd process of the corrupted server:
# ndbd attention! As mentioned earlier, there is no need to add the-- inital parameter at this time! At this point, the MySQL cluster is configured! At this point, I believe that you have a deeper understanding of "MySQL database cluster operation", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow 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.