Home > Database > Mysql Tutorial > body text

【mysql集群】mysql集群配置

WBOY
Release: 2016-06-07 15:52:35
Original
1007 people have browsed it

http://topic.csdn.net/u/20100621/16/c9436c17-374c-4c3a-b075-a18670143fd1.html MySql-Cluster安装 系统 centos5.1 32位(如何是64位下相应64位的rpm包) http://dev.mysql.com/get/Downloads/MySQL-Cluster-7.0和下面的包名对应 一共有5个包: MySQL-Clust

 

http://topic.csdn.net/u/20100621/16/c9436c17-374c-4c3a-b075-a18670143fd1.html

 

 MySql-Cluster安装

系统 centos5.1 32位(如何是64位下相应64位的rpm包)

http://dev.mysql.com /get/Downloads/MySQL-Cluster-7.0和下面的包名对应

一共有5个包:

MySQL-Cluster-gpl-client-7.1.3-1.rhel5.i386.rpm

MySQL-Cluster-gpl-management-7.1.3-1.rhel5.i386.rpm

MySQL-Cluster-gpl-server-7.1.3-1.rhel5.i386.rpm

MySQL-Cluster-gpl-storage-7.1.3-1.rhel5.i386.rpm

MySQL-Cluster-gpl-tools-7.1.3-1.rhel5.i386.rpm

 

3台centos 服务器:

管理节点(ndb_mgmd):192.168.1.14

 

SQL 节点1(mysqld): 192.168.1.15

SQL节点1(mysqld): 192.168.1.11

 

数 据节点(ndbd): 192.168.1.15

数据节点(ndbd): 192.168.1.11



  

 

//------------------------------------------------------------------ 以这个开始(七台机子都这个操做)

首先要做的是把这七台机子的防火墙关掉(如何不关的话每个节点都连不通)

 

关 闭防火墙:

Service iptables stop;

Flushing firewall rules: [ OK ]

Setting chains to policy ACCEPT: filter [ OK ]

Unloading iptables modules: [ OK ]

如何这样关闭成功; 

 

创建文件夹:

存 储节点:mkdir /var/lib/mysql/data  

管理结点:mkdir /var/lib/mysql-cluster  

Sql结点:要不要都行  

 

给两个文件赋 权限:

chmod -R 1777 /var/lib/mysql

chmod -R 1777 /var/lib/ mysql-cluster  

//------------------------------------------------------------------ 以这个结束

 

管理节点安装:

MySQL-Cluster-gpl-management-7.0.9-0.rhel4.x86_64.rpm;

MySQL-Cluster-gpl-tools-7.0.9-0.rhel4.x86_64.rpm;

Rpm –ivh MySQL-Cluster-gpl-management-7.0.9-0.rhel4.x86_64.rpm

Rpm –ivh MySQL-Cluster-gpl-tools-7.0.9-0.rhel4.x86_64.rpm

 

vi /var/lib/mysql-cluster/config.ini

 

[ndbd default]

NoOfReplicas=2

DataMemory=80M

IndexMemory=18M

[tcp default]

SendBufferMemory=2M

ReceiveBufferMemory=2M

[NDB_MGMD DEFAULT]

PortNumber=1186

Datadir=/var/lib/mysql-cluster

[ndb_mgmd]

Id=1

HostName= 192.168.1.14

[ndbd]

Id=2

HostName=192.168.1.15

datadir=/var/lib/mysql/data

[ndbd]

Id=3

HostName= 192.168.1.11

datadir=/var/lib/mysql/data

[mysqld]

Id=14

HostName=192.168.1.15

[mysqld]

Id=15

HostName=192.168.1.11

[mysqld]

Id=16

 

//启动管理节点
ndb_mgmd -f /var/lib/mysql-cluster/config.ini

/********************* 以上是安装管理节点**************************/

 

 

存储节点安装

MySQL-Cluster-gpl-storage-7.0.9-0.rhel4.x86_64.rpm

