MySql Cluster 中慎用ndb_drop_index命令,否则会导致
ERROR 1296 (HY000): Got error 4243 'Index not found' from NDBCLUSTER
官方文档中对这个命令的描述:
ndb_drop_index drops the specified index from an NDB table.
It is recommended that you
use this utility only as an example for writing NDB API applications。
1.用ndb_drop_index删除一个ndbcluster表的索引
$ndb_drop_index -c localhost testuser idx_testuser_id -d testdb
Dropping index testuser/idx_testuser_id...OK
NDBT_ProgramExit: 0 - OK
2.访问删除索引的表,正常。
$ ndb_select_all -d testdb testuser;
ID id loginName Passwd role SupplierName Status CreateUser CreateTime TotalOnlineTime mobileNumisOpenMobile
0 rows returned
NDBT_ProgramExit: 0 - OK
3.关闭集群
$ $HOME/mysqlc/bin/mysqladmin -u root -h 127.0.0.1 -P 5000 shutdown -p
$ $HOME/mysqlc/bin/ndb_mgm -e shutdown
4.重启集群后在访问用ndb_drop_index删除索引的表
$ ndb_mgmd -f $HOME/my_cluster/conf/config.ini
MySQL Cluster Management Server mysql-5.5.19 ndb-7.2.4
mysql> select count(1) from testuser;
ERROR 1296 (HY000): Got error 4243 'Index not found' from NDBCLUSTER
官方文档中的描述:
In such a case, your only option for making the table available to MySQL again is
to drop the table
and re-create it. You can use either the SQL statement DROP TABLE or the ndb_drop_table utility
to drop the table.
这种情况只能drop掉这个表并重建,才能访问。当然如果表中有数据也会丢失。
mysql> drop table testuser;
Query OK, 0 rows affected (0.04 sec)
不知道为什么这么设计ndb_drop_index,使用ndb_drop_index删除索引后表都不能用了。
使用drop index 则没有这个问题。希望ndb_drop_index的功能在新的版本中有所改进。