你好,游客 登录 注册 搜索
背景:
阅读新闻

MySQL Cluster安装配置

[日期:2013-07-22] 来源:CSDN  作者:john [字体: ]

环境
CentOS6.4_64
网络配置
192.168.10.167 os-14
192.168.10.166 os-13
192.168.10.151 os-1
192.168.10.152 os-2
192.168.10.153 os-3
192.168.10.154 os-4
192.168.10.155 os-5
192.168.10.156 os-6
架构和资源分配
192.168.10.151=====集群管理(CMGM)
###################################
192.168.10.154 os-4||
192.168.10.152 os-2||===MySQLServer(SQL)
192.168.10.153 os-3||
###################################
192.168.10.155 os-5  ||
192.168.10.156 os-6  ||===Storage(NDB)
192.168.10.167 os-14 ||
192.168.10.166 os-13 ||

error:
file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-Cluster-server-gpl-7.2.12-1.rhel5.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
解决方法:
yum -y remove mysql-libs-5.1.66-2.el6_3.x86_64

error:
[root@os-13 ~]# cd /usr/src/mysql/ && rpm -ivh /usr/src/mysql/MySQL-Cluster-server-gpl-7.2.12-1.rhel5.x86_64.rpm
error: Failed dependencies:
    libaio.so.1()(64bit) is needed by MySQL-Cluster-server-gpl-7.2.12-1.rhel5.x86_64
    libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-Cluster-server-gpl-7.2.12-1.rhel5.x86_64
    libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-Cluster-server-gpl-7.2.12-1.rhel5.x86_64
解决方法:
yum install libaio

error:
[root@os-14 mysql]#  rpm -ivh /usr/src/mysql/MySQL-Cluster-server-gpl-7.2.12-1.rhel5.x86_64.rpm
error: Failed dependencies:
    /usr/bin/perl is needed by MySQL-Cluster-server-gpl-7.2.12-1.rhel5.x86_64
解决方法:
yum -y install perl

开始安装(每个节点)
[root@os-1 mysql]# rpm -ivh MySQL-Cluster-server-gpl-7.2.12-1.rhel5.x86_64.rpm
Preparing...                ########################################### [100%]
  1:MySQL-Cluster-server-gp########################################### [100%]
[root@os-1 MySQLCluster]# mkdir /home/mysql && chown -R mysql.mysql /home/mysql
[root@os-1 MySQLCluster]# vi mysqlcluster.ini
[ndbd default]
NoOfReplicas=2
DataMemory=80M
IndexMemory=18M

[tcp default]
portnumber=2202

[ndb_mgmd]
hostname=192.168.10.151
datadir=/home/mysql

[ndbd]
hostname=192.168.10.155
datadir=/home/mysql

[ndbd]
hostname=192.168.10.156
datadir=/home/mysql

[ndbd]
hostname=192.168.10.166
datadir=/home/mysql

[ndbd]
hostname=192.168.10.167
datadir=/home/mysql

[mysqld]
hostname=192.168.10.153

[mysqld]
hostname=192.168.10.152

[mysqld]
hostname=192.168.10.154

配置NDBD存储节点和sql节点
[root@os-2 mysql]# vi /etc/my.cnf
[client]
socket=/tmp/mysql.sock

[mysqld]
ndbcluster
datadir=/home/mysql
socket=/tmp/mysql.sock
ndb-connectstring=192.168.10.151
old_passwords=1

[mysql_cluster]
ndb-connectstring=192.168.10.151

在每一个数据节点NDBD和SQL节点的机器上执行如下步骤:
scripts/mysql_install_db --user=mysql --datadir=/home/mysql
例子:
[root@os-2 mysql]# mysql_install_db --user=mysql --datadir=/home/mysql
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/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h os-2 password 'new-password'

Alternatively you can run:
/usr/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 ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

启动Cluster
注意启动顺序:首先是管理节点,然后是NDBD节点,最后是SQL节点。

