原因
由于断电重启集群忘记启动一台nova节点,使用openstack server start 1caf85fb-e025-4834-afc8-50c3fb7887df
启动虚拟机。造成task_state
一直处于powering-on
的状态。 如下:
[root@ctl01 ~]# openstack server show 1caf85fb-e025-4834-afc8-50c3fb7887df
+-------------------------------------+----------------------------------------------------------+
| Field | Value |
+-------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig | AUTO |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | cs07 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | cs07 |
| OS-EXT-SRV-ATTR:instance_name | instance-00000015 |
| OS-EXT-STS:power_state | Shutdown |
| OS-EXT-STS:task_state | powering-on |
| OS-EXT-STS:vm_state | stopped |
| OS-SRV-USG:launched_at | 2021-08-26T03:25:01.000000 |
| OS-SRV-USG:terminated_at | None |
~~~
| volumes_attached | id='2f184cda-3e7a-4d13-89db-abc0e4002217' |
+-------------------------------------+----------------------------------------------------------+
尝试多次启动均告失败。
状态修复
尝试使用server set
命令对虚拟机状态进行修复,task_state
状态变更None
[root@ctl01 ~]# openstack server set --state active 1caf85fb-e025-4834-afc8-50c3fb7887df
[root@ctl01 ~]# openstack server show 1caf85fb-e025-4834-afc8-50c3fb7887df
+-------------------------------------+----------------------------------------------------------+
| Field | Value |
+-------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig | AUTO |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | cs07 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | cs07 |
| OS-EXT-SRV-ATTR:instance_name | instance-00000015 |
| OS-EXT-STS:power_state | Shutdown |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | stopped |
| OS-SRV-USG:launched_at | 2021-08-26T03:25:01.000000 |
| OS-SRV-USG:terminated_at | None |
~~~
| volumes_attached | id='2f184cda-3e7a-4d13-89db-abc0e4002217' |
+-------------------------------------+----------------------------------------------------------+
重启服务
将task_status
的状态修改正确后再重启服务。一切正常
[root@ctl01 ~]# openstack server start 1caf85fb-e025-4834-afc8-50c3fb7887df
[root@ctl01 ~]# openstack server show 1caf85fb-e025-4834-afc8-50c3fb7887df
+-------------------------------------+----------------------------------------------------------+
| Field | Value |
+-------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig | AUTO |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | cs07 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | cs07 |
| OS-EXT-SRV-ATTR:instance_name | instance-00000015 |
| OS-EXT-STS:power_state | Running |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2021-08-26T03:25:01.000000 |
| OS-SRV-USG:terminated_at | None |
~~~
| volumes_attached | id='2f184cda-3e7a-4d13-89db-abc0e4002217' |
+-------------------------------------+----------------------------------------------------------+
其他扩展
查看server set
帮助后,感觉应该可以解决以前遇到的VM_state
是error
的情况
[root@ctl01 ~]# openstack server set --help
usage: openstack server set [-h] [--name <new-name>] [--root-password]
[--property <key=value>] [--state <state>]
[--description <description>]
<server>
Set server properties
positional arguments:
<server> Server (name or ID)
optional arguments:
-h, --help show this help message and exit
--name <new-name> New server name
--root-password Set new root password (interactive only)
--property <key=value>
Property to add/change for this server (repeat option
to set multiple properties)
--state <state> New server state (valid value: active, error)
--description <description>
New server description (supported by --os-compute-api-
version 2.19 or above)
以前的解决办法是直接修改数据库。有点土。步骤如下
update instances set task_state = NULL,vm_state = 'stopped', power_state = 4 , host='cs07' where uuid='1caf85fb-e025-4834-afc8-50c3fb7887df'