MySQL Cluster mysql cluster

Source: Internet
Author: User
Tags server memory

Original: http://lizhenliang.blog.51cto.com/7876557/1290451

Linux Latest Version 7.3.2

file size MD5
Mysqlcluster-7.3.2-linux-x32.tar.gz 431.0MB 03093541b6416fc93935750d614d875b
Mysqlcluster-7.3.2-linux-x64.tar.gz 441.8MB 330c71a87fbf8f0468ec9c5e0ad6e794

Official: http://dev.mysql.com/downloads/cluster/

Window Latest Version 7.3.2
file size MD5
Mysqlcluster-7.3.2-windows-x32.msi 100.2MB 9d25735d7e8af1a2e805f9a1fecc3a1f
Mysqlcluster-7.3.2-windows-x64.msi 95.5MB 6fe30e2045f074f471761cb17f0c3d1c
Basic concepts:

"NDB" is an "in-memory" storage engine and a transactional storage engine with acid properties.

Management (MGM) node: responsible for managing other nodes within the MySQL cluster, such as providing configuration data, starting and stopping nodes, running backups, and so on. Because such nodes are responsible for managing the configuration of other nodes, they should be started first before other nodes are started. The MGM node is started with the command "NDB_MGMD".

Data node: the data used to hold cluster. The number of data nodes is related to the number of replicas, which is a multiple of the fragment. The data node is started with the command "NDBD".

SQL node: the node used to access the cluster data. That is, the MySQL service, which can be started using service mysqld start.

The Management Server (MGM node) is responsible for managing cluster profiles and cluster logs. Each node in the cluster retrieves configuration data from the Management Server and requests a way to determine where the Management Server is located. When a new event occurs within the data node, the node transmits information about such events to the Management Server, and then writes such information to the cluster log.

Cluster Configuration Overview:

Installed version: MySQL cluster 7.3.2

Operating system: centos6.3 (X64)

Software Name: Mysql-cluster-gpl-7.3.2-linux-glibc2.5-x86_64.tar.gz (General edition)

Management node ip:192.168.0.202

Data node-sql node ip:192.168.0.203

Data node-sql node ip:192.168.0.204

Install dependency package: Yum install-y glibc perl libaio-devel

x32-bit system to install a Compatibility library group: Yum groupinstall "Compatibility Libraries"

One, management node installation configuration

1, installation Mysql-cluster

-G mysql-s/sbin/-zxvf mysql-cluster-gpl-7.3.2-linux-glibc2.5-x86_64.tar.gzmv MySQL- cluster-gpl-7.3.2-linux-glibc2.5-x86_64/usr/local/mysql--Rroot.mysql/usr/local/mysql/-R mysql.mysql/usr/local/mysql/data//usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--datadir= /usr/local/mysql/data--user=mysql &  -rf/usr/local/mysql/bin/ndb_mgm*/usr/local/bin/# Copy NDB node management commands to local, easy to use

2. Modify the MySQL master configuration file

vi/etc/==/tmp/=/usr/local/=/usr/local/mysql/data #数据库存放目录 character -set-server=UTF8 ndbcluster #运行NDB存储引擎 ndb-connectstring=192.168.0.202 lower_case_table_names =1 #表名是否区分大小写1为不区分, otherwise linux the table name is case-sensitive [mysql_cluster]ndb-connectstring=192.168.0.202 #Mysql CLUSTER Management node IP

3. Create a MySQL cluster configuration file

