ndb cluster部署

prepare host:

hadoop1 192.168.16.201  —-> management node

hadoop2 192.168.16.202  —-> data node

hadoop3 192.168.16.203  —-> data node

hadoop4 192.168.16.202  —-> sql node

hadoop5 192.168.16.203  —-> sql node

一、准备软件安装

# cd /root/software # tar xvf mysql-cluster-gpl-7.3.2-linux-glibc2.5-x86_64.tar.gz -C /usr/local

# cd /usr/local # mv mysql-cluster-gpl-7.3.2-linux-glibc2.5-x86_64 mysql

# vim ~/.bash_profile PATH=/usr/local/mysql/bin:$PATH

# source ~/.bash_profile

二、配置manage node

vim /usr/local/mysql/bin/config.ini

# file “config.ini” – showing minimal setup consisting of 1 data node,

# 1 management server, and 3 MySQL servers.

# The empty default sections are not required, and are shown only for

# the sake of completeness.

# Data nodes must provide a hostname but MySQL Servers are not required

# to do so.

# If you don’t know the hostname for your machine, use localhost.

# The DataDir parameter also has a default value, but it is recommended to

# set it explicitly.

# Note: [db], [api], and [mgm] are aliases for [ndbd], [mysqld], and [ndb_mgmd],

# respectively. [db] is deprecated and should not be used in new installations.

## TCP parameters

##

# Increasing the sizes of 2 buffers beyond the default values

# helps prevent bottlenecks due to slow disk I/O.

[tcp default]

SendBufferMemory=2M

ReceiveBufferMemory=2M

## Management Node parameters

# Use [ndb_mgmd default] to set the same data directory for each management server, just for ease of administration.

[ndb_mgmd default]

DataDir= /mysqldata/ndbdata

[ndb_mgmd]

HostName= 192.168.16.201

DataDir= /mysqldata/ndbdata

# NodeId=hadoop1-16201

## If you have more management server, just add the same section like [ndb_mgmd]

##

## Data Nodes options

##

[ndbd default]

NoOfReplicas= 2

# Using 2 replicas is recommended to guarantee availability of data;

# using only 1 replica does not provide any redundancy, which means

# that the failure of a single data node causes the entire cluster to

# shut down. We do not recommend using more than 2 replicas, since 2 is

# sufficient to provide high availability, and we do not currently test

# with greater values for this parameter.

LockPagesInMainMemory=1

# On Linux and Solaris systems, setting this parameter locks data node

# processes into memory. Doing so prevents them from swapping to disk,

# which can severely degrade cluster performance.

DataMemory=3072M IndexMemory=384M

# The values provided for DataMemory and IndexMemory assume 4 GB RAM

# per data node. However, for best results, you should first calculate

# the memory that would be used based on the data you actually plan to

# store (you may find the ndb_size.pl utility helpful in estimating

# this), then allow an extra 20% over the calculated values. Naturally,

# you should ensure that each data node host has at least as much

# physical memory as the sum of these two values.

# ODirect=1

# Enabling this parameter causes NDBCLUSTER to try using O_DIRECT

# writes for local checkpoints and redo logs; this can reduce load on

# CPUs. We recommend doing so when using MySQL Cluster on systems running

# Linux kernel 2.6 or later.

NoOfFragmentLogFiles=300

DataDir=/mysqldata/ndbdata

MaxNoOfConcurrentOperations=100000

SchedulerSpinTimer=400

SchedulerExecutionTimer=100

RealTimeScheduler=1

# Setting these parameters allows you to take advantage of real-time scheduling

# of NDB threads to achieve increased throughput when using ndbd. They

# are not needed when using ndbmtd; in particular, you should not set

# RealTimeScheduler for ndbmtd data nodes.

TimeBetweenGlobalCheckpoints=1000

TimeBetweenEpochs=200

DiskCheckpointSpeed=10M

DiskCheckpointSpeedInRestart=100M

RedoBuffer=32M

# CompressedLCP=1

# CompressedBackup=1

# Enabling CompressedLCP and CompressedBackup causes, respectively, local checkpoint files and backup files to be compressed,

# which can result in a space savings of up to 50% over noncompressed LCPs and backups.

# MaxNoOfLocalScans=64

MaxNoOfTables=1024

MaxNoOfOrderedIndexes=256

[ndbd]

HostName= 192.168.16.202

