This article mainly introducesMySQL Database ClusterImplementationServer Load balancerNext, let's take a look at this part of content.
The MySQL Database Cluster relationship is as follows:
Ndbd: the actual storage location of the database node and physical data.
Mysqld: MySQL server node.
Ndbd_mgmd: Management node. Manage/view the status of each database node and server node. The program directly accesses the IP address of this machine. The default port number is 3306.
1. Install MySQL5.0 on ndb_mgmd, mysqld, Node A, and Node B
Installation Directory:/usr/local/mysql
2. Configure Node A, Node B, and mysqld:
- # Cp/usr/local/mysql/support-files/my-medium.cnf/etc/my. cnf
-
- # Vi/etc/my. cnf Add at the end of the file # my. cnf
-
- # Example additions to my. cnf for MySQL Cluster
-
- # (Valid in MySQL 5.0) # enable ndbcluster storage engine, and provide connectstring
-
- # Management Server host (default port is 1186)
-
- [Mysqld]
-
- Ndbcluster
-
- Ndb-connectstring = 192.168.56.30 # provide connectstring for management Server host (default port: 1186)
-
- [Ndbd]
-
- Connect-string = 192.168.56.30 # provide connectstring for management Server host (default port: 1186)
-
- [Ndb_mgm]
-
- Connect-string = 192.168.56.30 # provide location of cluster configuration file
-
- [Ndb_mgmd]
-
- Config-file =/var/lib/mysql-cluster
Create A log folder on Node A and Node B
- # mkdir /var/lib/mysql-cluster
3. Configure ndb_mgmd:
- # mkdir /var/lib/mysql-cluster
-
- # cd /var/lib/mysql-cluster
-
- # vi config.ini # file "config.ini" - 2 data nodes and 2 SQL nodes
-
- # This file is placed in the startup directory of ndb_mgmd (the
-
- # management server)
-
- # The first MySQL Server can be started from any host. The second
-
- # can be started only on the host mysqld_5.mysql.com [NDBD DEFAULT]
-
- NoOfReplicas= 2
-
- DataDir= /var/lib/mysql-cluster [NDB_MGMD]
-
- Hostname= 192.168.56.30
-
- DataDir= /var/lib/mysql-cluster [NDBD]
-
- HostName= 192.168.56.11 [NDBD]
-
- HostName= 192.168.56.12[MYSQLD]
-
- [MYSQLD]
-
- [MYSQLD]
4. Start the service
- Ndb_mgmd/usr/local/mysql/bin/ndb_mgmd-f/var/lib/mysql-cluster/config. ini
-
- Node A/usr/local/mysql/bin/ndbd -- initial # Use the -- initial Parameter only when ndbd is started for the first time
-
- Node B/usr/local/mysql/bin/ndbd -- initial
-
- Check the working status of mysqld/usr/local/mysql/support-files/mysql. server start
Return to the management node server Ndb_mgmd and start the Management Terminal: #/usr/bin/ndb_mgm
- Ndb_mgm> show
-
- Cluster Configuration [ndbd (NDB)] 2 node (s)
-
- Id = 2 (not connected, accepting connect from 192.168.56.11)
-
- Id = 3 @ 192.168.56.12 (Version: 5.0.22, Nodegroup: 0, Master) [ndb_mgmd (MGM)] 1 node (s)
-
- Id = 1 @ 192.168.56.30 (Version: 5.0.22) [mysqld (API)] 3 node (s)
-
- Id = 4 @ 192.168.56.20 (Version: 5.0.22)
-
- Id = 5 (not connected, accepting connect from any host)
-
- Id = 6 (not connected, accepting connect from any host) mysqld (API) is mysqld -- ndb-cluster, MySQL server node, IP address that should be accessed by the program. Create a database mysqld ):
-
- #/Usr/local/mysql/bin/mysql
-
- > Use test;
-
- > Create table ctest (I INT) ENGINE = NDBCLUSTER;
-
- > Insert into ctest () VALUES (1 );
The configuration of MySQL Database Cluster Server Load balancer is introduced here. I hope this introduction will be helpful to you!