Install and configure a MySQL database cluster for Load Balancing

Source: Internet
Author: User

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:

 
 
  1. # Cp/usr/local/mysql/support-files/my-medium.cnf/etc/my. cnf
  2.  
  3. # Vi/etc/my. cnf Add at the end of the file # my. cnf
  4.  
  5. # Example additions to my. cnf for MySQL Cluster
  6.  
  7. # (Valid in MySQL 5.0) # enable ndbcluster storage engine, and provide connectstring
  8.  
  9. # Management Server host (default port is 1186)
  10.  
  11. [Mysqld]
  12.  
  13. Ndbcluster
  14.  
  15. Ndb-connectstring = 192.168.56.30 # provide connectstring for management Server host (default port: 1186)
  16.  
  17. [Ndbd]
  18.  
  19. Connect-string = 192.168.56.30 # provide connectstring for management Server host (default port: 1186)
  20.  
  21. [Ndb_mgm]
  22.  
  23. Connect-string = 192.168.56.30 # provide location of cluster configuration file
  24.  
  25. [Ndb_mgmd]
  26.  
  27. Config-file =/var/lib/mysql-cluster

Create A log folder on Node A and Node B

 
 
  1. # mkdir /var/lib/mysql-cluster  

3. Configure ndb_mgmd:

 
 
  1. # mkdir /var/lib/mysql-cluster  
  2.  
  3. # cd /var/lib/mysql-cluster  
  4.  
  5. # vi config.ini # file "config.ini" - 2 data nodes and 2 SQL nodes  
  6.  
  7. # This file is placed in the startup directory of ndb_mgmd (the  
  8.  
  9. # management server)  
  10.  
  11. # The first MySQL Server can be started from any host. The second  
  12.  
  13. # can be started only on the host mysqld_5.mysql.com [NDBD DEFAULT]  
  14.  
  15. NoOfReplicas= 2 
  16.  
  17. DataDir= /var/lib/mysql-cluster [NDB_MGMD]  
  18.  
  19. Hostname= 192.168.56.30  
  20.  
  21. DataDir= /var/lib/mysql-cluster [NDBD]  
  22.  
  23. HostName= 192.168.56.11 [NDBD]  
  24.  
  25. HostName= 192.168.56.12[MYSQLD]  
  26.  
  27. [MYSQLD]  
  28.  
  29. [MYSQLD] 

4. Start the service

 
 
  1. Ndb_mgmd/usr/local/mysql/bin/ndb_mgmd-f/var/lib/mysql-cluster/config. ini
  2.  
  3. Node A/usr/local/mysql/bin/ndbd -- initial # Use the -- initial Parameter only when ndbd is started for the first time
  4.  
  5. Node B/usr/local/mysql/bin/ndbd -- initial
  6.  
  7. 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

 
 
  1. Ndb_mgm> show
  2.  
  3. Cluster Configuration [ndbd (NDB)] 2 node (s)
  4.  
  5. Id = 2 (not connected, accepting connect from 192.168.56.11)
  6.  
  7. Id = 3 @ 192.168.56.12 (Version: 5.0.22, Nodegroup: 0, Master) [ndb_mgmd (MGM)] 1 node (s)
  8.  
  9. Id = 1 @ 192.168.56.30 (Version: 5.0.22) [mysqld (API)] 3 node (s)
  10.  
  11. Id = 4 @ 192.168.56.20 (Version: 5.0.22)
  12.  
  13. Id = 5 (not connected, accepting connect from any host)
  14.  
  15. 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 ):
  16.  
  17. #/Usr/local/mysql/bin/mysql
  18.  
  19. > Use test;
  20.  
  21. > Create table ctest (I INT) ENGINE = NDBCLUSTER;
  22.  
  23. > 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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.