mysql集群安装说明
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
修改配置文件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
注意: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
修改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
修改my.cnf
[mysqld] ndbcluster ndb-connectstring=192.168.10.10:1186 [mysql_cluster] ndb-connectstring=192.168.10.10:1186
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)
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
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
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
手动杀掉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.
2.然后关闭Sql节点,分别在2个节点里运行:
[root@192.168.10.30]# service mysql stop
十、 重要说明
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*

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











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 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 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.

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.

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.

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.

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

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.
