Ubuntu部署MysqlCluster集群
来源:程序员人生 发布时间:2015-03-04 08:07:09 阅读次数:3636次
部署环境:
系统:ubuntu⑴2.04.4-server
mysql-cluster-gpl⑺.3.7-linux-glibc2.5-x86_64.tar.gz
说明:
1、部署之前不要装Mysql,有的人部署是用apt-get安装的,但是如果你使用cluster2进制,就不要预装发行版
2、有的系统有些命令使用不了,所以这些也要注意
准备:3台主机
Mgm节点:192.168.1.71
Data节点:192.168.1.72 192.168.1.72
SQL节点:192.168.1.73 192.168.1.73
以下以72为例,73是相同的配置方法
1 安装管理节点
tar -zvxf mysql-cluster-gpl⑺.3.7-linux-glibc2.5-x86_64.tar.gz
mv mysql-cluster-gpl⑺.3.7-linux-glibc2.5-x86_64 /usr/local/mysql
cd /usr/local/mysql
mkdir -p /usr/local/mysql/ndbdata
mkdir /usr/local/mysql/mysql-cluster/
vi /usr/local/mysql/mysql-cluster/config.ini
==================配置文件内容===================
# ndb_mgmd -f path/mysql-cluster/config.ini --configdir=path/mysql-cluster/
[NDBD DEFAULT]
NoOfReplicas=2
DataMemory=128M
IndexMemory=32M
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
DataDir=/usr/local/mysql/mysql-cluster
[TCP DEFAULT]
# Section for the cluster management node
[NDB_MGMD]
NodeId=1
HostName=192.168.1.71
[NDBD]
# IP address of the first storage node
NodeId=2
HostName=192.168.1.72
DataDir= /usr/local/mysql/ndbdata
[NDBD]
# IP address of the second storage node
NodeId=3
HostName=192.168.1.73
DataDir=/usr/local/mysql/ndbdata
# one [MYSQLD] per storage node
[MYSQLD]
HostName=192.168.1.72
[MYSQLD]
HostName=192.168.1.73
[MYSQLD]
[MYSQLD]
# 注意上面多预留两个空闲的MYSQLD
====================================================
2 72上安装数据节点
tar -zvxf mysql-cluster-gpl⑺.3.7-linux-glibc2.5-x86_64.tar.gz
mv mysql-cluster-gpl⑺.3.7-linux-glibc2.5-x86_64 /usr/local/mysql
cd /usr/local/mysql
mkdir -p /usr/local/mysql/ndbdata
拷贝履行文件
添加履行文件路径
vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
创建配置文件:
vi /etc/mysql/my.cnf
分别在主机添加以下内容:
[mysql_cluster]
ndb-connectstring=192.168.1.71
3 72上安装SQL节点
tar -zvxf mysql-cluster-gpl⑺.3.7-linux-glibc2.5-x86_64.tar.gz
mv mysql-cluster-gpl⑺.3.7-linux-glibc2.5-x86_64 /usr/local/mysql
cd /usr/local/mysql
添加mysql用户
groupadd mysql
useradd -g mysql mysql
添加权限
chown -R mysql:mysql /usr/local/mysql
拷贝配置文件
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
初始化数据库
cd /usr/local/mysql
scripts/mysql_install_db --user=mysql
拷贝守护进程所需文件
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
添加履行文件路径
vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
更改配置文件
vi /etc/mysql/my.cnf
分别编辑以下信息:
[mysqld]
port = 3306
socket = /tmp/mysql.sock
ndbcluster
ndb-connectstring=192.168.1.71
bind-address = 192.168.1.72
[mysql_cluster]
ndb-connectstring=192.168.1.71
4 启动及关闭Cluster
启动顺序:管理节点--->数据节点--->SQL节点
1,启动管理节点
cd /usr/local/mysql/bin/
启动管理节点,注意第1启动请加--initail
ndb_mgmd -f path/mysql-cluster/config.ini --configdir=path/mysql-cluster/
ndb_mgm -e show #查看节点连接情况
2,启动数据节点
/usr/local/mysql/bin/ndbd --initial(第1次启动是用这个命令)
/usr/local/mysql/bin/ndbd(以后用这个命令)
3,启动SQL节点
/usr/local/mysql/bin/mysqld_safe --user=mysql &
或
/etc/init.d/mysqld restart
以后登录72的mysql服务器, 在test库中建立1个使用ndb引擎的表,
插入数据,正常情况下另外一台msyql服务器应当产生相同结果
生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