您的位置:首页 > 职场人生

cluster动态添加数据节点

2011-09-24 19:07 423 查看
http://suchalin.blog.163.com/blog/static/553046772010111061737325/

mysqlcluster7动态增加数据节点配置步骤

2010-12-1018:17:37|分类: 默认分类 |标签:mysqlcluster7动态增加数据节点配置步骤 |字号订阅

Startingconfiguration.

vi/usr/local/mysql/mysql-cluster/config.ini

[ndbddefault]

DataMemory=100M

IndexMemory=100M

NoOfReplicas=2

DataDir=/usr/local/mysql/var/mysql-cluster

[ndbd]

Id=1

HostName=172.20.86.188

[ndbd]

Id=2

HostName=172.20.86.189

[mgm]

HostName=172.20.86.185

Id=10

[mysqld]

Id=20

HostName=172.20.86.185

2在185上运行ndb_mgm

Ndb_mgm>show

--NDBCluster--ManagementClient--

ndb_mgm>[code]SHOW
[/code]
ConnectedtoManagementServerat:172.20.86.185:1186

ClusterConfiguration

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

[ndbd(NDB)]2node(s)

id=1@172.20.86.188(5.1.32-ndb-7.0.5,Nodegroup:0,Master)

id=2@172.20.86.189(5.1.32-ndb-7.0.5,Nodegroup:0)


[ndb_mgmd(MGM)]1node(s)

id=10@172.20.86.185(5.1.32-ndb-7.0.5)


[mysqld(API)]2node(s)

id=20@172.20.86.185(5.1.32-ndb-7.0.5)


Step1:Updateconfigurationfile

[ndbddefault]

DataMemory=100M

IndexMemory=100M

NoOfReplicas=2

DataDir=/usr/local/mysql/var/mysql-cluster


[ndbd]

Id=1

HostName=172.20.86.188


[ndbd]

Id=2

HostName=172.20.86.189


[ndbd]

Id=3

HostName=172.20.86.187[/b]


[ndbd]

Id=4

HostName=172.20.86.186[/b]


[mgm]

HostName=172.20.86.185

Id=10


[mysqld]

Id=20

HostName=172.20.86.185


Step2:Restartthemanagementserver

Step2.1停止管理节点

ndb_mgm>[code]10STOP
[/code]
Node10hasshutdown.

DisconnectingtoallowManagementServertoshutdown

shell>

Step2.2重新加载配置文件

shell>[code]ndb_mgmd-fconfig.ini--reload
[/code]
2008-12-0817:29:23[MgmSrvr]INFO--NDBClusterManagementServer.5.1.34-ndb-7.0.7

2008-12-0817:29:23[MgmSrvr]INFO--Readingclusterconfigurationfrom'config.ini'

Step2.3查看新集群状态

--NDBCluster--ManagementClient--

ndb_mgm>[code]SHOW
[/code]
ConnectedtoManagementServerat:172.20.86.185:1186

ClusterConfiguration

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

[ndbd(NDB)]2node(s)

id=1@172.20.86.188(5.1.32-ndb-7.0.5,Nodegroup:0,Master)

id=2@172.20.86.189(5.1.32-ndb-7.0.5,Nodegroup:0)

id=3(notconnected,acceptingconnectfrom172.20.86.186)

id=4(notconnected,acceptingconnectfrom172.20.86.187)


[ndb_mgmd(MGM)]1node(s)

id=10@172.20.86.185(5.1.32-ndb-7.0.5)


[mysqld(API)]1node(s)

id=20@172.20.86.185(5.1.32-ndb-7.0.5)


Step3:Perform.arollingrestartoftheexistingdatanodes–轮流重新启动连接的数据节点

ndb_mgm>[code]1RESTART
[/code]
Node1:Nodeshutdowninitiated

Node1:Nodeshutdowncompleted,restarting,nostart.

Node1isbeingrestarted


ndb_mgm>Node1:Startinitiated(version7.0.5)

Node1:Started(version7.0.5)


ndb_mgm>[code]2RESTART
[/code]
Node2:Nodeshutdowninitiated

Node2:Nodeshutdowncompleted,restarting,nostart.

Node2isbeingrestarted


Step4:Perform.arollingrestartofallclusterAPInodes–轮流重启sql节点

本案仅有一个sql节点

shell>[code]mysqladmin-uroot-ppasswordshutdown
[/code]
shell>[code]mysqld_safe&
[/code]

Step5:Perform.aninitialstartofthenewdatanodes–初始化新的数据节点

在新增的数据节点上186和187上执行

Shell>ndbmtd–initial

或者

Shell>ndbd–initial

登陆管理节点查看集群状态

ConnectedtoManagementServerat:172.20.86.185:1186

ClusterConfiguration

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

[ndbd(NDB)]2node(s)

id=1@172.20.86.188(5.1.32-ndb-7.0.5,Nodegroup:0,Master)

id=2@172.20.86.189(5.1.32-ndb-7.0.5,Nodegroup:0)

id=3@172.20.86.186(5.1.32-ndb-7.0.5,nonodegroup)

id=4@172.20.86.187(5.1.32-ndb-7.0.5,nonodegroup)


[ndb_mgmd(MGM)]1node(s)

id=10@172.20.86.185(5.1.32-ndb-7.0.5)


