Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4732798
  • 博文数量: 930
  • 博客积分: 12070
  • 博客等级: 上将
  • 技术积分: 11448
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-15 16:57
文章分类

全部博文(930)

文章存档

2011年(60)

2010年(220)

2009年(371)

2008年(279)

分类: LINUX

2010-10-07 15:27:19

########################################################################

 

mysqlndb集群是一个热备与负载均衡的mysql的数据库集群,安全性可达到99.99%,是有mysql节点,数据库节点,管理节点组成。如下图

 

    mysql节点A-----------mysql节点B

      |      \          /          |

      |        管理节点     |         

      |      /          \          |

    数据节点A------------数据节点B

 

########################################################################

 

############设备软件需求:##############

 

5台服务器,RHEL5.2操作系统,mysql-cluster-gpl-7.1.4b-linux-i686-glibc23.tar.gz

 

192.168.0.13   管理节点

192.168.0.61   mysql节点A

192.168.0.62   mysql节点B

192.168.0.63   数据节点A

192.168.0.64   数据节点B

 

 

配置方案:

 

########1.节点软件安装:#############

 

mysql-cluster-gpl-7.1.4b-linux-i686-glibc23.tar.gz分别在mysql节点AB,数据节点AB上安装。

# useradd mysql

# tar zxvf mysql-cluster-gpl-7.1.4b-linux-i686-glibc23.tar.gz

# mv mysql-cluster-gpl-7.1.4b-linux-i686-glibc23 /usr/loacl/mysql

# chown -R mysql.mysql /usr/local/mysql

 

########2.配置mysql节点:(192.168.0.61)###########

 

# vim /etc/my.cnf

[mysqld]      # mysql服务进程参数

ndbcluster

ndb-connectstring=192.168.0.13

 

[mysql_cluster]  # 集群服务进程指向管理节点

ndb-connectstring=192.168.0.13

 

# scp /etc/my.cnf 192.168.0.62:/etc/my.cnf   两个sql节点的配置完全相同,可以copy.

 

 

#########3.配置数据节点:(192.168.0.63)#############

 

# vim /etc/my.cnf

[mysqld]

Datadir=/usr/local/mysql/data  #数据在本地的存储位置

ndbcluster

ndb-connectstring=192.168.0.13

 

[mysql_cluster]

ndb-connectstring=192.168.0.13   #都指向管理节点

 

# scp /etc/my.cnf 192.168.0.63:/etc/my.cnf   两个数据节点的配置完全相同,可以copy.

 

 

#############4.配置管理节点:(192.168.0.13)############

 

# cat /usr/local/mysql/cluster-conf/config.ini   此目录与文件要自己创建。

 

[ndbd default]

NoOfReplicas=2      数据节点的个数,此处为两个。

DataMemory=80M      数据存储占本地内存数

IndexMemory=18M     数据索引占本地内存数

 

[ndb_mgmd]          管理节点

Id=1

Hostname=192.168.0.13

Datadir=/var/log/   日志存放位置

 

[ndbd]               数据节点

Id=2

Hostname=192.168.0.63

Datadir=/usr/local/mysql/data

 

[ndbd]

Id=3

Hostname=192.168.0.64

Datadir=/usr/local/mysql/data

 

[mysqld]            sql节点

Id=4 

Hostname=192.168.0.61

 

[mysqld]

Id=5

Hostname=192.168.0.62

 

复制其他任何一个节点上的以下文件到管理节点

 

# scp 192.168.0.61:/usr/loacl/mysql/bin/ndb_mgmd /bin/ndb_mgmd

# scp 192.168.0.61:/usr/loacl/mysql/bin/ndb_mgmd /bin/ndb_mgm

 

############5.管理节点启动 #############

 

# /bin/ndb_mgmd -f /usr/loca/mysql/cluster-conf/config.ini  启动管理节点

2010-07-08 22:02:52 [MgmtSrvr] INFO     -- NDB Cluster Management Server. mysql-5.1.44 ndb-7.1.4b

2010-07-08 22:02:52 [MgmtSrvr] INFO     -- Loaded config from '/usr/local/mysql/mysql-cluster/ndb_1_config.bin.1'

 

# /bin/ndb_mgm        查看各节点情况

-- NDB Cluster -- Management Client --

ndb_mgm> show

Connected to Management Server at: localhost:1186

Cluster Configuration

---------------------

[ndbd(NDB)]     2 node(s)

id=2 (not connected, accepting connect from 192.168.0.63)

id=3 (not connected, accepting connect from 192.168.0.64)

 

[ndb_mgmd(MGM)] 1 node(s)

id=1    @192.168.0.13  (mysql-5.1.44 ndb-7.1.4)

 

[mysqld(API)]   2 node(s)

id=4 (not connected, accepting connect from 192.168.0.61)

id=5 (not connected, accepting connect from 192.168.0.62)

 

此时发现与其他节点无法连接,因为其他节点还没有启动。

 

############6.启动数据节点#############

 

# /usr/local/mysql/bin/ndbd

2010-07-08 22:15:58 [ndbd] INFO     -- Configuration fetched from '192.168.0.13:1186', generation: 1

 

记得两个节点都启动。如果现在在管理节点上观察,会发现数据节点启动成功,一个主的,一个从的。

 

############7.启动sql节点##############

 

首先初始化mysql

# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --ldata=/usr/loacl/mysql/data/

Installing MySQL system tables...

OK

Filling help tables...

OK                           初始化成功

 

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system

 

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

 

/usr/local/mysql//bin/mysqladmin -u root password 'new-password'

/usr/local/mysql//bin/mysqladmin -u root -h localhost password 'new-password'

 

Alternatively you can run:

/usr/local/mysql//bin/mysql_secure_installation

 

which will also give you the option of removing the test

databases and anonymous user created by default.  This is

strongly recommended for production servers.

 

See the manual for more instructions.

 

You can start the MySQL daemon with:

cd /usr/local/mysql/ ; /usr/local/mysql//bin/mysqld_safe &

 

You can test the MySQL daemon with mysql-test-run.pl

cd /usr/local/mysql//mysql-test ; perl mysql-test-run.pl

 

Please report any problems with the /usr/local/mysql//scripts/mysqlbug script!

 

 

# /usr/local/mysql/bin/mysqld_safe &   启动(两个SQL节点都要启动)

[1] 20112

100708 22:22:37 mysqld_safe Logging to '/usr/local/mysql/data/localhost.err'.

100708 22:22:37 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

 

##########8.再去管理节点观察##############

 

# /bin/ndb_mgm

ndb_mgm> show

Cluster Configuration

---------------------

[ndbd(NDB)]     2 node(s)

id=2    @192.168.0.63  (mysql-5.1.44 ndb-7.1.4, Nodegroup: 0, Master)

id=3    @192.168.0.64  (mysql-5.1.44 ndb-7.1.4, Nodegroup: 0)

 

[ndb_mgmd(MGM)] 1 node(s)

id=1    @192.168.0.13  (mysql-5.1.44 ndb-7.1.4)

 

[mysqld(API)]   2 node(s)

id=4    @192.168.0.61  (mysql-5.1.44 ndb-7.1.4)

id=5    @192.168.0.62  (mysql-5.1.44 ndb-7.1.4)

 

显示全部连接成功,此时可以说配置完毕!

阅读(1140) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~