Install and configure MySQL Cluster in Ubuntu

Source: Internet
Author: User
Tags tmp file

Install and configure MySQL Cluster in Ubuntu

I. Introduction to MySQL-Cluster

MySQL Cluster is a technology that allows the deployment of "in memory" database clusters in a non-shared system. Without a shared architecture, the system can use cheap hardware without special requirements for hardware and software. In addition, each component has its own memory and disk, so there is no single point of failure.

The MySQL cluster integrates the standard MySQL server with the "in-memory" Cluster Storage engine named NDB. The term NDB refers to the settings related to the storage engine, and the term "MySQL cluster" refers to the combination of MySQL and the NDB storage engine.

A MySQL cluster consists of a group of computers, each of which runs a variety of processes, including MySQL servers, NDB cluster data nodes, Management Servers (MGM), and (possibly) dedicated Data Access Program. The relationship between these components in the cluster, such:

All these programs constitute a MySQL cluster. When you save data to the NBD cluster engine, the table is saved in the data node. These tables can be directly accessed from all other MySQL servers in the cluster. Therefore, if an application updates the salary of an employee, all other MySQL servers that query this data can immediately detect this change.

For MySQL clusters, data stored on data nodes can be mapped, and the cluster can handle faults of individual data nodes. Except for a few things, they will be abandoned due to the loss of their status, there will be no other impact. A transaction application can handle failures, so it is not the source of the problem.

2. Basic concepts of MySQL Clusters

NDB is a "in-memory" storage engine with high availability and good data consistency.

The NDB storage engine can be configured using multiple failover and load balancing options, but the storage engine at the cluster level is the easiest to start. The NDB storage engine of the MySQL cluster contains the complete dataset, which depends only on other data in the cluster.

Next, we will introduce how to set up a MySQL cluster consisting of the NDB storage engine and some MySQL servers.

Currently, the MySQL cluster can be configured independently of the MySQL server. In a MySQL cluster, each part of the cluster is considered as a node.

Note: in many cases, the term "Node" is used for computers, but it represents processes when discussing MySQL clusters. A single computer can have any number of nodes, so we can configure multiple nodes with different functions on the same computer. Therefore, we use the term cluster host.

There are three types of cluster nodes. In the lowest MySQL cluster configuration, there are at least three nodes. These three types of nodes are:

Management Nodes (MGM): these nodes manage other nodes in the MySQL cluster, such as providing configuration data, starting and stopping nodes, and running backups. Because such nodes are responsible for managing the configurations of other nodes, management nodes should be started before other nodes. The MGM node is started with the command ndb_mgm.

Data nodes (NDB): these nodes are used to save the data of the cluster. The number of data set points is related to the number of copies, which is a multiple of fragments. For example, there are four data nodes for two replicas and two fragments for each copy. There is no need to have more than one copy .. The data node is started with the command ndbd.

SQL nodes: these nodes are used to access cluster data. For MySQL clusters, client nodes are traditional MySQL servers that use the NDB Cluster Storage engine. In typical cases, the SQL node is started with the mysql-ndbcluster command, or the ndbcluster is added to my. cnf and started with mysqld.

The cluster configuration includes the configuration of individual nodes in the cluster and the individual communication links between nodes. The current design of MySQL clusters aims to ensure that the storage nodes are homogeneous in terms of processor capabilities, memory space, and bandwidth. In addition, to provide a single configuration point as a whole, all configurations of the cluster are in the same file.

The Management Server (MGM node) is responsible for managing cluster configuration files and cluster logs. Each node in the cluster retrieves configuration data from the Management Server and requests to determine the location of the management server. When an interesting event occurs in a data node, the node transmits the information about the event to the management server, and then writes the information to the cluster log.

3. Lab Environment

During the experiment, only two computers are used to configure the MySQL-Cluster environment. The specific environment is as follows:

Management node (MGM) server: 192.168.3.47 Host Name: songzi nodeid = 1

Data Node 1 (NDB): 192.168.3.47 nodeid = 11

Data Node 2 (NDB): 192.168.4.128 nodeid = 12

SQL Node 1: 192.168.3.47 nodeid = 21

SQL Node 2: 192.168.4.128 nodeid = 22

Among them, the 32-bit operating system of Ubuntu12.04 is installed on 192.168.3.47, And the 64-bit operating system of ubuntu12.04 is installed on 192.168.4.128.

