MySQL cluster installation and configuration

Source: Internet
Author: User

MySQL cluster installation and configuration article directory[Hide]
    • One, MySQL cluster installation
    • Second, node configuration
    • Third, start the node for the first time
    • Iv. Testing the service is normal
    • V. Secure shutdown and restart

MySQL Cluster is a high-utility, high-redundancy version of MySQL suitable for distributed computing environments. It employs the NDB Cluster storage engine, allowing multiple MySQL servers to run in 1 Cluster. MySQL Cluster is able to configure the NDB storage engine with multiple failover and load balancing options, but this is easiest to do on the storage engine at the Cluster level. Below we briefly describe how MySQL cluster is installed and configured.
Basic settings
Management (MGM) node: 192.168.0.111
MySQL server (SQL) node: 192.168.0.110
Data (NDBD) node "A": 192.168.0.112
Data (NDBD) node "B": 192.168.0.113

One, MySQL cluster installation

MySQL cluster installation can be three ways, one is to directly download binary use, the second is to use the RPM installation, the third is the source code compilation. We use the first installation here.
1, each node do the same operation

    1. Cd/tmp
    2. wget http://cdn.mysql.com/Downloads/MySQL-Cluster-7.2/mysql-cluster-gpl-7.2.8-linux2.6-i686.tar.gz
    3. Tar xzf mysql-cluster-gpl-7.2.8-linux2.6-i686.tar.gz
    4. MV Mysql-cluster-gpl-7.2.8-linux2.6-i686/usr/local/mysql

Note: This download is a 32-bit binary package, if your system is 64-bit, you need to download the 64-bit package.
2. Storage node and SQL node installation

    1. Groupadd MySQL
    2. useradd-g MySQL MySQL
    3. /usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql
    4. Chown-r Root/usr/local/mysql
    5. Chown-r Mysql/usr/local/mysql/data
    6. Chgrp-r Mysql/usr/local/mysql
    7. Cp/usr/local/mysql/support-files/my-medium.cnf/etc/my.cnf
Second, node configuration

1. Configuring storage nodes and SQL nodes

    1. Vi/etc/my.cnf
    2. Similar to:
    3. # Options for MYSQLD process:
    4. [MYSQLD]
    5. Ndbcluster # run NDB engine
    6. ndb-connectstring=198.168.0.111 # Location of MGM node
    7. # Options for NDBD process:
    8. [Mysql_cluster]
    9. ndb-connectstring=198.168.0.111 # Location of MGM node

2. Configuration Management node

  1. Mkdir/var/lib/mysql-cluster
  2. Cd/var/lib/mysql-cluster
  3. VI Config.ini
  4. The config.ini file should resemble the following:
  5. # Options affecting NDBD processes on all data nodes:
  6. [NDBD DEFAULT]
  7. noofreplicas=2 # of Replicas
  8. datamemory=80m # How much memory to allocate for data storage
  9. indexmemory=18m # How much memory to allocate for index storage
  10. # for Datamemory and indexmemory, we have used the
  11. # default values. Since the ' World ' database takes up
  12. # only on 500KB, this should is more than enough for
  13. # This example Cluster setup.
  14. # TCP/IP options:
  15. [TCP DEFAULT]
  16. portnumber=2202 # this default; However, you can use any
  17. # port that's free for all the hosts in cluster
  18. # Note:it is recommended beginning with MySQL 5.0 that
  19. # Specify the portnumber at all and simply allow
  20. # The default value to be used instead
  21. # Management Process Options:
  22. [NDB_MGMD]
  23. HOSTNAME=198.168.0.111 # hostname or IP address of MGM node
  24. Datadir=/var/lib/mysql-cluster # Directory for MGM node logfiles
  25. # Options for Data node "A":
  26. [NDBD]
  27. # (one [NDBD] section per data node)
  28. HOSTNAME=198.168.0.112 # hostname or IP address
  29. Datadir=/usr/local/mysql/data # Directory for this data node ' s datafiles
  30. # Options for Data node "B":
  31. [NDBD]
  32. HOSTNAME=198.168.0.113 # hostname or IP address
  33. Datadir=/usr/local/mysql/data # Directory for this data node ' s datafiles
  34. # SQL Node Options:
  35. [MYSQLD]
  36. HOSTNAME=198.168.0.110 # hostname or IP address
  37. # (Additional mysqld connections can be
  38. # specified for this node for various
  39. # purposes such as running Ndb_restore)
Third, start the node for the first time

1. Start the Management node

    1. /USR/LOCAL/MYSQL/BIN/NDB_MGMD--configdir=/var/lib/mysql-cluster-f/var/lib/mysql-cluster/config.ini

2. Start the Data node
The first boot requires the--initial parameter initialization, which is not required for the next boot.

    1. /USR/LOCAL/MYSQL/BIN/NDBD--initial

3. Start the SQL node

    1. /usr/local/mysql/bin/mysqld_safe &

4. Check the status
If everything is OK, execute the command/usr/local/mysql/bin/ndb_mgm-e show should output similar information:

[Email protected] mysql-cluster]#/USR/LOCAL/MYSQL/BIN/NDB_MGM-E Show
Connected to Management Server at:localhost:1186
Cluster Configuration
---------------------
[NDBD (NDB)] 2 node (s)
id=2 @192.168.0.112 (mysql-5.5.27 ndb-7.2.8, nodegroup:0, Master)
Id=3 @192.168.0.113 (mysql-5.5.27 ndb-7.2.8, nodegroup:0)

[NDB_MGMD (MGM)] 1 node (s)
Id=1 @192.168.0.111 (mysql-5.5.27 ndb-7.2.8)

[Mysqld (API)] 1 node (s)
Id=4 @192.168.0.110 (mysql-5.5.27 ndb-7.2.8)

Iv. Testing the service is normal

Perform the following database operations on the SQL node:

    1. /usr/local/mysql/bin/mysql-uroot-p
    2. Mysql> CREATE database Clusterdb;use Clusterdb;
    3. Mysql> CREATE TABLE simples (ID int not NULL primary key) Engine=ndb;
    4. mysql> INSERT into simples values (1), (2), (3), (4);
    5. Mysql> select * from Simples;

If it appears:
+----+
| ID |
+----+
| 1 |
| 2 |
| 4 |
| 3 |
+----+
Indicates that it is working correctly.

V. Secure shutdown and restart

1, close the MySQL cluster, you can execute the following command in the management node:

    1. /USR/LOCAL/MYSQL/BIN/NDB_MGM-E shutdown

2. Restart the Management node

    1. /USR/LOCAL/MYSQL/BIN/NDB_MGMD--configdir=/var/lib/mysql-cluster-f/var/lib/mysql-cluster/config.ini

3. Restart the data node

    1. /usr/local/mysql/bin/ndbd

Reference: http://dev.mysql.com/doc/refman/5.1/zh/ndbcluster.html

Reprint please indicate the article source: "Https://www.centos.bz/2012/11/mysql-cluster-install-configure/"

MySQL cluster installation and configuration

Related Article

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.