Table of Contents
一、     说明
二、     Mysql集群结构图
三、     名词解释
四、     安装环境
1.     操作系统
2.     安装结构图
3.     部署列表
五、     安装软件
六、     安装步骤
1.     管理节点安装
2.     数据节点安装
3.     SQL节点安装
七、     Mysql集群启动
1.     管理节点启动
2.     数据节点启动
3.     Sql节点启动
八、     验证
九、     关闭集群
十、     重要说明
十一、     其它
Home Database Mysql Tutorial mysql集群安装说明

mysql集群安装说明

Jun 07, 2016 pm 03:21 PM
cluster mysql install Install illustrate cluster

Mysql cluster安装说明 一、说明 本文档介绍了如何规划、安装、配置和运行MySQL集群的基本知识。 二、Mysql集群结构图 三、名词解释 ? 管理节点: 这类节点的作用是管理MySQL簇内的其他节点,如提供配置数据、启动并停止节点、运行备份等。由于这类节点负责

Mysql cluster安装说明

一、     说明

本文档介绍了如何规划、安装、配置和运行MySQL集群的基本知识。

二、     Mysql集群结构图


三、     名词解释

管理节点:这类节点的作用是管理MySQL簇内的其他节点,如提供配置数据、启动并停止节点、运行备份等。由于这类节点负责管理其他节点的配置,应在启动其他节点之前首先启动这类节点。

数据节点:这类节点用于保存簇的数据。数据节点的数目与副本的数目相关,是片段的倍数。例如,对于两个副本,每个副本有两个片段,那么就有4个数据节点。没有必要有一个以上的副本。数据节点是用命令ndbd启动的。

SQL节点:这是用来访问簇数据的节点。对于MySQL簇,客户端节点是使用NDB簇存储引擎的传统MySQL服务器。

四、     安装环境

1.     操作系统

Linux version2.6.18-164.el5

2.     安装结构图


3.     部署列表

名称

Ip

(MGM)管理节点

(NDBD)数据节点1

192.168.10.10

192.168.10.20

(NDBD)数据节点2

192.168.10.40

SQL节点1

192.168.10.30

SQL节点2

192.168.10.50

 

五、     安装软件

MySQL-Cluster-gpl-management-7.1.29-1.rhel5.x86_64.rpm

MySQL-Cluster-gpl-storage-7.1.29-1.rhel5.x86_64.rpm

MySQL-Cluster-gpl-tools-7.1.29-1.rhel5.x86_64.rpm

MySQL-Cluster-gpl-client-7.1.29-1.rhel5.x86_64.rpm

MySQL-Cluster-gpl-server-7.1.29-1.rhel5.x86_64.rpm

下载地址:http://www.mysql.com/downloads/cluster/7.1.html

六、     安装步骤

1.     管理节点安装

上传

MySQL-Cluster-gpl-management-7.1.29-1.rhel5.x86_64.rpm,MySQL-Cluster-gpl-tools-7.1.29-1.rhel5.x86_64.rpm到服务器192.168.10.10上

安装:

[root@192.168.10.10 ]# rpm -ivh MySQL-Cluster-gpl-management-7.1.29-1.rhel5.x86_64.rp
[root@192.168.10.10 ]# rpm -ivh MySQL-Cluster-gpl-tools-7.1.29-1.rhel5.x86_64.rpm
[root@192.168.10.10 ]# mkdir /var/lib/mysql-cluster
[root@192.168.10.10 ]# vi /var/lib/mysql-cluster/config.ini
Copy after login

修改配置文件config.ini
[ndbd default]
NoOfReplicas=2
DataMemory=80M
IndexMemory=18M
[tcp default]
SendBufferMemory=2M
ReceiveBufferMemory=2M
[NDB_MGMD DEFAULT]
PortNumber=1186
datadir=/var/lib/mysql-cluster
[ndb_mgmd]
NodeId=1
hostname=192.168.10.10
[ndbd]
NodeId=2
hostname=192.168.10.20
datadir=/var/lib/mysql-data
[ndbd]
NodeId=4
hostname=192.168.10.40
datadir=/var/lib/mysql-data
[mysqld]
NodeId=3
hostname=192.168.10.30
[mysqld]
NodeId=5
hostname=192.168.10.50
Copy after login


注意:NoOfReplicas的数字要和数据节点的数量一样!

2.     数据节点安装

上传MySQL-Cluster-gpl-storage-7.1.29-1.rhel5.x86_64.rpm分别到服务器192.168.10.20和192.168.10.40上

执行

[root@192.168.10.20]# rpm -ivh MySQL-Cluster-gpl-storage-7.1.29-1.rhel5.x86_64.rpm
输出如下成功
Preparing...                ########################################### [100%]
   1:MySQL-Cluster-gpl-stora########################################### [100%]
[root@192.168.10.20]# mkdir /var/lib/mysql-data
[root@192.168.10.20]# chmod 777 /var/lib/mysql-data –R
[root@192.168.10.20]#vi /etc/my.cnf
Copy after login


修改my.cnf

192.168.10.40的安装同上

3.     SQL节点安装

上传MySQL-Cluster-gpl-client-7.1.29-1.rhel5.x86_64.rpm

MySQL-Cluster-gpl-server-7.1.29-1.rhel5.x86_64.rpm分别到服务器192.168.10.30和192.168.10.50上

执行