For the installation package download for MySQL-Cluster, see the http://dev.mysql.com/downloads/cluster/, where the 192.168.3.47 operating system is 32-bit linux, so the downloaded version selected is: mysql-cluster-gpl-7.3.3-linux-glibc2.5-i686.tar.gz. And 192.168.4.128 for 64-bit linux operating system, so the download version is: mysql-cluster-gpl-7.3.3-linux-glibc2.5-x86_64.tar.gz. Run the uname-m command on the terminal to view the information of the operating system. If the result is i686, It is a 32-bit operating system. If the result is x86_64, It is a 64-bit operating system. Be sure to select the correct version and download it.

In addition, if you have installed mysql-server before, you need to uninstall mysql-server before this experiment, and execute the following command to uninstall mysql

Sudo apt-get autoremove -- purge mysql-server
Sudo apt-get remove mysql-server
Sudo apt-get autoremove mysql-server
Sudo apt-get remove mysql-common (very important)

4. Installation

The binary version of the MySQL server must be installed on each MySQL cluster computer running storage or SQL nodes. There is no need to install the binary version of the MySQL server for the management node, but the MGM server port supervisor and the client binary version (ndb_mgmd and ndb_mgm respectively) should be installed ). This section describes the steps required to install the correct binary version for each cluster node.

4.1 installation of storage nodes and SQL nodes

The installation steps for SQL nodes and data nodes are basically the same. Therefore, perform the following steps as the system root user on each machine designed as a storage node or SQL node:

1. check the/etc/passwd and/etc/group/files to check whether the mysql group and mysql user already exist on the system, in this case, some operating systems will create it as part of the installation process. You can run the following command to View Details:

Cat show/etc/passwd

Cat show/etc/group

If they do not exist, create a new mysql user group and add a mysql user group to the group.

Groupadd mysql

Useradd-g mysql

2. Enter the directory that contains the downloaded file, decompress the file, and create a symlink with the mysql executable file. Note: the actual file and directory names may vary depending on the MySQL version number and the directory where the files are downloaded from the browser. If the downloaded file is in the default/home/jenny/Downloads directory of the browser,

Cd/home/jenny/Downloads

Tar zxvf-C mysql-cluster-gpl-7.3.3-linux-glibc2.5-i686.tar.gz/usr/local/bin

Cd/var/tmp

Ln-s/usr/local/bin/mysql-cluster-gpl-7.3.3-linux-glibc2.5-i686.tar.gz for mysql

3. Go to the mysql directory and run the provided script for creating the system database:

Cd mysql

Scripts/mysql_install_db -- user = mysql

If the script cannot be run and the host name does not match, the download version may be incorrect. Check whether the OS is 32-bit or 64-bit and select the correct version. If the default file cannot be found, it is likely that the previous mysql-server has not been uninstalled. Execute the commands provided above to thoroughly uninstall mysql-server.

4. Set necessary permissions for the MySQL server and data directory:

Chown-R root.

Chown-R mysql data

Chgrp-R mysql.

Note: The data directory on each machine running the data node is/usr/local/mysql/data. You can also specify this directory. If this directory is specified, this file must exist, if necessary, you must manually create one. This type of information will be used when configuring management nodes.

5. Copy the MySQL STARTUP script to the appropriate directory to make it an executable script, and set it to start when the operating system is started:

Cp support-files/mysql. server/etc/init. d

Chmod + x/etc/init. d/mysql. server

Chconfig -- add mysql. server

Remember to perform the preceding steps for each machine where the storage node or SQL node is located.

4.2 management node Installation

For management (MGM) nodes, you do not need to install the mysqld executable file. You only need to install the binary files for the MGM server and client. Such files can be found in the downloaded file. Assume that the downloaded file is under the/var/tmp file. As a system administrator, perform the following steps to install ndb_mgmd and ndb_mgm on the cluster management node Host:

1. Enter the/var/tmp directory and extract ndb_mgmd and ndb_mgm from the file to the appropriate directory, such as/usr/local/bin:

Cd/var/tmp

Tar zxvf-C mysql-cluster-gpl-7.3.3-linux-glibc2.5-i686.tar.gz

Cp/mysql-cluster-gpl-7.3.3-linux-glibc2.5-i686.tar.gz/bin/ndb_mgm */usr/local/bin/

2. Enter the directories where nndb_mgmd and ndb_mgm are located, and make these two files executable:

Cd/usr/local/bin

Chmod mysql-cluster-gpl-7.3.3-linux-glibc2.5-i686.tar.gzd + x ndb_mgm *

Now, the installation of all nodes has been completed. Next, we will introduce the specific configuration methods for each node in detail.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

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.