MySQL Clusterのエラーについて調べてみた

設定自体は結構前に終わってたんだけど、改めてエラーについて調べてみた。
どうしてエラーが出るのか、何をどうすればエラーが出なくなるのか、の辺り。
運用中のエラーはまだ出た事がない。
今まで見た事のあるエラーはこれで全部。
あとは設定の確認方法。
 

NDBが起動出来ない

ndb_mgm> Node 11: Forced node shutdown completed. Occured during startphase 5. Caused by error 2355: 'Failure to restore schema(Resource configuration error). Permanent error, external action needed'.

 
config.iniで設定されているリソースの割り当てではNDBを起動出来ない。
MaxNoOfOrderedIndexesとかを上げる必要がありそう。
service ndbd restartした側ではOKと出るけど、実は起動失敗してるパターン。
 

SQLを実行出来ない

errno: 136
ERROR 1005 (HY000) at line 651: Can't create table 'test_db.test_51' (errno: 136)

 
MaxNoOfOrderedIndexesの値を大きくする。
デフォルトの値は128。
上げすぎるとメモリが足らなくて大変な事になる。
 

errno: 708
ERROR 1005 (HY000) at line 833: Can't create table 'test_db.test_65' (errno: 708)

 
MaxNoOfAttributesの値を大きくする。
デフォルトの値は1000で、32〜4294967039で指定する。
上げすぎるとメモリが足らなくて大変な事になる。
 

チューニングする時に確認するべき箇所

・Dataノードが最低1台は起動しているか。
・Dataノードのservice ndbd restartの出力。
・管理ノードのndb_mgmの出力。
・Dataノードのxvc0の出力。(メモリのエラーが出てないか)
 

設定確認

管理ノードからndb_mgmで起動状況を確認
# ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: 192.168.0.80:1186
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=11   @192.168.0.81  (mysql-5.1.47 ndb-7.1.5, Nodegroup: 0, Master)
id=12   @192.168.0.82  (mysql-5.1.47 ndb-7.1.5, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.0.80  (mysql-5.1.47 ndb-7.1.5)

[mysqld(API)]   2 node(s)
id=21   @192.168.0.81  (mysql-5.1.47 ndb-7.1.5)
id=22   @192.168.0.82  (mysql-5.1.47 ndb-7.1.5)

 

管理ノードからndb_configで設定を確認

queryパラメータは、config.iniで設定するキーと同じ。
 
全体の確認。

# ndb_config --query=id,type,HostName --fields=", " --rows="\n"
1, ndb_mgmd, 192.168.0.80
21, mysqld, 192.168.0.81
22, mysqld, 192.168.0.82
11, ndbd, 192.168.0.81
12, ndbd, 192.168.0.82

 
管理ノードの確認。

# ndb_config --type=ndb_mgmd --query=id,type,HostName,PortNumber,DataDir --fields=", " --rows="\n"
1, ndb_mgmd, 192.168.0.80, 1186, /var/lib/mysql-cluster

 
Dataノードの確認。

# ndb_config --type=ndbd --query=id,type,HostName,NoOfReplicas,DataMemory,IndexMemory,StringMemory,DataDir,FileSystemPath,BackupDataDir --fields=", " --rows="\n"
11, ndbd, 192.168.0.81, 2, 167772160, 37748736, 25, /usr/local/mysql/data, /usr/local/mysql/data, /usr/local/mysql/data
12, ndbd, 192.168.0.82, 2, 167772160, 37748736, 25, /usr/local/mysql/data, /usr/local/mysql/data, /usr/local/mysql/data

 
SQLノードの確認。

# ndb_config --type=mysqld --query=id,type,HostName,BatchByteSize,BatchSize,MaxScanBatchSize --fields=", " --rows="\n"
21, mysqld, 192.168.0.81, 32768, 64, 262144
22, mysqld, 192.168.0.82, 32768, 64, 262144

 

SQLノードからMySQL Clusterの設定を確認
$ mysql -h192.168.0.81 -uxxx -pxxx
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 26
Server version: 5.1.47-ndb-7.1.5-cluster-gpl MySQL Cluster Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SHOW STATUS LIKE 'ndb%';
+--------------------------------+--------------+
| Variable_name                  | Value        |
+--------------------------------+--------------+
| Ndb_cluster_node_id            | 21           |
| Ndb_config_from_host           | 192.168.0.80 |
| Ndb_config_from_port           | 1186         |
| Ndb_number_of_data_nodes       | 2            |
| Ndb_number_of_ready_data_nodes | 2            |
| Ndb_connect_count              | 1            |
| Ndb_execute_count              | 48           |
| Ndb_scan_count                 | 48           |
| Ndb_pruned_scan_count          | 0            |
| Ndb_cluster_connection_pool    | 1            |
| Ndb_conflict_fn_max            | 0            |
| Ndb_conflict_fn_old            | 0            |
+--------------------------------+--------------+
12 rows in set (0.00 sec)

 

参考URL

MySQL :: MySQL 5.1 リファレンスマニュアル :: 14.4.4.4 マネジメント サーバーの定義
http://dev.mysql.com/doc/refman/5.1/ja/mysql-cluster-mgm-definition.html
 
MySQL :: MySQL 5.1 リファレンスマニュアル :: 14.4.4.5 Defining Data Nodes
http://dev.mysql.com/doc/refman/5.1/ja/mysql-cluster-ndbd-definition.html
 
MySQL :: MySQL 5.1 リファレンスマニュアル :: 14.4.4.6 SQL および他の API ノードの定義
http://dev.mysql.com/doc/refman/5.1/ja/mysql-cluster-api-definition.html
 
MySQL :: MySQL 5.1 リファレンスマニュアル :: 14.9.1 ndb_config - NDB 設定情報の抽出
http://dev.mysql.com/doc/refman/5.1/ja/mysql-cluster-utilities-ndb-config.html