#NodeId=hadoop2-16202

[ndbd]

HostName= 192.168.16.203

#NodeId=hadoop2-16203

LockExecuteThreadToCPU=1

LockMaintThreadsToCPU=0

## SQL Nodes options

##

[mysqld]

HostName= 192.168.16.202

#NodeId=hadoop2-16204

[mysqld]

HostName= 192.168.16.203

#NodeId=hadoop2-16205

三、配置data nodes

vi /etc/my.cnf

[mysqld]

# Options for mysqld process:

ndbcluster                     # run NDB storage engine

[mysql_cluster]

# Options for MySQL Cluster processes:

ndb-connectstring=192.168.16.201    # location of management server

四、配置sql nodes

vi /etc/my.cnf [mysqld]

# Options for mysqld process:

ndbcluster                      # run NDB storage engine

[mysql_cluster]

# Options for MySQL Cluster processes:

ndb-connectstring=192.168.16.201  # location of management server

五、启动初始化

1. 启动management node

/usr/local/mysql/bin/ndb_mgmd -f /usr/local/mysql/bin/config.ini –config-dir=/usr/local/mysql

2. 启动data node

/usr/local/mysql/bin/ndbd –datadir=/mysqldata/ndbdata –initial    ————->第一次初始化

3. 使用management node client查看data node状态

/usr/local/mysql/bin/ndb_mgm

ndb_mgm> all status

ndb_mgm> show

4. 启动sql node, sql node的安装类似单实例情况的mysql安装

cd /usr/local/mysql/scripts

./mysql_install_db –basedir=/usr/local/mysql –datadir=/mysqldata/ndbdata   ————>初始化实例数据

chown -R mysql.mysql /mysqldata/ndbdata

/usr/local/mysql/bin/mysqld_safe &

或者使用脚本启动

cp support-files/mysql.server /etc/rc.d/init.d/

chmod +x /etc/rc.d/init.d/mysql.server

chkconfig –add mysql.server

/etc/rc.d/init.d/mysql.server start

5. 使用management node client查看data node状态

/usr/local/mysql/bin/ndb_mgm

ndb_mgm> all status

ndb_mgm> show

六. 测试、管理ndb cluster

1. 从任意sql node登录

mysql -u root -p

mysql> use test;

mysql> create table tab1(id int, name varchar(20)) engine=ndbcluster;

2. 再从其他任意sql node登录,查看刚建的表

mysql -u root -p

mysql> use test;

mysql> show tables;

3. ndb cluster启动、关闭

=============== example startup instance ==========================

“config.ini” 113L, 3804C written                                                                                                                             

[root@hadoop1 bin]# /usr/local/mysql/bin/ndb_mgmd –config-file=/usr/local/mysql/bin/config.ini –config-dir=/usr/local/mysql

MySQL Cluster Management Server mysql-5.6.11 ndb-7.3.2

[root@hadoop1 bin]#

[root@hadoop1 bin]#

[root@hadoop1 bin]#

[root@hadoop1 bin]#

[root@hadoop1 bin]# /usr/local/mysql/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.16.202)

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

[ndb_mgmd(MGM)] 1 node(s)

id=1    @192.168.16.201  (mysql-5.6.11 ndb-7.3.2)

[mysqld(API)]   2 node(s)

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

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

ndb_mgm>

[root@hadoop2 ~]# /usr/local/mysql/bin/ndbd

2013-11-04 14:58:24  [ndbd] INFO     — Angel connected to ’192.168.16.201:1186′

2013-11-04 14:58:24  [ndbd] INFO     — Angel allocated nodeid: 2

[root@hadoop2 ~]#

[root@hadoop3 ~]# /usr/local/mysql/bin/ndbd

2013-11-04 15:07:00 [ndbd] INFO     — Angel connected to ’192.168.16.201:1186′

2013-11-04 15:07:00 [ndbd] INFO     — Angel allocated nodeid: 3

[root@hadoop3 ~]#

[root@hadoop2 ndbdata]# more ndb_2_out.log

2013-11-04 14:58:24 [ndbd] INFO     — Angel pid: 26043 started child: 26044

2013-11-04 14:58:24 [ndbd] INFO     — Configuration fetched from ’192.168.16.201:1186′, generation: 1 NDBMT: non-mt

