Build MySQL Cluster Environment

This post documents how build MySQL cluster environment with 4 machines. Their IP addresses and roles are listed below.

  • Host #1: 192.168.1.100, management node
  • Host #2: 192.168.1.101, SQL node
  • Host #3: 192.168.1.102, data node #1
  • Host #4: 192.168.1.103, data node #2

Download MySQL Cluster on each host

wget http://dev.mysql.com/get/Downloads/MySQL-Cluster-7.3/mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
tar zxvf mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz
cd mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64/

Setup the cluster

On Management Node, run the following commands to copy ndb_mgm and ndb_mgmd to /usr/local/bin/.

cp bin/ndb_mgm /usr/local/bin/
cp bin/ndb_mgmd /usr/local/bin/

On Data Node, run the following commands to copy ndbd and ndbmtd to /usr/local/bin/.

cp bin/ndbd /usr/local/bin/
cp bin/ndbmtd /usr/local/bin/

On SQL Node

Check if the library libaio1 installed on the host, if not, execute the following command to install the library.

apt-get install libaio1

If the library can‘t be installed by running apt-get, you can download this package first, and then install it with dpkg -i like below.

wget http://archive.ubuntu.com/ubuntu/pool/main/liba/libaio/libaio1_0.3.109-4_amd64.deb
dpkg -i libaio1_0.3.109-4_amd64.deb

Run the following commands to install MySQL.

#
groupadd mysql
useradd -g mysql mysql

#
tar zxvf mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
ln -s /usr/local/mysql-cluster-gpl-7.3.7-linux-glibc2.5-x86_64 /usr/local/mysql

#
cd /usr/loca/mysql
scripts/mysql_install_db --user=mysql

#
chown -R root .
chown -R mysql data
chgrp -R mysql .

#
cp support-files/mysql.server /etc/init.d/
update-rc.d mysql.server defaults

Configure the Cluster

On the SQL and data nodes, type the following lines in /etc/my.cnf.

[mysqld]
ndbcluster

[mysql_cluster]
ndb-connectstring=1092.168.1.100

On the management node, type the following lines in /etc/mysql/config.ini.

[ndbd default]
NoOfReplicas=2    # Number of replicas
DataMemory=80M    # How much memory to allocate for data storage
IndexMemory=18M   # How much memory to allocate for index storage

[tcp default]
# TCP/IP options:
portnumber=2202

[ndb_mgmd]
# Management process options:
hostname=192.168.1.100
datadir=/var/lib/mysql-cluster  # Directory for MGM node log files

[ndbd]
# Options for data node #1:
hostname=192.168.1.102
datadir=/usr/local/mysql/data   # Directory for this data node‘s data files

[ndbd]
# Options for data node #2:
hostname=192.168.1.103
datadir=/usr/local/mysql/data   # Directory for this data node‘s data files

[mysqld]
# SQL node #1:
hostname=192.168.1.101

Start the cluster

Start the management node first.

ndb_mgmd -f /var/lib/mysql-cluster/config.ini

Start the data nodes.

ndbd

Start the SQL node.

service mysql.server start

On the management node, run the following command to see if the cluster goes well.

ndb_mgm
ndb_mgm> show

On the SQL node, set password for root.

mysqladmin -u root password ‘your password‘

Finally, try to create a database to test.

时间: 2024-10-08 23:58:15

Build MySQL Cluster Environment的相关文章

Build MySQL Replication Environment

The post demonstrates how to build replication environment with 2 new MySQL servers which are running on 64-bit Ubuntu 14.04 LTS machines. Master: {MySQL: 5.7.5, IP Address: 192.168.0.100} Slave  : {MySQL: 5.7.5, IP Address: 192.168.0.101} Configure

Mysql Cluster配置笔记

