MySQL cluster installation (CentOS)

Source: Internet
Author: User
Tags file copy first string mysql download mysql in mysql view

MySQL cluster:

1. Distributed database system based on NDB Cluster

2. Each server node in the MySQL cluster does not share data

3. In MySQL cluster node refers to the process, which is different from the other nodes in the cluster refers to the situation of the computer, so there can be any number of nodes on a single computer

4. Three nodes: 1) Management node: Management of other nodes in cluster; Including start, stop, Backup, configuration, etc.;

The management node needs to be started before other nodes can be started

The management node should not be one, otherwise if the outage causes the cluster to be unavailable

2) Data node: Save cluster data,

If there are two replicas, each copy has two fragments, then there are 4 data nodes, and so on

3) SQL node: for accessing data in cluster

In the lowest MySQL cluster configuration, there should be at least three nodes

5. Starting mode:

Management node: NDB_MGMD data node: Ndbdsql node: Mysqld_ndbcluster  , after changing the MY.CNF profile, mysqld boot is available, as described below

6. Default port:

11862202

Get ready:

1. mysql Download link: http://mysql.mirror.kangaroot.net/Downloads/MySQL-Cluster-7.3/

Connect to Linux using the Pietty tool

and WINSCP tools for file copy

2.3 Servers: CentOS 6.4, network connection: bridged

192.168.1.136: Managing Nodes

192.168.1.95: Data node

192.168.1.62:sql node

3. Installation Location:/usr/local/mysql

Data location:/usr/local/mysql/data

Log location:/usr/local/mysql/log

4. Relevant CentOS instructions:

View CentOS Version: cat/etc/redhat-release to see if mysql:rpm is installed-qa |grep MySQL View services Status: Service MySQL staus close the current SQL service:/etc/init.d/mysqld stop to start the current SQL service:/etc/init.d/mysqld start Restart SQL service:/etc/init.d/mysqld Restart to see if the process is closed: PS-ef |grep mysql Uninstall installed mysql:rpm-e--allmatches--nodeps MySQL mysql-Server Delete Related directory: RM-rf/usr/local/MySQL RM-RF/var/MySQL RM-RF/var/lib/MySQL Group and user add: Groupadd mysql useradd mysql-g MySQL decompression: tar-ZXVF mysql-cluster-gpl-7.3.4-LINUX-GLIBC2.5-i686.tar.gz renaming folders: MV MySQL-cluster-gpl-7.3.4-LINUX-GLIBC2.5-i686 MySQL Change file or folder owner: Chown mysql:mysql MySQL (mysql:mysql in front of the user, followed by a group) runs the script: Scripts/mysql_install_db--user=mysql (--user=MySQL instructs the user to create a folder for the MySQL group: mkdir/var/lib/mysql-cluster (plus-Create a new directory if the directory does not exist or edit the file: VI+ /var/lib/mysql-cluster/config.ini VI filename: Opens or creates a new file and places the cursor at the beginning of the first VI+n FileName: Opens the file and places the cursor at the beginning of the nth Line VI+FileName: Opens the file and places the cursor at the beginning of the last line VI+/pattern FileName: Opens a file and places the cursor at the first string that matches the pattern VI-r filename: A system crash occurred during the last edit with VI, restore filename VI filename....filename: Open multiple files, edit in turn permanently shut down the firewall: Chkconfig--level *iptables off View firewall status:/etc/init.d/iptables status

Installation:

1. Check whether the installation has been installed before installation, such as installed uninstall reinstall

See if MYSQL:RPM-QA is installed |  /etc/init.d//etc/init.d/mysqld start restart SQL service:     /etc/init.d/-ef |  -e--allmatches--nodeps mysqlmysql--rf/usr/local/              mysql-rf/var/MySQL              -rf/var/lib/mysql

2. Managing node Installation

Installing on the 192.168.1.136

[[email protected] ~]# groupadd mysql  // Add Group // Add User [[email protected] ~]# CD/ usr/-zxvf mysql-cluster-gpl-7.3. 4-LINUX-GLIBC2. 5 // Unzip [Email protected] local]# mv mysql-cluster-gpl-7.3. 4-LINUX-GLIBC2. 5 //  Renaming

// Change Folder owner [email protected] local]# CD Mysql[[email protected] mysql]# scripts // installation


3. Managing node Configuration

[Email protected] mysql]# CD ~~]# mkdir/var/lib/mysql-~]# mkdir  /Usr/local/mysql /log~]# cd/var/lib/mysql-cluster[[email protected] MySQL-cluster]# vi +/var /lib/mysql-cluster/config.ini[[email protected] MySQL-cluster]# vi +/var/lib/ Mysql-cluster/config.ini

The contents of the Config.ini file are as follows:

[ndbd Default]noofreplicas=1[NDB_MGMD] #设置管理节点服务器 HostName=192.168. 1.136 datadir=/usr/local/mysql/data[ndbd] #设置存储节点服务器 (NDB node) HostName=192.168. 1.95 datadir=/usr/local/mysql/[MYSQLD] #设置SQL节点服务器 HostName=192.168 . 1.62

To start the management node:

/usr/local/mysql/bin/ndb_mgmd-f/var/lib/mysql-cluster/config.ini  //- F indicates that the following parameter is the startup configuration parameter file

We see that port 1186 of the Management node has been monitored:

To close the management node:

[Email protected] ~]#/USR/LOCAL/MYSQL/BIN/NDB_MGM-e shutdown
Connected to Management Server at:localhost:11861 NDB Cluster node (s) has shutdown. Disconnecting to allow Management Server to shutdown.

