Simple deployment of MySQL Cluster Development Environment

Source: Internet
Author: User

Main Content

1. Get; 2. Install; 3. Configure; 4. Run; 5. Test; 6. Stop; 7. Conclusion

1. Get

You don't have to talk about this. Just download it from the MySQL website. The MySQL Cluster deployment test manual in English is very concise, and its content is basically the same here. Anyone who likes to read the English version can download it directly and skip this article.

2. Installation

Decompress the package and create a symbolic link:

 
 
  1. michael@linux:~$ tar xvf mysql-cluster-gpl-7.2.4-linux2.6-x86_64.tar  
  2. michael@linux:~$ ln -s mysql-cluster-gpl-7.2.4-linux2.6-x86_64 mysqlc 

If you want to, you can~/mysqlc/binAdd it to your path for ease of use.

3. Configuration

As the first deployment in the development environment, the main purpose is to test. A complete MySQL Cluster consists of MySQL Server, Data Nodes, and Management Node. First, create some required directories for them:

 
 
  1. michael@linux:~$ mkdir mysql-cluster  
  2. michael@linux:~$ cd mysql-cluster  
  3. michael@linux:~$ mkdir conf ndb_data mysqld_data 

ThenconfCreate the following two files in the directory:config.iniAndmy.cnf, The content is as follows:

Config. ini

Used for MySQL Server configuration, Port NumberportSet according to your own situation.

 
 
  1. [mysqld]  
  2. ndbcluster  
  3. datadir=/home/user1/my_cluster/mysqld_data  
  4. basedir=/home/user1/mysqlc  
  5. port=5050  

My. cnf

This file is used to configure the NodeId of each Node and the Data directory of Data Nodes and Management Node.

 
 
  1. [ndb_mgmd]  
  2. hostname=localhost  
  3. datadir=/home/user1/my_cluster/ndb_data  
  4. NodeId=1  
  5.  
  6. [ndbd default]  
  7. noofreplicas=2  
  8. datadir=/home/user1/my_cluster/ndb_data  
  9.  
  10. [ndbd]  
  11. hostname=localhost  
  12. NodeId=3  
  13.  
  14. [ndbd]  
  15. hostname=localhost  
  16. NodeId=4  
  17.  
  18. [mysqld]  
  19. NodeId=50  

In this case, your directory structure should be as follows:

 
 
  1. ~  
  2. +-- /mysql-cluster-gpl-7.2.4-linux2.6-x86_64  
  3. +-- /mysqlc -> mysql-cluster-gpl-7.2.4-linux2.6-x86_64  
  4. +-- /mysql-cluster  
  5.     +-- /conf  
  6.     +-- /ndb_data  
  7.     +-- /mysqld_data  

4. Run

The startup sequence of MySQL Cluster is as follows:

  1. Management Node

  2. Data Nodes

  3. MySQL Server

The command is as follows:

 
 
  1. michael@linux:~$ cd ../mysql-cluster  
  2. michael@linux:~/mysql-cluster$ $HOME/mysqlc/bin/ndb_mgmd -f conf/config.ini --initial --configdir=$HOME/mysql-cluster/conf/  
  3. michael@linux:~/mysql-cluster$ $HOME/mysqlc/bin/ndbd -c localhost:1186  
  4. michael@linux:~/mysql-cluster$ $HOME/mysqlc/bin/ndbd -c localhost:1186  

Check the status of the started node. The command is:

 
 
  1. poecahnt@linux:~$ $HOME/mysqlc/bin/ndb_mgm -e show  

The output is as follows:

 
 
  1. Connected to Management Server at: localhost:1186  
  2. Cluster Configuration  
  3. ---------------------  
  4. [ndbd(NDB)]     2 node(s)  
  5. id=3    @127.0.0.1  (mysql-5.5.19 ndb-7.2.4, Nodegroup: 0, Master)  
  6. id=4    @127.0.0.1  (mysql-5.5.19 ndb-7.2.4, Nodegroup: 0)  
  7.  
  8. [ndb_mgmd(MGM)] 1 node(s)  
  9. id=1    @127.0.0.1  (mysql-5.5.19 ndb-7.2.4)  
  10.  
  11. [mysqld(API)]   1 node(s)  
  12. id=50   @127.0.0.1  (mysql-5.5.19 ndb-7.2.4)  

MySQL Server can be started. Start MySQL Server. The command is:

 
 
  1. michael@linux:~/mysql-cluseter$ $HOME/mysqlc/bin/mysqld --defaults-file=conf/my.cnf &  