[mysqld(API)]2node(s)

id=20@172.20.86.185(5.1.32-ndb-7.0.5)


Step6:Createanewnodegroup.

ndb_mgm>[code]CREATENODEGROUP3,4
[/code]
Nodegroup1created


ndb_mgm>[code]SHOW
[/code]
ConnectedtoManagementServerat:172.20.86.185:1186

ClusterConfiguration

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

[ndbd(NDB)]2node(s)

id=1@172.20.86.188(5.1.32-ndb-7.0.5,Nodegroup:0,Master)

id=2@172.20.86.189(5.1.32-ndb-7.0.5,Nodegroup:0)

id=3@172.20.86.186(5.1.32-ndb-7.0.5,Nodegroup:1)

id=4@172.20.86.187(5.1.32-ndb-7.0.5,Nodegroup:1)


[ndb_mgmd(MGM)]1node(s)

id=10@172.20.86.185(5.1.32-ndb-7.0.5)


[mysqld(API)]1node(s)

id=20@172.20.86.185(5.1.32-ndb-7.0.5)


Step7:Redistributeclusterdata.–数据的重新分配

对于新增的数据节点一些访问量较高的数据和比较重要的数据需要从新分配。

分发数据命令:

Alteronlinetableipsreorganizepartition;

查看数据的分配情况:

ndb_mgm>[code]ALLREPORTMEMORY
[/code]

Node1:Datausageis5%(17732Kpagesoftotal3200)

Node1:Indexusageis0%(1088Kpagesoftotal12832)

Node2:Datausageis5%(17732Kpagesoftotal3200)

Node2:Indexusageis0%(1088Kpagesoftotal12832)

Node3:Datausageis0%(032Kpagesoftotal3200)

Node3:Indexusageis0%(08Kpagesoftotal12832)

Node4:Datausageis0%(032Kpagesoftotal3200)

Node4:Indexusageis0%(08Kpagesoftotal12832)

或者

shell>[code]ndb_desc-c192.168.0.10-dnips-p
[/code]
--ips--

Version:1

Fragmenttype:9

KValue:6

Minloadfactor:78

Maxloadfactor:80

Temporarytable:no

Numberofattributes:6

Numberofprimarykeys:1

Lengthoffrmdata:340

RowChecksum:1

RowGCI:1

SingleUserMode:0

ForceVarPart:1

FragmentCount:2

TableStatus:Retrieved

--Attributes--

idBigintPRIMARYKEYDISTRIBUTIONKEYAT=FIXEDST=MEMORYAUTO_INCR

country_codeChar(2;latin1_swedish_ci)NOTNULLAT=FIXEDST=MEMORY

typeChar(4;latin1_swedish_ci)NOTNULLAT=FIXEDST=MEMORY

ip_addressVarchar(15;latin1_swedish_ci)NOTNULLAT=SHORT_VARST=MEMORY

addressesBigunsignedNULLAT=FIXEDST=MEMORY

dateBigunsignedNULLAT=FIXEDST=MEMORY


--Indexes--

PRIMARYKEY(id)-UniqueHashIndex

PRIMARY(id)-OrderedIndex


--Perpartitioninfo--

PartitionRowcountCommitcountFragfixedmemoryFragvarsizedmemory

026086260861572864557056

126329263291605632557056


NDBT_ProgramExit:0-OK

Youcancausethedatatoberedistributedamongallofthedatanodesbyperforming,foreach
NDBCLUSTER
table,an
ALTERONLINETABLE...REORGANIZEPARTITION
statementinthe[b]mysql[/b]client.Afterissuingthestatement
ALTERONLINETABLEipsREORGANIZEPARTITION
,youcanseeusingndb_descthatthedataforthistableisnowstoredusing4partitions,asshownhere(withtherelevantportionsoftheoutputinboldtype):

shell>[code]ndb_desc-c172.20.86.185-dnips-p
[/code]
--ips--

Version:16777217

Fragmenttype:9

KValue:6

Minloadfactor:78

Maxloadfactor:80

Temporarytable:no

Numberofattributes:6

Numberofprimarykeys:1

Lengthoffrmdata:341

RowChecksum:1

RowGCI:1

SingleUserMode:0

ForceVarPart:1

FragmentCount:4

TableStatus:Retrieved

--Attributes--

idBigintPRIMARYKEYDISTRIBUTIONKEYAT=FIXEDST=MEMORYAUTO_INCR

country_codeChar(2;latin1_swedish_ci)NOTNULLAT=FIXEDST=MEMORY

typeChar(4;latin1_swedish_ci)NOTNULLAT=FIXEDST=MEMORY

ip_addressVarchar(15;latin1_swedish_ci)NOTNULLAT=SHORT_VARST=MEMORY

addressesBigunsignedNULLAT=FIXEDST=MEMORY

dateBigunsignedNULLAT=FIXEDST=MEMORY


--Indexes--

PRIMARYKEY(id)-UniqueHashIndex

PRIMARY(id)-OrderedIndex


--Perpartitioninfo--

PartitionRowcountCommitcountFragfixedmemoryFragvarsizedmemory

012981522961572864557056

113236525151605632557056

21310513105819200294912

31309313093819200294912
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  职场 休闲 cluster