启动CMGM
[root@os-1 mysql-cluster]# ndb_mgmd -f /etc/MySQLCluster/mysqlcluster.ini
MySQL Cluster Management Server mysql-5.5.30 ndb-7.2.12
[root@os-1 mysql-cluster]# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)]    4 node(s)
id=2 (not connected, accepting connect from 192.168.10.155)
id=3 (not connected, accepting connect from 192.168.10.156)
id=4 (not connected, accepting connect from 192.168.10.166)
id=5 (not connected, accepting connect from 192.168.10.167)

[ndb_mgmd(MGM)]    1 node(s)
id=1    @192.168.10.151  (mysql-5.5.30 ndb-7.2.12)

[mysqld(API)]    3 node(s)
id=6 (not connected, accepting connect from 192.168.10.153)
id=7 (not connected, accepting connect from 192.168.10.152)
id=8 (not connected, accepting connect from 192.168.10.154)

启动NDBD节点
[root@os-6 mysql]# ndbd --initial  #首次启动加initial进行初始化,其他情况就不加任何选项
2013-05-06 15:52:41 [ndbd] INFO    -- Angel connected to '192.168.10.151:1186'
2013-05-06 15:52:41 [ndbd] INFO    -- Angel allocated nodeid: 3
在OS-1上show
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)]    4 node(s)
id=2    @192.168.10.155  (mysql-5.5.30 ndb-7.2.12, Nodegroup: 0, Master)
id=3    @192.168.10.156  (mysql-5.5.30 ndb-7.2.12, Nodegroup: 0)
id=4    @192.168.10.166  (mysql-5.5.30 ndb-7.2.12, Nodegroup: 1)
id=5    @192.168.10.167  (mysql-5.5.30 ndb-7.2.12, Nodegroup: 1)

[ndb_mgmd(MGM)]    1 node(s)
id=1    @192.168.10.151  (mysql-5.5.30 ndb-7.2.12)

[mysqld(API)]    3 node(s)
id=6 (not connected, accepting connect from 192.168.10.153)
id=7 (not connected, accepting connect from 192.168.10.154)
id=8 (not connected, accepting connect from 192.168.10.154)

启动SQL节点
[root@os-3 mysql]# mysqld_safe --user=mysql &
[1] 2501
[root@os-3 mysql]# 130506 16:01:16 mysqld_safe Logging to '/home/mysql/os-3.err'.
130506 16:01:16 mysqld_safe Starting mysqld daemon with databases from /home/mysql
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)]    4 node(s)
id=2    @192.168.10.155  (mysql-5.5.30 ndb-7.2.12, Nodegroup: 0, Master)
id=3    @192.168.10.156  (mysql-5.5.30 ndb-7.2.12, Nodegroup: 0)
id=4    @192.168.10.166  (mysql-5.5.30 ndb-7.2.12, Nodegroup: 1)
id=5    @192.168.10.167  (mysql-5.5.30 ndb-7.2.12, Nodegroup: 1)

[ndb_mgmd(MGM)]    1 node(s)
id=1    @192.168.10.151  (mysql-5.5.30 ndb-7.2.12)

[mysqld(API)]    3 node(s)
id=6    @192.168.10.153  (mysql-5.5.30 ndb-7.2.12)
id=7    @192.168.10.152  (mysql-5.5.30 ndb-7.2.12)
id=8    @192.168.10.154  (mysql-5.5.30 ndb-7.2.12)

测试:
在sqlserver上进行mysql -uroot连接测试

推荐阅读:

MySQL Cluster 备份与恢复 http://www.linuxidc.com/Linux/2013-06/85295.htm

MySQL Cluster 3台机器搭建集群环境 DOC  http://www.linuxidc.com/Linux/2013-01/78249.htm

MySQL Cluster7.2在线增加数据节点存在重大弊端 http://www.linuxidc.com/Linux/2012-08/67605.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款