clusterはデータノードを動的に追加します。


http://suchalin.blog.163.com/blog/static/553046772010111061737325/
 
mysql cluster 7は、データノードの配置手順を動的に増加する。  
2010-12-10 18:17:37|  デフォルトの分類  ラベル:mysql  cluster  7  データノードの構成ステップを動的に増加する   |サイズ 購読する
 
Starting configration.
vi/usr/local/mysql/mysql-cluster/config.ini
[dbd default]
Data Memory=100 M
IndexMemory=100 M
NoOf Replicas=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>ショー
-- NDB Cluster -- Management Client --
ndb_mgm>SHOW
Connected to Management Server at: 172.20.86.185:1186
Cluster Configuration
---------------------
[ndbd(NDB)]    2 node(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)] 1 node(s)
id=10  @172.20.86.185 (5.1.32-ndb-7.0.5)
 
[mysqld(API)]  2 node(s)
id=20  @172.20.86.185 (5.1.32-ndb-7.0.5)
 
 
Step 1:Update configration file
 
[ndbd default]
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
 
[ndbd]
Id = 4
HostName=172.20.86.186
 
[mgm]
HostName = 172.20.86.185
Id = 10
 
[mysqld]
Id=20
HostName = 172.20.86.185
 
 
Step 2:Restart the management server
Step 2.1管理ノードの停止
ndb_mgm>10 STOP
Node 10 has shut down.
Disconnecting to allow Management Server to shutdown
shell>
Step 2.2設定ファイルを再読み込みする
shell>ndb_mgmd -f config.ini --reload
2008-12-08 17:29:23 [MgmSrvr] INFO    -- NDB Cluster Management Server.5.1.34-ndb-7.0.7
2008-12-08 17:29:23 [MgmSrvr] INFO    --Readingcluster configuration from 'config.ini'
Step 2.3新しいグループの状態を確認する
-- NDB Cluster -- Management Client --
ndb_mgm>SHOW
Connected to Management Server at: 172.20.86.185:1186
Cluster Configuration
---------------------
[ndbd(NDB)]    2 node(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 (not connected, accepting connect from 172.20.86.186)
id=4 (not connected, accepting connect from 172.20.86.187)
 
[ndb_mgmd(MGM)] 1 node(s)
id=10  @172.20.86.185 (5.1.32-ndb-7.0.5)
 
[mysqld(API)]  1 node(s)
id=20  @172.20.86.185 (5.1.32-ndb-7.0.5)
 
Step 3:Perform.a rolling retart of the existing data nodes–接続されたデータノードを順番に再起動する
ndb_mgm>1 RESTART
Node 1: Node shutdown initiated
Node 1: Node shutdown completed, restarting, no start.
Node 1 is being restarted
 
ndb_mgm> Node 1: Start initiated (version7.0.5)
Node 1: Started (version7.0.5)
 
ndb_mgm>2 RESTART
Node 2: Node shutdown initiated
Node 2: Node shutdown completed, restarting, no start.
Node 2 is being restarted
 
Step 4:Perform.a rolling retart of all cluster API nodes–順番にsqlノードを再起動する
本件はsqlノードしかない。
shell>mysqladmin -uroot -ppasswordshutdown
shell>mysqld_safe &
 
Step 5:Perform.an initial start of the new data nodes–新しいデータノードを初期化する
 
新規データノード186および187において実行される。
Shell>ndbmtd–initial
または
Shell>ndbd–initial
管理ノードにログインしてクラスタ状態を確認する
Connected to Management Server at: 172.20.86.185:1186
Cluster Configuration
---------------------
[ndbd(NDB)]    2 node(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,no nodegroup)
id=4   @172.20.86.187 (5.1.32-ndb-7.0.5,no nodegroup)
 
[ndb_mgmd(MGM)] 1 node(s)
id=10  @172.20.86.185 (5.1.32-ndb-7.0.5)
 
[mysqld(API)]  2 node(s)
id=20  @172.20.86.185 (5.1.32-ndb-7.0.5)
 
Step 6:Create a new node group. 
ndb_mgm>CREATE NODEGROUP 3,4
Nodegroup 1 created
 
ndb_mgm>SHOW
Connected to Management Server at: 172.20.86.185:1186
Cluster Configuration
---------------------
[ndbd(NDB)]    2 node(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)] 1 node(s)
id=10  @172.20.86.185 (5.1.32-ndb-7.0.5)
 