mkdir/var/lib/mysql-Clustervi/var/lib/mysql-cluster/CONFIG.INI[NDBDdefault]noofreplicas=2#定义在Cluster环境中相同数据的份数, 4DataMemory Max=256M #分配的数据内存大小, allocate indexmemory according to the amount of native server memory=256M #设定用于存放索引 (non-primary key) data memory segment Size # The amount of data that a NDB node can hold is constrained by the two parameter settings of Datamemory and indexmemory, and any one that reaches the limit will no longer be able to increase the amount of data that can be stored. If you continue to deposit the data system will error "table is full". [Ndb_mgmd]nodeid=1hostname=192.168.0.202DataDir=/var/lib/mysql-cluster/[Ndbd]nodeid=2hostname=192.168.0.203DataDir=/usr/local/mysql/Data[ndbd]nodeid=3hostname=192.168.0.204DataDir=/usr/local/mysql/Data[mysqld]nodeid=4hostname=192.168.0.203[Mysqld]nodeid=5hostname=192.168.0.204Save exit! Chown Mysql.mysql/var/lib/mysql-cluster/config.ini

Second, two data nodes and SQL node configuration is the same

1, installation Mysql-cluster

TAR-ZXVF mysql-cluster-gpl-7.3.2-linux-glibc2.5-x86_64.tar.gzmv MySQL- cluster-gpl-7.3.2-linux-glibc2.5-x86_64/usr/local/-G mysql-s/sbin/-R root.mysql/usr/local/  -R mysql.mysql/usr/local/mysql/data/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/ MySQL--datadir=/usr/local/mysql/data--user=mysql &/usr/local/mysql/support-files/mysql.server/etc/ init.d//usr/local/mysql/support-files/medium.cnf/etc/+x/etc/init.d/mysqld

2. Modify the MySQL configuration file

vi/etc/My.cnf[mysqld]user=mysqlcharacter_set_server=utf8ndbclusterndb-connectstring =192.168.0.202default-storage-engine=ndbcluster #设置默认是NDB存储引擎datadir=/usr/local/mysql/  Databasedir=/usr/local/mysql[mysql_cluster]ndb-connectstring=192.168.0.202 #mysql CLUSTER Management node IP

Third, testing (first shut down three server firewalls (IPTABLES) and Selinux)

1. Start the Management node

Ndb_mgmd-f/var/lib/mysql-cluster/config.ini---tuplna | grep 11860 0 0.0.0.0:1186 0.0.0.0:* LISTEN 1369/NDB_MGMD

#--initial: Add at the first boot, do not add at other times, otherwise the data will be emptied, unless it is restarted after backup, restore, or configuration changes.

If the start error: The Config.ini set in the Nodeid are deleted!

2. Start two data nodes and SQL nodes

Data node:/USR/LOCAL/MYSQL/BIN/NDBD--initial

SQL node: Bin/mysqld_safe--user=mysql & or service mysqld start

3. View cluster status

NDB_MGM-E Show #显示管理节点和数据节点则配置成功

4. Create a database to verify synchronization

Mysql-u root-pmysql>CREATE DATABASE Test; Mysql> Usetest; MySQLint) engine=ndbcluster; #指定数据库表的引擎为NDB, otherwise the synchronization fails MySQL>insert into ABC () VALUES (1) ; Mysql>select * FROM ABC;

#此时看两个数据是否数据一致 if the cluster is successful!

Precautions:

1. Be sure to use ENGINE=NDB or Engine=ndbcluster to specify the storage engine for the NDB cluster storage engine, or change the table with the ALTER TABLE option.
The 2.NDB table must have a primary key, so you must define a primary key when creating the table, otherwise the NDB storage engine will automatically generate the implied primary key.
The User rights table of the 3.SQL node is still saved with the MyISAM storage engine, so the MySQL user created in a SQL node can only access this node, and if you want to access other SQL nodes with the same user, you need to append the user to the corresponding SQL node.

Iv. Management and Maintenance orders

Close MySQL cluster: ndb_mgm-e shutdown

Restart MySQL cluster: ndb_mgmd-f/var/lib/mysql-cluster/config.ini

Restart Data node:/USR/LOCAL/MYSQL/BIN/NDBD

Start the SQL node:/usr/local/mysql/bin/mysqld_safe--user=mysql & or service mysqld restart

View MySQL status: Ndb_mgm-e show

Boot order:

SQL node, data node, management node

Close order:

Management node, data node, SQL node

MySQL Cluster mysql cluster

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.