4. Data node and SQL node installation

1) 192.168.1.95: Data node, new user and Group on 192.168.1.62:sql node in the same way as above

-G MySQL

2) Copy the Management node/usr/local/mysql directory to the Data node and node

5. SQL Node Configuration:

[[email protected] mysql]# CP support-files/my-default.cnf/etc/my.cnf[[email protected] mysql]# CPSupport- Files/mysql.server/etc/init.d/mysqld
Cd/etcVI my.cnf Add the following: [Mysqld]ndbclusterndb-connectstring=192.168. 1.136 NDB-connectstring=192.168. 1.136 [Ndb_mgm]connect-string=192.168. 1.136

SQL node start: Service mysqld start (need to start management node)

[[Email protected] mysql]# service mysqld startstarting MySQL ......................................................................................................................... .... SUCCESS!

SQL node shutdown:/usr/local/mysql/bin/mysqladmin-uroot shutdown

6. Data node Configuration

[[email protected] mysql]# CP support-files/my-default.cnf/etc/my.cnf[[email protected] mysql]# CPSupport- Files/mysql.server/etc/init.d/mysqld
cd/etc/VI my.cnf added: [Mysqld]ndbclusterndb-connectstring=192.168. 1.136 [mysql_cluster]ndb-connectstring=192.168. 1.136 [Ndb_mgm]connect-string=192.168. 1.136

Data node Start:

/USR/LOCAL/MYSQL/BIN/NDBD--  need to start the management node)
[Email protected] support-files]#/USR/LOCAL/MYSQL/BIN/NDBD--initial--22 : [ndbd] INFO     '192.168.1.136:1186'  All:[ndbd] INFO     2

Test:

To create a database on a data node

[Email protected] mysql]#/etc/rc.d/init.d/~]#/etc/rc.d/init.d/~]#/usr/local/mysql/bin/mysql–u Root-p mysql> show database; MySQL> create Database wishtestdb; MySQL> Use wisht Estdb; MySQL> CREATE TABLE table1_test (ID varchar (), name varchar); MySQL>


To view the data on the SQL node:

mysql> use wishtestdb, MySQLselect from Table1_test;

  

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.