openstack中彻底删除计算节点
2021-10-15 本文已影响0人
无味wy
在使用openstack的过程中,我们经常会添加好几台计算节点来部署虚拟机,在后续使用中由于某些原因,一些计算节点出现了问题,需要将这些出了问题的计算节点从openstack的控制节点中踢出去!但是很多时候,在删除计算节点的时候由于删除不彻底而导致了后面使用openstack出现了诸多问题
下面记录了在openstack中彻底删除计算节点compute2的操作:
在控制节点上操作
查看计算节点
[root@controller ~]# openstack host list
Missing value auth-url required for auth plugin password
[root@controller ~]# source /openstcak/
admin-openrc cloud/
[root@controller ~]# source /openstcak/admin-openrc
[root@controller ~]# openstack host list
+------------+-------------+----------+
| Host Name | Service | Zone |
+------------+-------------+----------+
| controller | conductor | internal |
| controller | scheduler | internal |
| controller | consoleauth | internal |
| compute1 | compute | nova |
| compute2 | compute | nova |
+------------+-------------+----------+
[root@controller ~]# nova service-list
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| 1 | nova-conductor | controller | internal | enabled | up | 2021-10-15T02:28:41.000000 | - |
| 5 | nova-scheduler | controller | internal | enabled | up | 2021-10-15T02:28:38.000000 | - |
| 6 | nova-consoleauth | controller | internal | enabled | up | 2021-10-15T02:28:42.000000 | - |
| 12 | nova-compute | compute1 | nova | enabled | up | 2021-10-15T02:28:37.000000 | - |
| 13 | nova-compute | compute2 | nova | enabled | down | 2021-10-13T07:20:01.000000 | - |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
虽然上面显示的一个计算节点compute2 的State状态是down,但是Status状态还是enabled可用
现在需要使它为不可用
[root@controller ~]# nova service-disable compute2 nova-compute
+----------+--------------+----------+
| Host | Binary | Status |
+----------+--------------+----------+
| compute2 | nova-compute | disabled |
+----------+--------------+----------+
[root@controller ~]# nova service-list
+----+------------------+------------+----------+----------+-------+----------------------------+-----------------+
| Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+----+------------------+------------+----------+----------+-------+----------------------------+-----------------+
| 1 | nova-conductor | controller | internal | enabled | up | 2021-10-15T02:55:22.000000 | - |
| 5 | nova-scheduler | controller | internal | enabled | up | 2021-10-15T02:55:19.000000 | - |
| 6 | nova-consoleauth | controller | internal | enabled | up | 2021-10-15T02:55:22.000000 | - |
| 12 | nova-compute | compute1 | nova | enabled | up | 2021-10-15T02:55:17.000000 | - |
| 13 | nova-compute | compute2 | nova | disabled | down | 2021-10-15T02:55:11.000000 | - |
+----+------------------+------------+----------+----------+-------+----------------------------+-----------------+
在数据库里清理(nova库)
[root@controller ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 101949
Server version: 10.1.20-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use nova;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [nova]> delete from nova.services where host="compute2";
Query OK, 1 row affected (0.04 sec)
MariaDB [nova]> delete from compute_nodes where hypervisor_hostname="compute2";
Query OK, 1 row affected (0.04 sec)
MariaDB [nova]> select host from nova.services;
+------------+
| host |
+------------+
| 0.0.0.0 |
| 0.0.0.0 |
| compute1 |
| controller |
| controller |
| controller |
+------------+
6 rows in set (0.00 sec)
MariaDB [nova]> select hypervisor_hostname from compute_nodes;
+---------------------+
| hypervisor_hostname |
+---------------------+
| compute1 |
+---------------------+
1 row in set (0.00 sec)
MariaDB [nova]> ^DBye
再次查看计算节点,就发现已经删除了compute2
[root@controller ~]# openstack host list
+------------+-------------+----------+
| Host Name | Service | Zone |
+------------+-------------+----------+
| controller | conductor | internal |
| controller | scheduler | internal |
| controller | consoleauth | internal |
| compute1 | compute | nova |
+------------+-------------+----------+
[root@controller ~]# nova service-list
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| 1 | nova-conductor | controller | internal | enabled | up | 2021-10-15T02:59:03.000000 | - |
| 5 | nova-scheduler | controller | internal | enabled | up | 2021-10-15T02:58:59.000000 | - |
| 6 | nova-consoleauth | controller | internal | enabled | up | 2021-10-15T02:59:02.000000 | - |
| 12 | nova-compute | compute1 | nova | enabled | up | 2021-10-15T02:58:57.000000 | - |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+