[root@192.168.10.30]#rpm -ivh MySQL-Cluster-gpl-server-7.1.29-1.rhel5.x86_64.rpm
输出如下成功
Preparing...                ########################################### [100%]
   1:MySQL-Cluster-gpl-serve########################################### [100%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!
[root@192.168.10.30]# rpm -ivh MySQL-Cluster-gpl-client-7.1.29-1.rhel5.x86_64.rpm --nodeps –force
输出如下成功
Preparing...                ########################################### [100%]
   1:MySQL-Cluster-gpl-clien########################################### [100%]
[root@192.168.10.30]# vi /etc/my.cnf
Copy after login

修改my.cnf
[mysqld]
ndbcluster
ndb-connectstring=192.168.10.10:1186
[mysql_cluster]
ndb-connectstring=192.168.10.10:1186
Copy after login


192.168.10.50的安装同上

七、     Mysql集群启动

启动顺序为管理节点、数据节点、sql节点

1.     管理节点启动

//管理节点启动
//第一次启动
[root@192.168.10.10]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
//以后启动
[root@192.168.10.10]# ndb_mgmd
//config.ini 修改启动
[root@192.168.10.10]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
//启动成功为:
MySQL Cluster Management Server mysql-5.1.72 ndb-7.1.29
//查看状态
[root@192.168.10.10]# ndb_mgm
ndb_mgm>show
如下信息,各个节点的状态
[ndbd(NDB)]     2 node(s)
id=2    @192.168.10.20  (mysql-5.1.72 ndb-7.1.29, Nodegroup: 0, *)
id=4    @192.168.10.40  (mysql-5.1.72 ndb-7.1.29, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.10.10  (mysql-5.1.72 ndb-7.1.29)
[mysqld(API)]   2 node(s)
id=3 (not connected, accepting connect from 192.168.10.30)
id=5 (not connected, accepting connect from 192.168.10.50)
Copy after login


2.     数据节点启动

//数据节点启动 第一个数据节点启动时用 –initial其它不需要
[root@192.168.10.20]# ndbd –initial 
//输出如下成功
2013-12-25 23:36:23 [ndbd] INFO     -- Angel connected to '192.168.10.10:1186'
2013-12-25 23:36:23 [ndbd] INFO     -- Angel allocated nodeid: 2
Copy after login

192.168.10.40 操作同上

3.     Sql节点启动

//sql节点启动 
[root@192.168.10.20]# mysqld_safe
//输出如下成功
131226 01:02:43 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.
131226 01:02:43 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Copy after login

192.168.10.50 操作同上

如果启动出现如下提示


//sql节点启动
131226 01:01:50 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.
131226 01:01:51 mysqld_safe A mysqld process already exists
Copy after login

手动杀掉mysql的进程重新启动

八、     验证


在其中一个sql节点上建一个库,并建立一个测试表插入数据,再从另外一个sql节点登陆看是否同步,如果同步成功,否则失败。

九、     关闭集群


1.关闭管理节点和数据节点,只需要在管理节点里执行:

[root@192.168.10.10]# ndb_mgm -e shutdown
Node 2: Cluster shutdown initiated
Node 4: Cluster shutdown initiated
Node 4: Node shutdown completed.
Node 2: Node shutdown completed.
3 NDB Cluster node(s) have shutdown.
Disconnecting to allow management server to shutdown.
Copy after login



 2.然后关闭Sql节点,分别在2个节点里运行:

[root@192.168.10.30]# service mysql stop
Copy after login


十、     重要说明

1.在建表的时候一定要用ENGINE=NDB或ENGINE=NDBCLUSTER指定使用NDB集群存储引擎,或用ALTERTABLE选项更改表的存储引擎。
2.NDB表必须有一个主键,因此创建表的时候必须定义主键,否则NDB存储引擎将自动生成隐含的主键。
3.Sql节点的用户权限表仍然采用MYISAM存储引擎保存的,所以在一个Sql节点创建的MySql用户只能访问这个节点,如果要用同样的用户访问别的Sql节点,需要在对应的Sql节点追加用户。


十一、     其它

先看看都安装了什么包:

如果安装过程中出现错误,删除重新装

rpm -qa|grep MySQL

然后把这些包都卸载掉

rpm -e MySQL-server*

rpm -e MySQL-client*

 

 


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1663
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
MySQL's Role: Databases in Web Applications MySQL's Role: Databases in Web Applications Apr 17, 2025 am 12:23 AM

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Laravel Introduction Example Laravel Introduction Example Apr 18, 2025 pm 12:45 PM

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Solve database connection problem: a practical case of using minii/db library Solve database connection problem: a practical case of using minii/db library Apr 18, 2025 am 07:09 AM

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

MySQL vs. Other Programming Languages: A Comparison MySQL vs. Other Programming Languages: A Comparison Apr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Laravel framework installation method Laravel framework installation method Apr 18, 2025 pm 12:54 PM

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

MySQL for Beginners: Getting Started with Database Management MySQL for Beginners: Getting Started with Database Management Apr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

Solve MySQL mode problem: The experience of using the TheliaMySQLModesChecker module Solve MySQL mode problem: The experience of using the TheliaMySQLModesChecker module Apr 18, 2025 am 08:42 AM

When developing an e-commerce website using Thelia, I encountered a tricky problem: MySQL mode is not set properly, causing some features to not function properly. After some exploration, I found a module called TheliaMySQLModesChecker, which is able to automatically fix the MySQL pattern required by Thelia, completely solving my troubles.

See all articles