[mysqld(API)]  1 node(s)
id=20  @172.20.86.185 (5.1.32-ndb-7.0.5)
 
Step 7:Redistribute cluster data.–データの再割り当て
 
新たに追加されたデータノードのいくつかのアクセス量が高いデータおよびより重要なデータについては、新たな割り当てが必要である。
 
配信データコマンド:
Alter online table ips reorganize partition;
データの割り当てを確認します。
ndb_mgm>ALL REPORT MEMORY
 
Node 1: Data usage is 5%(177 32K pages of total 3200)
Node 1: Index usage is 0%(108 8K pages of total 12832)
Node 2: Data usage is 5%(177 32K pages of total 3200)
Node 2: Index usage is 0%(108 8K pages of total 12832)
Node 3: Data usage is 0%(0 32K pages of total 3200)
Node 3: Index usage is 0%(0 8K pages of total 12832)
Node 4: Data usage is 0%(0 32K pages of total 3200)
Node 4: Index usage is 0%(0 8K pages of total 12832)
または
shell>ndb_desc -c 192.168.0.10 -d n ips -p
-- ips --
Version: 1
Fragment type: 9
K Value: 6
Min load factor: 78
Max load factor: 80
Temporary table: no
Number of attributes: 6
Number of primary keys: 1
Length of frm data: 340
Row Checksum: 1
Row GCI: 1
SingleUserMode: 0
ForceVarPart: 1
FragmentCount: 2
TableStatus: Retrieved
-- Attributes --
id Bigint PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY AUTO_INCR
country_code Char(2;latin1_swedish_ci) NOT NULL AT=FIXED ST=MEMORY
type Char(4;latin1_swedish_ci) NOT NULL AT=FIXED ST=MEMORY
ip_address Varchar(15;latin1_swedish_ci) NOT NULL AT=SHORT_VAR ST=MEMORY
addresses Bigunsigned NULL AT=FIXED ST=MEMORY
date Bigunsigned NULL AT=FIXED ST=MEMORY
 
-- Indexes --
PRIMARY KEY(id) - UniqueHashIndex
PRIMARY(id) - OrderedIndex
 
-- Per partition info --
Partition  Row count  Commit count Frag fixed memory  Frag varsized memory
0          26086      26086        1572864            557056
1          26329      26329        1605632            557056
 
NDBT_ProgramExit: 0 - OK
You can cause the data to be redistributed among all of the data nodes by performing、for each NDBCLUSTER table、an ALTER ONLINE TABLE ... REORGANIZE PARTITION statement in themysql client.After issung the statement ALTER ONLINE TABLE ips REORGANIZE PARTITION、you can see usingb。descthat the data for this table is now stored using 4 partitions、as shown here(with the relevant politions of the out put in bold type):
shell>ndb_desc -c 172.20.86.185 -d n ips -p
-- ips --
Version: 16777217
Fragment type: 9
K Value: 6
Min load factor: 78
Max load factor: 80
Temporary table: no
Number of attributes: 6
Number of primary keys: 1
Length of frm data: 341
Row Checksum: 1
Row GCI: 1
SingleUserMode: 0
ForceVarPart: 1
FragmentCount: 4
TableStatus: Retrieved
-- Attributes --
id Bigint PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY AUTO_INCR
country_code Char(2;latin1_swedish_ci) NOT NULL AT=FIXED ST=MEMORY
type Char(4;latin1_swedish_ci) NOT NULL AT=FIXED ST=MEMORY
ip_address Varchar(15;latin1_swedish_ci) NOT NULL AT=SHORT_VAR ST=MEMORY
addresses Bigunsigned NULL AT=FIXED ST=MEMORY
date Bigunsigned NULL AT=FIXED ST=MEMORY
 
-- Indexes --
PRIMARY KEY(id) - UniqueHashIndex
PRIMARY(id) - OrderedIndex
 
-- Per partition info --
Partition  Row count  Commit count Frag fixed memory  Frag varsized memory
0          12981      52296        1572864            557056
1          13236      52515        1605632            557056
2          13105      13105        819200             294912
3          13093      13093        819200             294912