Mysql cluster中不要使用Ndb_drop_index命令删除索引

2490阅读 0评论2012-09-24 guopy007
分类:

最近在使用mysql cluster时,发现使用Ndb_drop_index命令删除索引时,会出现问题
test表有个索引idx_b

点击(此处)折叠或打开

  1. mysql> show create table test\G
  2. *************************** 1. row ***************************
  3.        Table: test
  4. Create Table: CREATE TABLE `test` (
  5.   `a` int(11) NOT NULL DEFAULT '0',
  6.   `b` varchar(20) DEFAULT NULL,
  7.   PRIMARY KEY (`a`),
  8.   KEY `idx_b` (`b`)
  9. ) ENGINE=ndbcluster DEFAULT CHARSET=utf8
  10. 1 row in set (0.00 sec)
在管理节点删除索引:

点击(此处)折叠或打开

  1. [mysql@station-192-168-20-80 mysql]$ ndb_drop_index -c 192.168.21.24 test idx_b -d test
  2. Dropping index test/idx_b...OK
  3. NDBT_ProgramExit: 0 - OK
显示删除成功,现在回到刚才的sql节点:

点击(此处)折叠或打开

  1. mysql> show create table test\G
  2. *************************** 1. row ***************************
  3.        Table: test
  4. Create Table: CREATE TABLE `test` (
  5.   `a` int(11) NOT NULL DEFAULT '0',
  6.   `b` varchar(20) DEFAULT NULL,
  7.   PRIMARY KEY (`a`),
  8.   KEY `idx_b` (`b`)
  9. ) ENGINE=ndbcluster DEFAULT CHARSET=utf8
  10. 1 row in set (0.00 sec)

  11. mysql>
该表结构显示该索引仍然存在,现在在sql节点使用drop命令删除该索引试试:

点击(此处)折叠或打开

  1. mysql> drop index idx_b;
  2. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
  3. mysql>
报错了。。。
官方文档中的描述:
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掉这个表并重建,才能访问。当然如果表中有数据也会丢失。
目前删除索引,只能在sql节点使用drop命令删除,不知道这是mysql的bug还是就是这样设计的,不理解!
上一篇:Nginx Location配置总结
下一篇:Java多线程Synchronized的注意细节