OpenStack 删除无用的计算结点
经常有些计算结点被移除了,或者是暂时不想用了,但还是出现在nova service-list 列表中,在horizon中还是看得到,状态是disabled
[root@yanheven-001 ~(keystone_admin)]# nova service-list
+------------------+---------------------------+----------+----------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+---------------------------+----------+----------+-------+----------------------------+-----------------+
| nova-consoleauth | yanheven-001.yanheven.tk | internal | enabled | up | 2014-05-09T01:51:37.000000 | None |
| nova-scheduler | yanheven-001.yanheven.tk | internal | enabled | up | 2014-05-09T01:51:39.000000 | None |
| nova-conductor | yanheven-001.yanheven.tk | internal | enabled | up | 2014-05-09T01:51:41.000000 | None |
| nova-cert | yanheven-001.yanheven.tk | internal | enabled | up | 2014-05-09T01:51:38.000000 | None |
| nova-compute | yanheven-012.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:36.000000 | None |
| nova-compute | yanheven-013.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:42.000000 | None |
| nova-compute | yanheven-014.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:40.000000 | None |
| nova-compute | yanheven-015.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:41.000000 | None |
| nova-compute | yanheven-017.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:36.000000 | None |
| nova-compute | yanheven-018.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:37.000000 | None |
| nova-compute | yanheven-032.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:41.000000 | None |
| nova-compute | yanheven-031.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:32.000000 | None |
| nova-compute | yanheven-034.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:34.000000 | None |
| nova-compute | yanheven-029.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:42.000000 | None |
| nova-compute | yanheven-028.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:39.000000 | None |
| nova-compute | yanheven-036.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:39.000000 | None |
| nova-compute | yanheven-033.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:41.000000 | None |
| nova-compute | yanheven-030.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:34.000000 | None |
| nova-compute | yanheven-016.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:42.000000 | None |
| nova-compute | yanheven-001.yanheven.tk | nova | disabled | down | 2014-05-04T06:46:14.000000 | None |
| nova-compute | yanheven-035.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:39.000000 | None |
| nova-compute | yanheven-027.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:41.000000 | None |
| nova-compute | yanheven-026.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:34.000000 | None |
+------------------+---------------------------+----------+----------+-------+----------------------------+-----------------+
可以通过直接在数据库中删除这个计算结点的信息来实现完全删除一个计算结点的功能
mysql> delete from compute_nodes where service_id=6;
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`nova`.`compute_node_stats`,
CONSTRAINT `fk_compute_node_stats_compute_node_id` FOREIGN KEY (`compute_node_id`) REFERENCES `compute_nodes` (`id`))
有外键依赖,同时在另外一张表删除相关行
mysql> delete from compute_node_stats where compute_node_id=1;
Query OK, 18 rows affected (0.01 sec)
mysql> delete from compute_nodes where service_id=6;
Query OK, 1 row affected (0.00 sec)
mysql> delete from services where id=6;
Query OK, 5 rows affected (0.03 sec)
搞掂:
[root@yanheven-001 ~(keystone_admin)]# nova service-list
+------------------+---------------------------+----------+----------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+---------------------------+----------+----------+-------+----------------------------+-----------------+
| nova-consoleauth | yanheven-001.yanheven.tk | internal | enabled | up | 2014-05-09T01:51:37.000000 | None |
| nova-scheduler | yanheven-001.yanheven.tk | internal | enabled | up | 2014-05-09T01:51:39.000000 | None |
| nova-conductor | yanheven-001.yanheven.tk | internal | enabled | up | 2014-05-09T01:51:41.000000 | None |
| nova-cert | yanheven-001.yanheven.tk | internal | enabled | up | 2014-05-09T01:51:38.000000 | None |
| nova-compute | yanheven-012.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:36.000000 | None |
| nova-compute | yanheven-013.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:42.000000 | None |
| nova-compute | yanheven-014.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:40.000000 | None |
| nova-compute | yanheven-015.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:41.000000 | None |
| nova-compute | yanheven-017.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:36.000000 | None |
| nova-compute | yanheven-018.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:37.000000 | None |
| nova-compute | yanheven-032.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:41.000000 | None |
| nova-compute | yanheven-031.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:32.000000 | None |
| nova-compute | yanheven-034.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:34.000000 | None |
| nova-compute | yanheven-029.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:42.000000 | None |
| nova-compute | yanheven-028.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:39.000000 | None |
| nova-compute | yanheven-036.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:39.000000 | None |
| nova-compute | yanheven-033.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:41.000000 | None |
| nova-compute | yanheven-030.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:34.000000 | None |
| nova-compute | yanheven-016.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:42.000000 | None |
| nova-compute | yanheven-035.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:39.000000 | None |
| nova-compute | yanheven-027.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:41.000000 | None |
| nova-compute | yanheven-026.yanheven.tk | nova | enabled | up | 2014-05-09T01:51:34.000000 | None |
+------------------+---------------------------+----------+----------+-------+----------------------------+-----------------+