Rpm –ivh MySQL-Cluster-gpl-storage-7.0.9-0.rhel4.x86_64.rpm

vi /etc/my.cnf //确认添加修改了如下部分
[mysqld]
max_connections = 100
slow_query_log = /var/lib/mysql-cluster/slow_query.log
long_query_time = 1
datadir = /var/lib/mysql-cluster
ndbcluster
ndb-connectstring=192.168.1.14

[mysql_cluster]
ndb-connectstring= 192.168.1.14

 

初始化启动数据节点的数据库,
注意://ndbd –initial 不能同时在所有数据节点机器上执行,否者会删除所有数据.即该命令只能在其中一台数据节点中执行
ndbd –initial

 

如 何这样:

[ndbd] INFO -- Configuration fetched from '10.50.8.8:1186', generation: 1

 

sql节点的安装:

MySQL-Cluster-gpl-client-7.0.9-0.rhel4.x86_64.rpm

MySQL-Cluster-gpl-server-7.0.9-0.rhel4.x86_64.rpm

 

Rpm –ivh MySQL-Cluster-gpl-server-7.0.9-0.rhel4.x86_64.rpm

Rpm –ivh MySQL-Cluster-gpl-client-7.0.9-0.rhel4.x86_64.rpm --nodeps –force红色的一定写上不然安不上.

vi /etc/my.cnf //确认添加修改了如下部分
[mysqld]

ndbcluster

ndb-connectstring=192.168.1.14:1186

[mysql_cluster]

ndb-connectstring=192.168.1.14:1186

 

启动sql结点 我用这个 mysqld_safe &没有错

执行后

100308 13:46:32 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.

100308 13:46:32 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

Sql 结点就成功了

 

在管理节点的机子下(192.168.1.14)

ndb_mgm

 

ndb_mgm> show


Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @192.168.1.15 (mysql-5.1.44 ndb-7.1.3, Nodegroup: 0, Master)
id=3 @192.168.1.11 (mysql-5.1.44 ndb-7.1.3, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1 @192.168.1.14 (mysql-5.1.44 ndb-7.1.3)

[mysqld(API)] 3 node(s)
id=14 @192.168.1.15 (mysql-5.1.44 ndb-7.1.3)
id=15 @192.168.1.11 (mysql-5.1.44 ndb-7.1.3)
id=16 (not connected, accepting connect from any host)


 

如何出现上面的信息就成功了.

出 现not connected, accepting connect from any host是sql节点没有启来。

出现 mysql-5.1.39 ndb-7.0.9,staring Nodegroup: 0 是说明存储节点没有启来。如何你的配置都没有错的话(那是你的防火墙没有关)

 

 /*********下面是添加节点、重启节点这些操作******************/

动态更新节点

关闭管理 节点我这里的管理节点是1

ndb_mgm>1 stop

退出ndb_mgm

shell>vi /var/lib/mysql-cluster/config.ini

如果我们加一个ndbd节点

[ndbd]

Id=6

HostName= 10.50.8.13

datadir=/var/lib/mysql/data

保存退出

Ndb_mgmb –f config.ini –reload

 

2010-03-08 13:47:15 [MgmtSrvr] INFO -- NDB Cluster Management Server. mysql-5.1.39 ndb-7.0.9b

2010-03-08 13:47:16 [MgmtSrvr] INFO -- Reading cluster configuration from 'config.ini'

就从启成功了

把每个节点重启一下

Ndb节点在管理节点上执行 ndb_mgm>2 restart (如何你安上面安装的话应该知道进入ndb_mgm里)

Sql 节点在sql节点上 执行 service myql stop mysqld_save;

都做完了在管理节点上 show一下看看结果。

 

1. 管理节点启动:ndb_mgmd ndb_mgmd -f /var/lib/mysql-cluster/config.ini ndb_mgmd –f config.ini –reload


2. 数据节点启动:ndbd启动 ndb_mgm>2 restart 数据节点重启 
3. SQL节点启动: mysqld_safe & 关闭:service mysql stop mysqld_save

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template