2013-11-04 14:58:24 [ndbd] INFO     — NDB Cluster — DB node 2 2013-11-04 14:58:24 [ndbd] INFO     — mysql-5.6.11 ndb-7.3.2 —

2013-11-04 14:58:24 [ndbd] INFO     — numa_set_interleave_mask(numa_all_nodes) : OK

2013-11-04 14:58:24 [ndbd] INFO     — Ndbd_mem_manager::init(1) min: 1564Mb initial: 1692Mb Adding 36Mb to ZONE_LO (1,1151) Instantiating DBSPJ instanceNo=0 2013-11-04 14:58:24 [ndbd] INFO     — Start initiated (mysql-5.6.11 ndb-7.3.2) NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer Adding 1657Mb to ZONE_LO (1152,53000) NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer NDBFS/AsyncFile: Allocating 310392 for In/Deflate buffer WOPool::init(61, 9) RWPool::init(22, 14) RWPool::init(42, 75) blockSz: 800, wpp: 8188 -> 624 (76) RWPool::init(29, 624) RWPool::init(42, 16) RWPool::init(62, 12) RWPool::init(42, 83) RWPool::init(c2, 18) RWPool::init(e2, 16) WOPool::init(41, 8) RWPool::init(82, 12) RWPool::init(a2, 54) WOPool::init(21, 10) blockSz: 1024, wpp: 8188 -> 816 (28) RWPool::init(68, 816)

2013-11-04 14:58:25 [ndbd] INFO     — Start phase 0 completed

2013-11-04 14:58:25 [ndbd] INFO     — Using locked memory

2013-11-04 15:07:05 [ndbd] INFO     — findNeighbours from: 2100 old (left: 65535 right: 65535) new (3 3) Dbspj::execSTTOR() inst:0 phase=1

2013-11-04 15:07:05 [ndbd] INFO     — Start phase 1 completed

[root@hadoop2 ndbdata]#

[root@hadoop2 ndbdata]#

[root@hadoop2 ndbdata]#

[root@hadoop2 ndbdata]#

[root@hadoop2 ndbdata]#

[root@hadoop2 ndbdata]#

[root@hadoop2 ndbdata]#

[root@hadoop2 ndbdata]#

[root@hadoop2 ndbdata]#

[root@hadoop2 ndbdata]#

[root@hadoop2 ndbdata]# tailf /mysqldata/ndbdata/ndb_2_out.log

RWPool::init(82, 12) RWPool::init(a2, 54) WOPool::init(21, 10) blockSz: 1024, wpp: 8188 -> 816 (28) RWPool::init(68, 816)

2013-11-04 14:58:25 [ndbd] INFO     — Start phase 0 completed

2013-11-04 14:58:25 [ndbd] INFO     — Using locked memory

2013-11-04 15:07:05 [ndbd] INFO     — findNeighbours from: 2100 old (left: 65535 right: 65535) new (3 3) Dbspj::execSTTOR() inst:0 phase=1

2013-11-04 15:07:05 [ndbd] INFO     — Start phase 1 completed

2013-11-04 15:08:58 [ndbd] INFO     — Start phase 2 completed

2013-11-04 15:08:58 [ndbd] INFO     — Start phase 3 completed Dbspj::execSTTOR() inst:0 phase=4

2013-11-04 15:08:59 [ndbd] INFO     — Start phase 4 completed Using 1 fragments per node

2013-11-04 15:09:02 [ndbd] INFO     — Start phase 5 completed

2013-11-04 15:09:02 [ndbd] INFO     — Start phase 6 completed

2013-11-04 15:09:02 [ndbd] INFO     — President restarts arbitration thread [state=1]

2013-11-04 15:09:02 [ndbd] WARNING  — Could not find an arbitrator, cluster is not partition-safe m_active_buckets.set(0)

2013-11-04 15:09:02 [ndbd] INFO     — Start phase 7 completed

2013-11-04 15:09:02 [ndbd] INFO     — Start phase 8 completed

2013-11-04 15:09:02 [ndbd] INFO     — Start phase 9 completed

2013-11-04 15:09:02 [ndbd] INFO     — Start phase 100 completed

2013-11-04 15:09:02 [ndbd] INFO     — Start phase 101 completed

2013-11-04 15:09:02 [ndbd] INFO     — Node started

2013-11-04 15:09:02 [ndbd] INFO     — Started arbitrator node 1 [ticket=65bc00011b25fc11]

