search
HomeDatabaseMysql TutorialWindows环境下配置MySQL Cluster

Windows环境下配置MySQL Cluster

Jun 07, 2016 pm 04:20 PM
clustermysqlwindowsenvironmentConfiguration

一、准备工作 首先得准备好硬件设施、我这里是3台机器在做群集、结构如下: 管理节点(MGM) 172.16.0.162(db1) SQL节点1(SQL1) 172.16.0.161(db2) SQL节点2(SQL2) 172.16.0.202(db3) 数据节点1(NDBD1) 172.16.0.161(db4) 数据节点2(NDBD2) 172.16.0.202(db4)

   一、准备工作

  首先得准备好硬件设施、我这里是3台机器在做群集、结构如下:

  管理节点(MGM) 172.16.0.162(db1)

  SQL节点1(SQL1) 172.16.0.161(db2)

  SQL节点2(SQL2) 172.16.0.202(db3)

  数据节点1(NDBD1) 172.16.0.161(db4)

  数据节点2(NDBD2) 172.16.0.202(db4)

  这个硬件搞定了、现在搞软件

  最好下载7以上的版本、因为性能好嘛,7.2这个版本的新特性上介绍说是:自适应查询本地化(AQL) 复杂连接速度提高70多倍。当然到底是不是这样我没有测试过不清楚。

  二、安装软件

  解压mysql-cluster-gpl-7.2.9-win32.zip包

  Management node的安装配置。

  Management node一定要安装在C盘下,并且是以下的目录(这是在运行此节点时报错,说找不到相对应的目录)。在IP为172.16.0.162的机子上

  生成c:/mysql/bin、C:/mysql/mysql-cluster(第一次启动后在这个文件夹会生成类似ndb_1_config.bin.1的文件,好像是为了以后启动加载的配置)

  和c:/mysql/bin/cluster-logs目录,在下载解压的文件目录mysql/bin中将ndb_mgmd.exe和ndb_mgm.exe复制到172.16.0.162的c:/mysql/bin目录下。

  在172.16.0.162的c:/mysql/bin下生成两个文件,my.ini和config.ini。

  my.ini的内容为:

  [plain]view plaincopyprint?

  [mysql_cluster]

  # Options for management node process

  config-file=C:/mysql/bin/config.ini

  [mysql_cluster] # Options for management node process config-file=C:/mysql/bin/config.ini

  config.ini的内容:(注:ID不能从0开始,必须大于0)

  [html]view plaincopyprint?

  [NDBD DEFAULT]

  NoOfReplicas=2

  DataDir=D:/Program Files/mysqlcluster/datanode/mysql/bin/cluster-data

  DataMemory=80M

  IndexMemory=18M

  [MYSQLD DEFAULT]

  [NDB_MGMD DEFAULT]

  [TCP DEFAULT]

  [NDB_MGMD]

  ID=1

  HostName=172.16.0.162 #管理节点服务器

  # Storage Engines

  DataDir=C:/mysql/bin/cluster-logs

  [NDBD]

  ID=2

  HostName=172.16.0.161 #MySQL集群db1的IP地址

  #DataDir= D:/Program Files/mysqlcluster/datanode/mysql/bin/cluster-data #如果不存在就创建一个

  [NDBD]

  ID=3

  HostName=172.16.0.202 #MySQL集群db2的IP地址

  #DataDir= D:/Program Files/mysqlcluster/datanode/mysql/bin/cluster-data #如果不存在就创建一个

  [MYSQLD]

  ID=4

  HostName=172.16.0.161

  [MYSQLD]

  ID=5

  HostName=172.16.0.202

  [NDBD DEFAULT]NoOfReplicas=2DataDir=D:/Program Files/mysqlcluster/datanode/mysql/bin/cluster-dataDataMemory=80MIndexMemory=18M[MYSQLD DEFAULT][NDB_MGMD DEFAULT][TCP DEFAULT][NDB_MGMD]ID=1HostName=172.16.0.162 #管理节点服务器# Storage EnginesDataDir=C:/mysql/bin/cluster-logs[NDBD]ID=2HostName=172.16.0.161 #MySQL集群db1的IP地址#DataDir= D:/Program Files/mysqlcluster/datanode/mysql/bin/cluster-data #如果不存在就创建一个[NDBD]ID=3HostName=172.16.0.202 #MySQL集群db2的IP地址#DataDir= D:/Program Files/mysqlcluster/datanode/mysql/bin/cluster-data #如果不存在就创建一个[MYSQLD]ID=4HostName=172.16.0.161[MYSQLD]ID=5HostName=172.16.0.202

  Data nodes的安装配置

  在IP为172.16.0.161 的机子上生成D:/Program Files/mysqlcluster/datanode/mysql/bin、D:/Program Files/mysqlcluster/datanode/mysql/cluster-data、

  D:/Program Files/mysqlcluster/datanode/mysql/bin/cluster-data.在下载的的解压文件夹/bin中将ndbd.exe复制到

  172.16.0.161 机子的D:/Program Files/mysqlcluster/datanode/mysql /bin目录下,

  并在D:/Program Files/mysqlcluster/datanode/mysql/bin目录下生成my.ini文件,文件的内容为:

  [html]view plaincopyprint?

  [mysql_cluster]

  # Options for data node process:

  ndb-connectstring=172.16.0.162 # location of management server

  [mysql_cluster] # Options for data node process:ndb-connectstring=172.16.0.162 # location of management server 同理在172.16.0.202机子上配置相同的配置,也可以直接复制到172.16.0.202机子上。

  SQL node的安装配置

  在IP为172.16.0.161的机子上生成D:/Program Files/mysqlcluster/sqlnode目录,将下载的解压文件夹直接整个复制到D:/ProgramFiles/mysqlcluster/sqlnode/mysql目录下,在D:/ProgramFiles/mysqlcluster/sqlnode/mysql下生成my.ini文件,文件内容为:

  [html]view plaincopyprint?

  [html]view plaincopyprint?

  [mysqld]

  # Options for mysqld process:ndbcluster

  [mysqld] # Options for mysqld process:ndbcluster

  [html]view plaincopyprint?

  # run NDB storage engine

  ndb-connectstring=172.16.0.154

  # location of management server

  # run NDB storage engine ndb-connectstring=172.16.0.154 # location of management server同理,将D:/Program Files/mysqlcluster/sqlnode整个文件夹复制到172.16.0.202机子的相同目录下。

  三、启动集群

  启动各个节点是有顺序的,先是Management node,然后是Data nodes,最后是SQL nodes。

  a、启动Management node在172.16.0.162机子下进入命令行,,转到c:/mysql/bin目录下,输入:

  ndb_mgmd -f config.ini

  (

  如果报如下错误:MySQL Cluster Management Server mysql-5.5.28 ndb-7.2.9

  2013-05-03 10:13:10 [MgmtSrvr] INFO -- The default config directory 'C:/Prog

  ram Files/MySQL/MySQL Server 5.5/mysql-cluster' does not exist. Trying to create

  it...

  Failed to create directory 'C:/Program Files/MySQL/MySQL Server 5.5/mysql-cluste

  r', error: 3

  2013-05-03 10:13:10 [MgmtSrvr] ERROR -- Could not create directory 'C:/Progra

  m Files/MySQL/MySQL Server 5.5/mysql-cluster'. Either create it manually or spec

  ify a different directory with --configdir=

  则在创建如下文件夹:C:Program FilesMySQLMySQL Server 5.5

  )

  b、启动Data node

  在172.16.0.161机子下进入命令行,转到D:/Program Files/mysqlcluster/datanode/mysql/bin目录下,输入:

  ndbd --connect-string="nodeid2;host=172.16.0.162:1186"

  同理启动172.16.0.202机子,nodeid2是根据管理节点的配置文件

  config.ini中的id决定的,如果id为2,则为nodeid2,配置文件中未指定

  id,则按顺序执行。

  (注)此时可通过在Management node中新开一命令行,转到

  c:/mysql/bin目录下输入命令:

  ndb_mgm

  启动ndb_mgm.exe,之后输入命令:

  ALL STATUS

  查看到Data node连接是否成功.之后启动正常之后才能继续启动

  SQLnode

  c、启动SQL node

  在172.16.0.161机子下进入命令行,转到D:/Program

  Files/mysqlcluster/sqlnode/mysql/bin目录下,输入:

  mysqld --console

  按相同方式启动172.16.0.202下的SQL node。

  (注):可通过在Management node节点的机器下,转到c:/mysql/bin目录

  下输入命令:

  ndb_mgm

  启动ndb_mgm.exe,之后输入命令:

  SHOW

  即可查看到各个节点的连接情况。

Statement
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
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 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.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 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

See all articles

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

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment