以下技术应用于最优质的水果的鲜果篮
Introduction to MySQL-Cluster:
- MySQL Cluster is a kind of technology, the technology allows the deployment of "memory" database in the system without sharing in clusters. Sharing architecture by no, system can use cheap hardware, and no special requirements for hardware and software, suitable for high utility, high redundancy in the distributed computing environment. In addition, because each component has its own memory and disk, there is no single point of failure.
- MySQL Cluster will be the standard MySQL server with the name NDB "memory" cluster storage engine integrated up. The term "MySQL cluster" refers to the combination of MySQL and NDB storage engine.
The characteristics of MySQL-Cluster:
- 1, Making making through automatic sheet write extended high level of competence
MySQL Cluster will automatically list slice (or partition) to different nodes, so that the database can be extended in thecommercial hardware and low cost, while maintaining the application completely transparent to applications.
- 2, The availability of making making 99.999%
By virtue of its distributed, shared nothing architecture, the availability of MySQL Cluster provides 99.999%, to ensure a strong recovery ability and ability to perform scheduled maintenance under the condition of no stop.
- 3, Making making SQL and NoSQL API
MySQL Cluster allows users to integrate the best part of relational database technology and NoSQL technology in thesolution, thereby reducing the cost, complexity and risk.
- 4, The real-time performance of making making
MySQL Cluster provides the response time and throughput in real time, can satisfy the most demanding of Web, telecommunication and enterprise application needs.
- 5, Making making with multi site cluster cross regional copy function
Cross regional replication allows multiple clusters can be distributed in different locations, thus improving the disaster recovery expansion capacity and the ability of global Web services.
- 6, Making making on-line expansion and upgrading
To support the continuing operations, MySQL Cluster allows the addition of on-line to a running database schema node and update the content, load and can therefore support the rapidly changing and highly dynamic.
MySQL-Cluster architecture diagram:
By the above can be divided into three types of nodes, at the lowest MySQL cluster configuration, there are at least three nodes, three nodes are:
· Administration(MGM)Node: This kind of joint function is other node MySQL in cluster, such as provide configuration data, start and stop node to run the backup, etc.. Because this kind of node is responsible for the management of other node configuration, should first start this node before the start of other nodes.
· Data node: This kind of nodes in the storage cluster data. The number of data nodes and copies of related, is the fragment ratio. For example, in two copies, each copy has two segments, then there are 4 data node.
· SQLNode: This is used to access the data in the cluster nodes. For the MySQL cluster, the client node using NDB cluster storage engine traditional MySQL server.
The hardware environment:
The 4 machines
192.168.6.14 dp04 making making management node
192.168.6.12 dp02 making making making making making storage node
192.168.6.10 dp01 making making making making making storage node, SQL node
192.168.6.13 dp03 making making SQL node
Software environment:
Operating system: CentOS 6 (64 bit)
Mysql version: MySQL-Cluster-gpl-7.3.5-1.el6.x86_64(RPM)
Installation preparation:
1 MySQL-Cluster-gpl-7.3.5-1.el6.x86_64.rpm-bundle.tar extract:
Will extract the MySQL-Cluster-server-gpl-7.3.5-1.el6.x86_64.rpm distribution to each machine,
Will extract the MySQL-Cluster-client-gpl-7.3.5-1.el6.x86_64.rpm distribution to the SQL node,
2 to clean up the old Mysql installation:
yum remove mysql
rpm -qa | grep mysql*
For 1 residual MySQL find the bag, please delete the following command format:
rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64
3 installation dependent Libraries:
yum -y install libaio
Install MySQL Cluster:
1 on each of the machine to install MySQL-Cluster-server-gpl-7.3.5-1.el6.x86_64.rpm
rpm -Uvh MySQL-Cluster-server-gpl-7.3.5-1.el6.x86_64.rpm
After installation will prompt the default password is stored in the /root/.mysql_secret file
2 on the SQL node to install MySQL-Cluster-client-gpl-7.3.5-1.el6.x86_64.rpm
rpm -Uvh MySQL-Cluster-client-gpl-7.3.5-1.el6.x86_64.rpm
Configuration management node:
Execution on the management node:
mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
vi config.ini
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2 # Number of replicas
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
# only about 500KB, this should be more than enough for
# this example Cluster setup.
[ndb_mgmd]
# Management process options:
hostname=dp04 # Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster # Directory for MGM node log files
[ndbd]
# Options for data node "A":
# (one [ndbd] section per data node)
hostname=dp03 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
[ndbd]
# Options for data node "B":
hostname=dp01 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
[mysqld]
# SQL node options:
hostname=dp02 # Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
[mysqld]
hostname=dp01
The configuration storage node and SQL node:
Execute on the storage node:
mkdir -p /usr/local/mysql/data
Execution on the SQL node:
mkdir -p /var/run/mysqld/
chmod -R 777 /var/run/mysqld/
Establish the configuration file in all storage nodes and SQL nodes:
vi /etc/my.cnf
[client]
socket=/var/lib/mysql/mysql.sock
[mysqld]
max_connections=100
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
ndbcluster
ndb-connectstring=dp04
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysql_cluster]
ndb-connectstring=dp04 ##The management node
Start each node:
Pay attention to the sequence.
1 start the management node: ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial
Changed config.ini file when the need to add the --initial parameter, then do not need the --initial parameter
2 start the storage node: ndbd --initial
Making first startup when the need to add the --initial parameter, then only need to perform ndbd,
3 start the SQL node: nohup mysqld_safe --explicit_defaults_for_timestamp & (also good: service mysql start)
Check whether the normal start all nodes:
Implementation of ndb_mgm into console in the management of cluster management node, use the show command to list all the node information:
Alter user root password:
Performed in each SQL node:
mysqladmin -u root -pOLDPASSWORD password 'newpassword'
Where OLDPASSWORD is generated in /root/.mysql_secret:
[root@dp03 ~]# cat /root/.mysql_secret
# The random password set for the root user at Tue Apr 15 11:08:59 2014 (local time): Nnqn0u1MRcpXkMue
Test cluster:
In the dp02 login MySQL:
[root@dp02 ~]# mysql -u root -ppassword
mysql> create database lxw;
Query OK, 1 row affected (0.06 sec)
In the dp01 login MySQL:
[root@dp01 ~]# mysql -u root -ppassword
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| lxw |
| mysql |
| ndbinfo |
| performance_schema |
| test |
+--------------------+
6 rows in set (0.00 sec)
You can see the database synchronization.
Commonly used commands:
1)Making making making making ndb_mgmd management command: ndb_mgm
After the execution is the management console, which can continue to enter the command.
All nodes inside view cluster state: show
2)Making making making making stop cluster server command: ndb_mgm -e shutdown
If the cluster configuration is updated: rm /usr/mysql-cluster/ndb_1_config.bin.1
3)Making making making making stop node SQL command: mysqladmin -uroot shutdown
4)Making making making making SQL Node connected to MySQL: mysql -u root –pPASSWORD
After the execution is the MySQL console, which can continue to enter the command.