赞
踩
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/53079933
1、下载mysql-cluster 7.3.7
http://dev.mysql.com/downloads/cluster/
2、环境清理及安装
# yum -y remove mysql
# rpm -qa | grep mysql*
# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
2
)环境准备
创建文件夹(分如下3个类来创建对应的文件夹)
存储节点:# mkdir /var/lib/mysql/data
管理节点:# mkdir /var/lib/mysql-cluster SQL节点:可不用 文件夹授权
进程DIR:# mkdir /var/run/mysqld
使用如下的命令来变更权限保证可写入:
# chmod -R 1777 /var/lib/mysql
# chmod -R 1777 /var/run/mysqld
# chmod -R 1777 /var/lib/mysql-cluster
3
)安装mysql-cluster
首先解压MySQL-Cluster-gpl-7.4.2-1.el6.x86_64.rpm-bundle.tar
# tar xvf MySQL-Cluster-gpl-7.4.2-1.el6.x86_64.rpm-bundle.tar
然后执行如下命令安装
# rpm -ivh MySQL-Cluster-server-gpl-7.3.4-1.el6.x86_64.rpm
# rpm -ivh MySQL-Cluster-client-gpl-7.3.4-1.el6.x86_64.rpm
特别注意,当安装完毕server gpl包后,将出现如下提示信息,提醒我们整个cluster安装后的初次超级账户密码存在/root/.mysql_secret这个文件当中。
---------------------------------------------------------------------------------------------------------------------
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test database.
This is strongly recommended for production servers.
-----------------------------------------------------------
2、配置管理节点
# cd /var/lib/mysql-cluster
# vi config.ini
2)配置config.ini文件
[computer]
Id=mgr-server-01
HostName=192.168.100.218
[mgm default]
datadir=/var/lib/mysql-cluster
[mgm]
HostName=192.168.100.218
NodeId=60
ExecuteOnComputer=mgr-server-01
PortNumber=1186
ArbitrationRank=2
[ndbd default]
NoOfReplicas=2
DataMemory=500M
IndexMemory=500M
[ndbd]
HostName=192.168.100.217
DataDir=/var/lib/mysql
NodeId=1
[ndbd]
HostName=192.168.100.218
DataDir=/var/lib/mysql
NodeId=2
[mysqld]
HostName=192.168.100.217
NodeId=81
[mysqld]
HostName=192.168.100.218
NodeId=82
3、SQL节点和数据节点的配置
[client]
socket=/var/lib/mysql/mysql.sock
[mysqld]
max_connections=100
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
ndbcluster
ndb-connectstring=192.168.100.218
[mysqld_safe]
log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid
pid-file=/var/lib/mysql/mysqld.pid
[mysql_cluster]
ndb-connectstring=192.168.100.218
4、MySQL Cluster初次启动命令以及用户密码更改调整:(请严格按照次序启动)
ndb_mgm> show
Connected to Management Server at: 192.168.100.218:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=1 @192.168.100.217 (mysql-5.6.21 ndb-7.4.2, Nodegroup: 0)
id=2 @192.168.100.218 (mysql-5.6.21 ndb-7.4.2, Nodegroup: 0, *)
[ndb_mgmd(MGM)] 1 node(s)
id=60 @192.168.100.218 (mysql-5.6.21 ndb-7.4.2)
[mysqld(API)] 2 node(s)
id=81 @192.168.100.217 (mysql-5.6.21 ndb-7.4.2)
id=82 @192.168.100.218 (mysql-5.6.21 ndb-7.4.2)
如果有节点没连接,如下,id=81一行,表示没连接,检查问题故障点
ndb_mgm> show
Cluster Configuration
--------------------
[ndbd(NDB)] 2 node(s)
id=1 @192.168.100.217 (mysql-5.6.21 ndb-7.4.2, Nodegroup: 0)
id=2 @192.168.100.218 (mysql-5.6.21 ndb-7.4.2, Nodegroup: 0, *)
[ndb_mgmd(MGM)] 1 node(s)
id=60 @192.168.100.218 (mysql-5.6.21 ndb-7.4.2)
[mysqld(API)] 2 node(s)
id=81 (not connected, accepting connect from 192.168.100.217)
id=82 @192.168.100.218 (mysql-5.6.21 ndb-7.4.2)
2)修改密码
mysql -u root -p;
随机密码(具体请参见/root/.mysql_secret文件获取),进入后使用如下指令修改密码:
SET PASSWORD = PASSWORD('新密码');
但是这个新密码,必须是hash值,所以要使用如下方式获取密码字符串的hash值
select password('111111');
然而执行上面命令,会让你先设置密码,郁闷,又绕回来了,那就去其他地方的mysql上执行下吧
use mysql;
delete from user;
grant all on *.* to root@'%' identified by "111111" with grant option;
flush privileges;
quit;
然后,可以使用明文密码登陆了
create database clustertest;
use clustertest;
CREATE TABLE testtable(Count INT) ENGINE=NDBCLUSTER;
注意:ENGINE=NDBCLUSTER; 引擎必须使用NDBCLUSTER才可以同步,否则不会进行同步
insert into testtable values (1);
启动217的mysql服务,使用show确认217的数据库节点已经连接上了,执行如下语句
select * from testtable;
如果发现有数据,则表示功能完备
# pgrep mysqld
# ps aux | grep nbdb
如果没有,找到对应的pid进行kill 操作即可
ndb_mgmd -f /var/lib/mysql-cluster/config.ini
ndbd
mysqld_safe --defaults-file=/etc/my.cnf --explicit_defaults_for_timestamp &
备注:
MySQL Cluster 备份与恢复 http://www.linuxidc.com/Linux/2013-06/85295.htm
MySQL Cluster安装配置 http://www.linuxidc.com/Linux/2013-07/87705.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
搭建MySQL-Cluster集群架构 http://www.linuxidc.com/Linux/2014-05/102218.htm
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。