Create database tables in MySQL Cluster

Source: Internet
Author: User
Tags mysql manual how to create database

MySQL Cluster is a MySQL database that is mainly applicable to high-utility and high-redundancy distributed computing environments. MySQL Cluster uses the NDB Cluster Storage engine, which allows you to operate and operate MySQL servers in a Cluster.

This storage engine is available in MySQL 5.0 and later binary versions, and in RPM compatible with the latest Linux version. Note: To obtain the functions of MySQL Cluster, you must install mysql-server and mysql-max RPM ).
Currently, the operating systems that can run MySQL Cluster include Linux, Mac OS x, and Solaris. Some users have reported that MySQL Cluster has been successfully run on FreeBSD, but MySQL AB does not yet officially support this feature ).

How to create database tables in the creation of MySQL Cluster

Compared with MySQL that does not use the Cluster, there is no big difference in the way data is operated in the MySQL Cluster. When performing such operations, remember two points:

Tables must be created with the ENGINE = NDB or ENGINE = NDBCLUSTER option, or changed with the alter table option to use the NDB Cluster Storage ENGINE to copy them within the Cluster. If you use mysqldump output to import tables from an existing database, you can open the SQL script in the text editor and add this option to any table creation statement, or use one of these options to replace any existing ENGINE or TYPE) options.

Remember that each NDB table must have a primary key. If you do not define a primary key when creating a table, the NDB Cluster Storage engine automatically generates an implicit primary key. Note: This implicit key also occupies space, just like any other table index. The problem is not uncommon because there is not enough memory to hold these automatically created keys ).

The following is an example:

On db2, create a data table and insert data:

 
 
  1. [db2~]root# mysql -uroot test  
  2. [db2~]mysql> create table city(  
  3. [db2~]mysql> id mediumint unsigned not null auto_increment primary key,  
  4. [db2~]mysql> name varchar(20) not null default ''  
  5. [db2~]mysql> ) engine = ndbcluster default charset utf8;  
  6. [db2~]mysql> insert into city values(1, 'city1');  
  7. [db2~]mysql> insert into city values(2, 'city2'); 

On db3, query data:

 
 
  1. [db3~]root# mysql -uroot test  
  2. [db2~]mysql> select * from city;  
  3. +-----------+  
  4. |id | name |  
  5. +-----------+  
  6. |1 | city1 |  
  7. +-----------+  
  8. |2 | city2 |  
  9. +-----------+ 

Disable Security

To disable Cluster, you can simply enter the following command in Shell on the machine where the MGM node is located:

[Db1 ~] Root #/usr/local/mysql/ndb_mgm-e shutdown run the following command to disable the mysqld service on the SQL node:

 
 
  1. [db2~]root# /usr/local/mysql/bin/mysqladmin -uroot shutdown 

Others

For more information about MySQL Cluster and backup, see the "MySQL Cluster (MySQL Cluster)" section in the MySQL manual.

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.