Chinaunix首页 | 论坛 | 博客
  • 博客访问: 371327
  • 博文数量: 166
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1640
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-05 11:44
个人简介

文章不在长,坚持不懈记录下努力前行的脚步

文章分类

全部博文(166)

文章存档

2017年(19)

2016年(59)

2015年(88)

我的朋友

分类: Mysql/postgreSQL

2015-08-10 15:49:44

mysql集群
===================
集群成员:
管理节点
数据节点
sql节点
===================
ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-Cluster-7.3/
1. 所有节点均不安装和启动mysql-server软件包,仅安装集群软件包 mysql-cluster-gpl-7.3.4.tar.gz
2. Mysql Cluster采用的是NDB存储引擎,因此在建表时必须指定ENGINE为ndbcluster,这是一种内存
式的存储引擎,因此对内存要求很高
-------------------------------
拓部结构
              192.168.25.253              管理节点 mgm
      192.168.25.11   192.168.25.108         sql节点  sql1、sql2
      192.168.25.11   192.168.25.108         数据节点 data1、data2
----------------------------------------------------------------
一、所有节点
IP、Iptables、SELinux、hostname解析
[root@yang ~]# service mysqld stop
[root@yang ~]# chkconfig mysqld off
[root@yang ~]# mv /etc/my.cnf /etc/my.cnf.bak
二、安装集群
1、sql节点
[root@sql2 ~]# tar -xvf mysql-cluster-gpl-7.3.4-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
[root@sql2 ~]# ln -s /usr/local/mysql-cluster-gpl-7.3.4-linux-glibc2.5-x86_64/ /usr/local/mysql
[root@sql2 ~]# cd /usr/local/mysql
[root@sql2 mysql]# scripts/mysql_install_db --user=mysql
[root@sql2 mysql]# chown -R root .
[root@sql2 mysql]# chown -R mysql data
[root@sql2 mysql]# chgrp -R mysql .
[root@sql2 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/
[root@sql2 mysql]# chmod +x /etc/rc.d/init.d/mysql.server
[root@sql2 mysql]# chkconfig --add mysql.server
Data nodes.
[root@data1 ~]# rsync -va sql2:/usr/local/mysql/bin/ndbd /usr/local/bin/
[root@data1 ~]# rsync -va sql2:/usr/local/mysql/bin/ndbmtd /usr/local/bin/
[root@data1 ~]# chmod a+x /usr/local/bin/ndb*
Management nodes.
[root@mgm ~]# rsync -va sql2:/usr/local/mysql/bin/ndb_mgm* /usr/local/bin/
[root@mgm ~]# chmod a+x /usr/local/bin/ndb_mgm*
[root@mgm ~]# mkdir -p /usr/local/mysql/mysql-cluster
三、初始化mysql集群配置
1、配置数据节点和sql节点
[root@sql2 mysql]# vim /etc/my.cnf
[mysqld]
# Options for mysqld process:
ndbcluster
[mysql_cluster]
# Options for MySQL Cluster processes:
ndb-connectstring=192.168.25.1
[root@sql2 mysql]# rsync -va /etc/my.cnf data1:/etc/
[root@sql2 mysql]# rsync -va /etc/my.cnf data2:/etc/
2、配置管理节点  --需要修改
[root@mgm ~]# mkdir /var/lib/mysql-cluster
[root@mgm ~]# cd /var/lib/mysql-cluster
[root@mgm mysql-cluster]# vim config.ini
[ndbd default]
# Options affecting ndbd processes on all data nodes:
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
# 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.
[tcp default]
# TCP/IP options:
portnumber=3306 # This the default; however, you can use any
# port that is free for all the hosts in the cluster
# Note: It is recommended that you do not specify the port
# number at all and simply allow the default value to be used
# instead
[ndb_mgmd]
# Management process options:
id=1
hostname=192.168.25.1 # Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster # Directory for MGM node log files
[ndbd]
# Options for data node "data1":
id=10
hostname=192.168.25.4 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
[ndbd]
# Options for data node "data2":
id=11
hostname=192.168.25.5 # Hostname or IP address
datadir=/usr/local/mysql/data # Directory for this data node's data files
[mysqld]
# SQL node options:
id=20
hostname=192.168.25.3
四、集群启动初始化
1.管理节点
[root@mgm ~]# ndb_mgmd -f /var/lib/mysql-cluster/config.ini
MySQL Cluster Management Server mysql-5.6.15 ndb-7.3.4
2.数据节点
[root@data1 ~]# mkdir -p /usr/local/mysql/data
[root@data1 ~]# ndbd
[root@data2 ~]# mkdir -p /usr/local/mysql/data
[root@data2 ~]# ndbd
3.sql节点
[root@sql2 mysql]# /etc/init.d/mysql.server start
Starting MySQL.................................... [ OK ]
[root@sql2 mysql]# chkconfig mysql.server on
4.管理节点
[root@mgm ~]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @192.168.25.4 (mysql-5.6.15 ndb-7.3.4, Nodegroup: 0, *)
id=3 @192.168.25.5 (mysql-5.6.15 ndb-7.3.4, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.25.1 (mysql-5.6.15 ndb-7.3.4)
[mysqld(API)] 1 node(s)
id=4 @192.168.25.3 (mysql-5.6.15 ndb-7.3.4)
ndb_mgm>
阅读(675) | 评论(0) | 转发(0) |
0

上一篇:mysql源码安装

下一篇:top命令

给主人留下些什么吧!~~