MysqlCluster集群搭建(windows或linux系统环境下)
2014-04-04 17:51
417 查看
MysqlCluster
Mysql cluster简介
MySQL Cluster是一种技术,该技术允许在无共享的系统中部署“内存中”数据库的集群。通过无共享体系结构,系统能够使用廉价的硬件,而且对软硬件无特殊要求,适合于分布式计算环境的高实用、高冗余版本。此外,由于每个组件有自己的内存和磁盘,不存在单点故障。MySQL Cluster将标准的MySQL服务器与名为NDB的“内存中”集群式存储引擎集成了起来。其中术语“MySQL cluster”指的是MySQL和NDB存储引擎的组合。
Mysql cluster特性
1、 通过自动分片实现高水平的写入扩展能力MySQL Cluster 自动将表分片(或分区)到不同节点上,使数据库可以在低成本的商用硬件上横向扩展,同时保持对应用程序完全应用透明。
2、 99.999% 的可用性
凭借其分布式、无共享架构,MySQLCluster 可提供 99.999% 的可用性,确保了较强的故障恢复能力和在不停机的情况下执行预定维护的能力。
3、 SQL 和 NoSQL API
MySQL Cluster 让用户可以在解决方案中整合关系数据库技术和 NoSQL 技术中的最佳部分,从而降低成本、风险和复杂性。
4、 实时性能
MySQL Cluster 提供实时的响应时间和吞吐量,能满足最苛刻的 Web、电信及企业应用程序的需求。
5、 具有跨地域复制功能的多站点集群
跨地域复制使多个集群可以分布在不同的地点,从而提高了灾难恢复能力和全球 Web 服务的扩展能力。
6、 联机扩展和模式升级
为支持持续运营,MySQL Cluster允许向正在运行的数据库模式中联机添加节点和更新内容,因而能支持快速变化和高度动态的负载。
Mysql cluster架构图
由上图可分为三类节点,在最低的MySQL cluster配置中,至少有三个节点,这三类节点分别是:· 管理(MGM)节点:这类节点的作用是管理MySQL集群内的其他节点,如提供配置数据、启动并停止节点、运行备份等。由于这类节点负责管理其他节点的配置,应在启动其他节点之前首先启动这类节点。
· 数据节点:这类节点用于保存集群的数据。数据节点的数目与副本的数目相关,是片段的倍数。例如,对于两个副本,每个副本有两个片段,那么就有4个数据节点。
· SQL节点:这是用来访问集群数据的节点。对于MySQL集群,客户端节点是使用NDB集群存储引擎的传统MySQL服务器。
Mysql cluster环境搭建
硬件环境
需要5台服务器Win1: IP:192.168.2.2 (管理节点)
Win2: IP:192.168.2.3 (数据节点)
Win3: IP:192.168.2.4 (数据节点)
Win4: IP:192.168.2.5 (sql节点)
Win5: IP:192.168.2.13 (sql节点)
软件环境
Window server 2008搭建步骤
l 管理节点(192.168.2.2)安装:1、 解压mysql-cluster-gpl-7.2.9-win32.zip包,开始Managementnode的安装配置。注意Management node一定要安装在C盘下。
2、 进入目录新建config.ini,配置内容如下:
config.ini内容为:
# Options affecting ndbd processes on all data nodes: [ndbd default] #NoOfReplicas=2 # Number of replicas #DataMemory=3072M # How much memory to allocate for data storage #DataMemory=512M #IndexMemory=256M # How much memory to allocate for index storage # For DataMemory and IndexMemory, we have used the # default values. Since the "world" database takes up # only about 500KB, this should be more than enough for # this example Cluster setup. #StringMemory=25 #ODirect=1 #MaxNoOfLocalScans=64 MaxNoOfTables=3000 #MaxNoOfOrderedIndexes=2048 #MaxNoOfUniqueHashIndexes=512 MaxNoOfAttributes=4000 #MaxNoOfAttributes=24576 #MaxNoOfTriggers=14336 #MaxNoOfConcurrentOperations=5000000 #MaxAllocate=50M #LockPagesInMainMemory=1 #MaxNoOfConcurrentTransactions=16384 #NoOfFragmentLogFiles=48 [NDB_MGMD] NodeId=1 HostName=192.168.2.2 #管理节点服务器 # Storage Engines # DataDir=C:/mysql/bin/cluster-logs [NDBD] NodeId=2 HostName=192.168.2.3 #MySQL集群db1的IP地址 #DataDir= D:/Program Files/mysqlcluster/datanode/mysql/bin/cluster-data #如果不存在就创建一个 [NDBD] NodeId=3 HostName=192.168.2.4 #MySQL集群db2的IP地址 #DataDir= D:/Program Files/mysqlcluster/datanode/mysql/bin/cluster-data #如果不存在就创建一个 [MYSQLD] NodeId=4 HostName=192.168.2.5 [MYSQLD] NodeId=5 HostName=192.168.2.13 |
在cmd命令行下cd 到集群/bin目录下执行:ndb_mgmd –f config.ini,出现以下字样表明成功。(如果修改config.ini文件后,需要重新初始化,使用命令:ndb_mgmd -f ..\config.ini --initial)
l 数据节点(192.168.2.3、192.168.2.4)安装
1、 解压mysql-cluster-gpl-7.2.9-win32.zip包,开始data node的安装配置。拷贝一份my-default修改名称为my.ini。
2、 修改my.ini文件,配置内容如下:
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysql_cluster] # Options for data node process: ndb-connectstring=192.168.2.2 [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #TCP Default Portnumber=2202 |
分别在两台服务器上执行,在cmd命令行下cd 到集群/bin目录下执行:ndbd,出现以下字样表明成功。
l sql节点(192.168.2.5、192.168.2.13)安装
1、 解压mysql-cluster-gpl-7.2.9-win32.zip包,开始sql node的安装配置。拷贝一份my-default修改名称为my.ini。
2、 修改my.ini文件,配置内容如下:
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] ndbcluster ndb-connectstring=192.168.2.2 # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES |
分别在两台服务器上执行,在cmd命令行下cd 到集群/bin目录下执行:mysqld --console,出现以下字样表明成功。
测试集群
1、调用集群自带的管理工具查看各个节点状态:在cmd命令行下cd 到集群/bin目录下执行:ndb_mgm à show 出现以下内容,表明节点正常启动。2、 错误提示
3、 使用mysql进行管理工作,在cmd命令行下cd 到集群/bin目录下执行:
mysql –uroot –p (root默认的密码为空)。
分配vrv用户和密码
GRANT ALL PRIVILEGES ON *.* TO 'vrv'@'%' IDENTIFIED BY'vrv123456' WITH GRANT OPTION
接下来跟操作单机数据库没啥区别。
注意在创建表的时候记得加入engine = ndbcluster,这样的表在数据节点中才能共享。
4、 关闭其中一台sql节点或数据节点,测试是否集群还能使用。
相关文章推荐
- 在Windows环境下搭建Linux系统的日志服务器.htm
- Windows系统安装Linux系统及Linux系统搭建Java开发环境
- 使用boch仿真器在x86 PC平台上搭建Linux0.11系统环境(windows下)
- 使用boch仿真器在x86 PC平台上搭建Linux0.11系统环境(windows下)
- Kettle集群介绍及(windows、linux)环境搭建
- Android --- windows下搭建Linux环境下载编译Android源代码--解决下载android系统源码错误问题
- 用qemu搭建CentOS 6 for colinux虚拟系统——《Windows下搭建CentOS 6开发环境之一》
- Linux 0.11系统环境搭建(windows下)
- Linux下Hadoop2.6.0集群环境的搭建
- Android一分钟环境搭建,包含Mac、Linux、Windows
- Windows系统搭建Android环境及遇到的问题解析
- Node.js开发环境搭建(Windows+Linux)
- Redis应用(一)——Windows系统中搭建并启动redis环境
- 测试环境搭建(Jenkins)的一般操作步骤-Linux系统
- Linux下zookeeper集群环境搭建
- 搭建开发板—Linux系统的通信环境网…
- windows开发 linux部署 java [debian+resin+mysql+java] 之环境搭建
- windows系统下Python环境的搭建
- RabbitMQ环境(linux和Windows)搭建指南
- 实时内存数据库eXtremeDB 在linux系统下的java开发环境搭建