Table of Contents
1、单管理节点MySQL集群和多管理节点MySQL集群
2、多管理节点MySQL集群配置
        1)修改管理节点配置
        2)修改数据节点配置
        3)修改SQL节点配置
3、多管理节点MySQL集群配置启动和测试
Home Database Mysql Tutorial 项目进阶 之 集群环境搭建(3)多管理节点MySQL集群

项目进阶 之 集群环境搭建(3)多管理节点MySQL集群

Jun 07, 2016 pm 04:25 PM
mysql build environment manage node Advanced cluster project

项目进阶 之 集群环境搭建(三)多管理节点MySQL集群 上次的博文项目进阶 之 集群环境搭建(二)MySQL集群中,我们搭建了一个基础的MySQL集群,这篇博客咱们继续讲解MySQL集群的相关内容,同时针对上一篇遗留的问题提出一个解决方法。 1、单管理节点MySQL集群

项目进阶 之 集群环境搭建(三)多管理节点MySQL集群
        上次的博文项目进阶 之 集群环境搭建(二)MySQL集群中,我们搭建了一个基础的MySQL集群,这篇博客咱们继续讲解MySQL集群的相关内容,同时针对上一篇遗留的问题提出一个解决方法。

1、单管理节点MySQL集群和多管理节点MySQL集群

        上一篇的博客中,我们搭建的MySQL集群架构中,只存在一个管理节点,这样搭建的集群可以用如下所示的结构表示。



        仔细分析上图就会发现,上图所示的单管理节点MySQL集群存在当唯一的管理节点由于网络、断电、压力过大等各种原因宕机后,数据节点和SQL节点将会各自为战,成为一盘散沙。这样搭建的MySQL集群可用性较低,所以我们要将单管理节点集群改变成如下图所示的多管理节点集群。



        在上图的多管理节点MySQL集群中,由于管理节点存在多个,所以当其中的某一个管理节点出现宕机之后,其他的管理节点自动接过MySQL集群的管理权限,保证MySQL集群的正常运行。


2、多管理节点MySQL集群配置

        多管理节点MySQL的配置非常简单,仅需要修改之前的博文中提高的三种节点的三个地方。

        1)修改管理节点配置

        打开管理节点C:\mysql\bin下的config.ini文件,将其中ndb_mgmd的相关配置修改为如下内容:
[ndb_mgmd] 
# Management process options:  
# Hostname or IP address of management node    
HostName=192.168.24.16              
# Directory for management node log files   
DataDir=C:/mysql/bin/cluster-logs


[ndb_mgmd]   
# Management process options:  
# Hostname or IP address of management node    
HostName=192.168.24.43               
# Directory for management node log files   
DataDir=C:/mysql/bin/cluster-logs
Copy after login
        即修改之后的config.ini存在多个ndb_mgmd管理节点的相关配置。

        2)修改数据节点配置

        打开数据节点C:\mysqlcluster\datanode\mysql下的my.ini文件,将其中mysql_cluster的相关配置修改为如下内容:
[mysql_cluster]  
# Optionsfor data node process:  
#location of management server  
ndb-connectstring=192.168.24.16,192.168.24.43
Copy after login
        即修改之后的mysql_cluster节点下的ndb-connectstring对应多个管理节点的IP地址。(如果管理节点修改了服务端口号,则需要添加相应的端口号,例如:192.168.24.16:3306,192.168.24.43:3306

        3)修改SQL节点配置

        与修改数据节点类似,修改SQL节点配置需要打开C:\mysqlcluster\sqlnode\mysql下的my.ini文件,将其中mysqld的相关配置修改为如下内容:
[mysqld]   
# Options for mysqld process:   
# run NDB storage engine   
ndbcluster                         
# location of management server   
ndb-connectstring=192.168.24.16,192.168.24.43
Copy after login
        即修改之后的mysqld节点下的ndb-connectstring对应多个管理节点的IP地址。

3、多管理节点MySQL集群配置启动和测试

        多管理节点MySQL集群的启动和测试与单管理节点MySQL集群的启动和测试没有区别,可以参考上一篇文章中的相关介绍。需要注意的是在启动MySQL集群的时候,除第一个启动的管理节点以外,其他管理节点会出现如下图所示的警告:

        以上警告的意思是节点1和3,2和4的arbitrator在一台主机上,可能引起整个集群失败,这个警告可以不用放在心上继续操作即可。

        到目前为止,咱们的多管理节点的MySQL集群就搭建完毕了,这样的集群的在正常情况下可以满足一般需求,但并不是说它就真的无懈可击,它从架构和实用度来讲还可以进行更多的优化和完善,具体都有哪些可以优化和完善的地方呢?敬请期待接下来的文章!
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)

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.

How to start mysql by docker How to start mysql by docker Apr 15, 2025 pm 12:09 PM

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

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.

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.

How to install mysql in centos7 How to install mysql in centos7 Apr 14, 2025 pm 08:30 PM

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

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

Centos install mysql Centos install mysql Apr 14, 2025 pm 08:09 PM

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

See all articles