一.Mysql Cluster拓扑环境 Management:ClusterManager  222.9.9.161 ndb1:Clusterndb1    222.9.9.162 ndb2:Clusterndb2    222.9.9.163 sql1:Clustersql1    222.9.9.164 sql1:Clustersql2    222.9.9.165 拓扑中的服务器均为HyperV虚拟机镜像拷贝,仅有Centos 6.4操作系统,需要做一些基本配置 1.配置网卡IP地址(可直

MySQL分片高可用集群之MySQL Cluster部署使用

MySQL Cluster 是MySQL官方出品的分布式数据库解决方案,使用的数据库引擎为NDB,跟单机下的MyISAM和Innodb引擎有所不同,操作界面之一就是MySQL,此外提供原生API,可以节省资源并加快执行速度.该方案比业界其他MySQL集群方案在数据量大时有更大优势,开发者使用上跟单库操作几乎无差异,原先使用MySQL的话几乎可以无缝迁移,就可以享受集群带来的力量.当然也有个明显的缺点:内存开销非常大,如果要选择该方案,需要足够的硬件内存资源.下面我们详细地讲述MySQL Clus

MySQL Cluster(MySQL 集群) 初试(转)

作/译者:叶金荣(imysql#imysql.com>),来源:http://imysql.com,欢迎转载. 作/译者:叶金荣(Email: ),来源:http://imysql.cn,转载请注明作/译者和出处,并且不能用于商业用途,违者必究. MySQL Cluster 是MySQL适合于分布式计算环境的高实用.高冗余版本.它采用了NDB Cluster 存储引擎,允许在1个 Cluster 中运行多个MySQL服务器.在MyQL 5.0及以上的二进制版本中.以及与最新的Linux版本兼容的

mysql cluster (mysql 集群)安装配置方案(转)

一.准备 1.准备服务器 计划建立有5个节点的MySQL CLuster体系,需要用到5台服务器,但是我们做实验时没有这么多机器,可以只用2台,我就是一台本机,一台虚拟机搭建了有5个节点的MySQL CLuster体系,将一个SQL节点一个数据节点一个SQL节点放在了一台服务器上(192.168.1.252),将另一个SQL节点和一个数据节点放在了另外一台服务器上(192.168.1.52). 节点配置说明 节点 对应的IP和端口 管理节点(1个) 192.168.1.252 SQL节点 (2个

Build MySQL 5.7.4 in RedHat

Install Cmake 1. download cmake source code at  http://www.cmake.org/files/v3.1/cmake-3.1.0.tar.gz 2. ./configure &  make &  make install Build MySQL source code download at MySQL http://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.4-m14.tar.gz 1. c

mysql cluster安装部署

mysql cluster安装部署: http://www.178linux.com/36462 IPADDR=192.168.0.71 NETMASK=255.255.255.0 GATEWAY=192.168.0.1 DNS1=192.168.0.1 管理节点(MGM):  192.168.1.71 数据节点1(NDBD1):192.168.1.72 数据节点2(NDBD2):192.168.1.73 sql节点1(SQL1):   192.168.1.74 sql节点2(SQL2):  

Windows Server 2008R2配置MySQL Cluster并将管理节点和数据节点配置成windows服务

说明:将mysql的管理节点和数据节点配置成windows服务是为了防止有人手误关闭管理节点或数据节点的dos命令窗口,管理节点或数据节点的命令窗口误关闭可能会造成mysql某台或某几台mysql不能被访问,注册成windows服务自动启动更安全可靠. 目录 操作系统:Windows Server 2008 R2 Enterprise VM1:192.168.220.103 管理节点(MGM), VM2:192.168.220.104数据节点(NDBD1),SQL节点(SQL1) VM3:192

MySQL Cluster

一.MySQL Cluster概述MySQL Cluster 是一种技术,该技术允许在无共享的系统中部署“内存中”数据库的 Cluster .通过无共享体系结构,系统能够使用廉价的硬件,而且对软硬件无特殊要求.此外,由于每个组件有自己的内存和磁盘,不存在单点故障.MySQL Cluster 由一组计算机构成,每台计算机上均运行着多种进程,包括MySQL服务器,NDB Cluster 的数据节点(NDB),管理服务器(MGM),以及(可能)专门的数据访问程序.关于 Cluster 中这些组件的关系