[root@hadoop1 ~]# /usr/local/mysql/bin/ndb_mgm

— NDB Cluster — Management Client —

ndb_mgm> all status

Connected to Management Server at: localhost:1186

Node 2: starting (Last completed phase 1) (mysql-5.6.11 ndb-7.3.2)

Node 3: starting (Last completed phase 1) (mysql-5.6.11 ndb-7.3.2)

ndb_mgm> all status;

Node 2: starting (Last completed phase 1) (mysql-5.6.11 ndb-7.3.2)

Node 3: starting (Last completed phase 1) (mysql-5.6.11 ndb-7.3.2)

ndb_mgm>

Node 2: Started (version 7.3.2)

Node 3: Started (version 7.3.2)

ndb_mgm>

ndb_mgm>

ndb_mgm> all status;

Node 2: started (mysql-5.6.11 ndb-7.3.2)

Node 3: started (mysql-5.6.11 ndb-7.3.2)

ndb_mgm>

ndb_mgm> show

Cluster Configuration ———————

[ndbd(NDB)]     2 node(s)

id=2    @192.168.16.202  (mysql-5.6.11 ndb-7.3.2, Nodegroup: 0, Master)

id=3    @192.168.16.203  (mysql-5.6.11 ndb-7.3.2, Nodegroup: 0)

[ndb_mgmd(MGM)]

1 node(s) id=1    @192.168.16.201  (mysql-5.6.11 ndb-7.3.2)

[mysqld(API)]  

2 node(s)

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

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

ndb_mgm>

[root@hadoop2 ~]# mysql -u root

Welcome to the MySQL monitor. 

Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.6.11-ndb-7.3.2-cluster-gpl MySQL Cluster Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> use test;

Database changed

mysql> create table tab1(id int,name varchar(20)) engine=ndbcluster;

Query OK, 0 rows affected (0.55 sec)

mysql>

mysql>

mysql> exit

Bye

[root@hadoop2 ~]#

[root@hadoop2 ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. 

Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.6.11-ndb-7.3.2-cluster-gpl MySQL Cluster Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

mysql>

mysql> use test

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> insert into tab1 values(1,’jeff’);

Query OK, 1 row affected (0.00 sec)

mysql> exit

Bye

[root@hadoop2 ~]#

[root@hadoop3 ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.6.11-ndb-7.3.2-cluster-gpl MySQL Cluster Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

mysql>

mysql> use test;

Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;

+—————-+

| Tables_in_test |

+—————-+

| tab1           |

+—————-+

1 row in set (0.00 sec)

mysql>

mysql>

mysql>

mysql> select * from tab1;

+——+——+

| id   | name |

+——+——+

|    1 | jeff |

+——+——+

1 row in set (0.00 sec)

mysql>

ndb_mgm> all status

Node 2: started (mysql-5.6.11 ndb-7.3.2)

Node 3: started (mysql-5.6.11 ndb-7.3.2)

ndb_mgm> show

Cluster Configuration ———————

[ndbd(NDB)]     2 node(s)

id=2    @192.168.16.202  (mysql-5.6.11 ndb-7.3.2, Nodegroup: 0, Master)

id=3    @192.168.16.203  (mysql-5.6.11 ndb-7.3.2, Nodegroup: 0)

[ndb_mgmd(MGM)]

1 node(s) id=1    @192.168.16.201  (mysql-5.6.11 ndb-7.3.2)

[mysqld(API)]  

2 node(s)

id=4    @192.168.16.202  (mysql-5.6.11 ndb-7.3.2)

id=5    @192.168.16.203  (mysql-5.6.11 ndb-7.3.2)

ndb_mgm>

停止单个data node

ndb_mgm> 3 stop

Node 3: Node shutdown initiated

Node 3: Node shutdown completed.

Node 3 has shutdown.

ndb_mgm> show

Cluster Configuration ———————

[ndbd(NDB)]     2 node(s)

id=2    @192.168.16.202  (mysql-5.6.11 ndb-7.3.2, Nodegroup: 0, Master)

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

[ndb_mgmd(MGM)] 1 node(s)

id=1    @192.168.16.201  (mysql-5.6.11 ndb-7.3.2)

[mysqld(API)]   2 node(s)

id=4    @192.168.16.202  (mysql-5.6.11 ndb-7.3.2) id=5    @192.168.16.203  (mysql-5.6.11 ndb-7.3.2)

ndb_mgm>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值