The output information is as follows:

 
 
  1. 120223 15:29:02 InnoDB: The InnoDB memory heap is disabled  
  2. 120223 15:29:02 InnoDB: Mutexes and rw_locks use GCC atomic builtins  
  3. 120223 15:29:02 InnoDB: Compressed tables use zlib 1.2.3  
  4. 120223 15:29:02 InnoDB: Using Linux native AIO  
  5. 120223 15:29:02 InnoDB: Initializing buffer pool, size = 128.0M  
  6. 120223 15:29:02 InnoDB: Completed initialization of buffer pool  
  7. 120223 15:29:02 InnoDB: highest supported file format is Barracuda.  
  8. 120223 15:29:02  InnoDB: Waiting for the background threads to start  
  9. 120223 15:29:03 InnoDB: 1.1.8 started; log sequence number 1595675  
  10. 120223 15:29:04 [Note] NDB: NodeID is 50, management server 'localhost:1186' 
  11. 120223 15:29:04 [Note] NDB[0]: NodeID: 50, all storage nodes connected  
  12. 120223 15:29:04 [Warning] NDB: server id set to zero - changes logged to bin log with   server id zero will be logged with another server id by slave mysqlds  
  13. 120223 15:29:04 [Note] Starting Cluster Binlog Thread  
  14. 120223 15:29:04 [Note] Event Scheduler: Loaded 0 events  
  15. 120223 15:29:04 [Note] $HOME/mysqlc/bin/mysqld: ready for connections.  
  16. Version: '5.5.19-ndb-7.2.4-gpl'  socket: '/tmp/mysql.sock'  port: 5050  MySQL Cluster Community Server (GPL)  
  17. 120223 15:29:05 [Note] NDB: Creating mysql.ndb_schema  
  18. 120223 15:29:08 [Note] NDB Binlog: CREATE TABLE Event: REPL$mysql/ndb_schema  
  19. 120223 15:29:09 [Note] NDB Binlog: logging ./mysql/ndb_schema (UPDATED,USE_WRITE)  
  20. 120223 15:29:09 [Note] NDB: Creating mysql.ndb_apply_status  
  21. 120223 15:29:09 [Note] NDB Binlog: CREATE TABLE Event: REPL$mysql/ndb_apply_status  
  22. 120223 15:29:09 [Note] NDB Binlog: logging ./mysql/ndb_apply_status (UPDATED,USE_WRITE)  
  23. 120223 15:29:09 [Note] NDB: missing frm for mysql.ndb_index_stat_sample, discovering...  
  24. 120223 15:29:09 [Note] NDB: missing frm for mysql.ndb_index_stat_head, discovering...  
  25. 2012-02-23 15:29:10 [NdbApi] INFO     -- Flushing incomplete GCI:s < 579/14  
  26. 2012-02-23 15:29:10 [NdbApi] INFO     -- Flushing incomplete GCI:s < 579/14  
  27. 120223 15:29:10 [Note] NDB Binlog: starting log at epoch 579/14  
  28. 120223 15:29:10 [Note] NDB Binlog: ndb tables writable  

5. Test

Connect to MySQL Server for testing.ndbStorage engine to create tables in the database, as follows:

 
 
  1. michael@linux:~$ $HOME/mysqlc/bin/mysql -h 127.0.0.1 -P 5050  
  2. mysql> create database clusterdb;  
  3. mysql> use clusterdb;  
  4. mysql> insert into simples values (1),(2),(3),(4);  
  5. mysql> select * from simples;  
  6.  
  7.         +----+  
  8.         | id |  
  9.         +----+  
  10.         |  3 |  
  11.         |  1 |  
  12.         |  2 |  
  13.         |  4 |  
  14.         +----+  

6. Stop

MySQL Cluster must be stopped manually. Data Nodes can be stopped using ndb_mgm:

 
 
  1. michael@linux:~$ $HOME/mysqlc/bin/mysqladmin -h 127.0.0.1 -P 5050 shutdown  

If the prompt is:

 
 
  1. /home/michael/mysqlc/bin/mysqladmin: shutdown failed; error: 'Access denied; you need (at least one of) the SHUTDOWN privilege(s) for this operation' 

InshutdownAddsudo.

 
 
  1. michael@linux:~$ $HOME/mysqlc/bin/ndb_mgm -e shutdown  

The normal stop information is similar to the following:

 
 
  1. 120223 16:44:11 [Note] /home/michael/mysqlc/bin/mysqld: Normal shutdown  
  2.  
  3. michael@linux:~/mysql-cluster$ 120223 16:44:11 [Note] Event Scheduler: Purging the queue. 0 events  
  4. 120223 16:44:13 [Warning] /home/michael/mysqlc/bin/mysqld: Forcing close of thread 2  user: 'michael' 
  5.  
  6. 120223 16:44:13 [Note] Stopping Cluster Utility thread  
  7. 120223 16:44:13 [Note] Stopping Cluster Index Stats thread  
  8. 120223 16:44:13 [Note] Stopping Cluster Binlog  
  9. 120223 16:44:13 [Note] Stopping Cluster Index Statistics thread  
  10. 120223 16:44:14  InnoDB: Starting shutdown...  
  11. 120223 16:44:15  InnoDB: Shutdown completed; log sequence number 1595675  
  12. 120223 16:44:15 [Note] /home/michael/mysqlc/bin/mysqld: Shutdown complete  

7. Summary

  1. Orderly startup: Management Node, Data Nodes, MySQL Server

  2. Configuration items correspond to each node

  3. Each node is started independently.

  4. Management Node provides multiple functions such as status view.

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.