mysql cluster安装

节点规划,因为是在vm上,也只能起3个节点了:
管理节点(ndb_mgmd):192.168.0.124

SQL节点1(mysqld): 192.168.0.125
SQL节点1(mysqld): 192.168.0.126

数据节点(ndbd): 192.168.0.125
数据节点(ndbd): 192.168.0.126

主机与ip
mgm      192.168.0.124         
sqld     192.168.0.125         
ndbd     192.168.0.126         


使用的软件:mysql-cluster-gpl-7.1.18-linux-x86_64-glibc23.tar.gz


配置信息
/etc/my.cnf
存储节点
[mysqld]
ndbcluster
ndb-connectstring=192.168.0.124
--做了一测试,存储节点只有以下两句节点能正常启动。
[mysql_cluster]
ndb-connectstring=192.168.0.124

sql节点与数据节点同在一台主机配置
[mysqld]
basedir=/user/local/mysql
datadir=/user/local/mysql/data
port=3306
user=mysql
socket=/tmp/mysql.sock
ndbcluster
ndb-connectstring=192.168.0.124
[ndbd]
connect-string=192.168.0.126
[ndbd_mgm]
connect-string=192.168.0.124
[ndbd_mgmd]
config-file=/opt/mysql_cluster/conf/config.ini
[mysql_cluster]
ndb-connectstring=192.168.0.124

/etc/config.ini
配置管理节点:
[NDBD DEFAULT]
NoOfReplicas=1
DataMemory=600M
IndexMemory=100M
[TCP DEFAULT]
portnumber=2202
[NDB_MGMD]
nodeid=1
hostname=192.168.0.124
datadir=/usr/local/mysql/data
[NDBD]
nodeid=2
hostname=192.168.0.126
datadir=/usr/local/mysql/data
[MYSQLD]
nodeid=3
hostname=192.168.0.126


节点启动
管理节点启动:
[root@MGM mysql_cluster]# ./mysql/bin/ndb_mgmd -f /opt/mysql_cluster/conf/config.ini --configdir=/opt/mysql_cluster/conf

数据节点启动:
数据节点有些特殊,如果是第一次启动,则需要增加参数 –initial,如果不是,直接启动即可
./mysql/bin/ndbd --defaults-file=/opt/mysql_cluster/conf/my.cnf --initial  

启动sql节点 service mysqld start,前提是要配置mysqld服务

添加新节点后,重新加载管理节点配置信息
[root@MGM mysql]# ./ndb_mgmd -f /etc/config.ini --initial

[root@MGM mysql]# ./ndb_mgmd -f /etc/config.ini --reload



遇到的一些问题
启动sql节点时出现错误
[root@NDBD mysql]# service mysqld start
Starting MySQL..Manager of pid-file quit without updating f[FAILED]
查看日志文件内容
NDBD.err:
120208 21:00:32 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
120208 21:00:33 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/mysql/bin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
120208 21:00:33 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120208 21:00:33  InnoDB: Initializing buffer pool, size = 8.0M
120208 21:00:33  InnoDB: Completed initialization of buffer pool
120208 21:00:33  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
120208 21:00:33 mysqld_safe mysqld from pid file /usr/local/mysql/data/NDBD.pid ended
解决方法sql节点配置(my.cnf)中的user=nobody改为user=mysql,还不行可以重新运行:
[root@NDBD mysql]# scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

当管理节点将NoOfReplicas=1设置为NoOfReplicas=2时,同时启动数据节点会遇到像下面这样的错误,导致数据节点与sql节点都不能正常启动.暂且记录下该问题。
Node 2: Forced node shutdown completed. Occured during startphase 1. Caused by error 2350: 'Invalid configuration received from Management Server(Configuration error). Permanent error, external action needed'



登录并进行测试
[root@NDBD mysql]# ./bin/mysql -uroot
测试cluster是否正常
在一节点执行:
[root@NDBD mysql]# ./bin/mysql -uroot
建立表并插入数据
create table cluster_test(
id int,
name varchar(20)
)engine = ndbcluster default charset utf8;

insert into cluster_test values(1, 'hello');
insert into cluster_test values(2, 'world');
commit;

在别一节点看是否能够访问,能够访问说明是正常的。

1.启动各个节点的顺序永远是:MGM node,Data Node,SQL node。
2.engine=ndbcluster或者engine=ndb的表才能使用Data node所存储。其他engine即放在SQL node本地,就像单机版一样。
3.多个节点放在一台机器上时,需要给每个节点分配不同端口号以此区分。   --没有使用


具体的安装步骤可以参照mysql参考手册


发布了168 篇原创文章 · 获赞 16 · 访问量 42万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章