virsh list --all
看到在哪个主机上,就去数据库中将host和node信息设置为该主机,如我这虚拟机在computer07上[root@computer07 instances]# virsh list --all
Id Name State
----------------------------------------------------
4 instance-000006a6 running
- instance-000006a9 shut off
[root@computer07 instances]#
首先获取nova数据库的密码
控制节点执行:grep mysql /etc/nova/nova.conf
,如下,Changeme_123就是密码
[root@controller01 nova]# grep mysql /etc/nova/nova.conf
connection = mysql+pymysql://nova:Changeme_123@controller01/nova_api
#connection=mysql://nova:nova@localhost/nova
# by the server configuration, set this to no value. Example: mysql_sql_mode=
#mysql_sql_mode=TRADITIONAL
connection = mysql+pymysql://nova:Changeme_123@controller01/nova
# by the server configuration, set this to no value. Example: mysql_sql_mode=
#mysql_sql_mode=TRADITIONAL
# by the server configuration, set this to no value. Example: mysql_sql_mode=
#mysql_sql_mode=TRADITIONAL
mysql -unova -p
use nova;
[root@controller01 ~]# mysql -unova -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4286927
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]>
MariaDB [nova]> select * from instances where uuid='8c1fb8d2-d90d-4250-b64f-b18e2df0465c'\G
*************************** 1. row ***************************
created_at: 2023-09-12 16:14:21
updated_at: 2023-09-12 22:41:34
deleted_at: NULL
id: 1705
internal_id: NULL
user_id: 5357091ec61b472bb75668dfe3e2b7e5
project_id: 8d71dc6fb0f244c0875717774b66a8c2
image_ref: 47c2723b-f479-4a58-977c-e102c2b1d4ef
kernel_id:
ramdisk_id:
launch_index: 0
key_name: NULL
key_data: NULL
power_state: 0
vm_state: error
memory_mb: 8192
vcpus: 8
hostname: hegui-test-linux7.2-4
host: computer03
user_data: IyEvYmluL2Jhc2gKcGFzc3dkIHJvb3Q8PEVPRgpyb290CnJvb3QKRU9G
reservation_id: r-2mz46wcx
scheduled_at: NULL
launched_at: 2023-09-12 16:14:42
terminated_at: NULL
display_name: hegui-test-linux7.2-4
display_description: hegui-test-linux7.2-4
availability_zone: test001
locked: 0
os_type: NULL
launched_on: computer07
instance_type_id: 247
vm_mode: NULL
uuid: 8c1fb8d2-d90d-4250-b64f-b18e2df0465c
architecture: NULL
root_device_name: /dev/vda
access_ip_v4: NULL
access_ip_v6: NULL
config_drive:
task_state: NULL
default_ephemeral_device: NULL
default_swap_device: NULL
progress: 0
auto_disk_config: 1
shutdown_terminate: 0
disable_terminate: 0
root_gb: 200
ephemeral_gb: 0
cell_name: NULL
node: computer03
deleted: 0
locked_by: NULL
cleaned: 1
ephemeral_key_uuid: NULL
1 row in set (0.00 sec)
MariaDB [nova]> update instances set host='computer07',node='computer07' where uuid='8c1fb8d2-d90d-4250-b64f-b18e2df0465c'\G
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [nova]> select * from instances where uuid='8c1fb8d2-d90d-4250-b64f-b18e2df0465c'\G
*************************** 1. row ***************************
created_at: 2023-09-12 16:14:21
updated_at: 2023-09-12 22:41:34
deleted_at: NULL
id: 1705
internal_id: NULL
user_id: 5357091ec61b472bb75668dfe3e2b7e5
project_id: 8d71dc6fb0f244c0875717774b66a8c2
image_ref: 47c2723b-f479-4a58-977c-e102c2b1d4ef
kernel_id:
ramdisk_id:
launch_index: 0
key_name: NULL
key_data: NULL
power_state: 0
vm_state: error
memory_mb: 8192
vcpus: 8
hostname: hegui-test-linux7.2-4
host: computer07
user_data: IyEvYmluL2Jhc2gKcGFzc3dkIHJvb3Q8PEVPRgpyb290CnJvb3QKRU9G
reservation_id: r-2mz46wcx
scheduled_at: NULL
launched_at: 2023-09-12 16:14:42
terminated_at: NULL
display_name: hegui-test-linux7.2-4
display_description: hegui-test-linux7.2-4
availability_zone: test001
locked: 0
os_type: NULL
launched_on: computer07
instance_type_id: 247
vm_mode: NULL
uuid: 8c1fb8d2-d90d-4250-b64f-b18e2df0465c
architecture: NULL
root_device_name: /dev/vda
access_ip_v4: NULL
access_ip_v6: NULL
config_drive:
task_state: NULL
default_ephemeral_device: NULL
default_swap_device: NULL
progress: 0
auto_disk_config: 1
shutdown_terminate: 0
disable_terminate: 0
root_gb: 200
ephemeral_gb: 0
cell_name: NULL
node: computer07
deleted: 0
locked_by: NULL
cleaned: 1
ephemeral_key_uuid: NULL
1 row in set (0.00 sec)
MariaDB [nova]>
MariaDB [nova]> exit
Bye
[root@controller01 neutron]#
nova show 8c1fb8d2-d90d-4250-b64f-b18e2df0465c
nova reset-state --active 8c1fb8d2-d90d-4250-b64f-b18e2df0465c
nova stop 8c1fb8d2-d90d-4250-b64f-b18e2df0465c
【因为要去冷迁移,所以直接关机】
[root@controller01 neutron]# nova show 8c1fb8d2-d90d-4250-b64f-b18e2df0465c
+--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Property | Value |
+--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| OS-DCF:diskConfig | AUTO |
| OS-EXT-AZ:availability_zone | test001 |
| OS-EXT-SRV-ATTR:host | computer07 |
| OS-EXT-SRV-ATTR:hostname | hegui-test-linux7.2-4 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | computer07 |
| OS-EXT-SRV-ATTR:instance_name | instance-000006a9 |
| OS-EXT-SRV-ATTR:kernel_id | |
| OS-EXT-SRV-ATTR:launch_index | 0 |
| OS-EXT-SRV-ATTR:ramdisk_id | |
| OS-EXT-SRV-ATTR:reservation_id | r-2mz46wcx |
| OS-EXT-SRV-ATTR:root_device_name | /dev/vda |
| OS-EXT-SRV-ATTR:user_data | IyEvYmluL2Jhc2gKcGFzc3dkIHJvb3Q8PEVPRgpyb290CnJvb3QKRU9G |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | - |
| OS-EXT-STS:vm_state | error |
| OS-SRV-USG:launched_at | 2023-09-12T16:14:42.000000 |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| config_drive | |
| created | 2023-09-12T16:14:21Z |
| description | hegui-test-linux7.2-4 |
| fault | {"message": "error creating snapshot nova-resize from 8c1fb8d2-d90d-4250-b64f-b18e2df0465c_disk", "code": 500, "details": " File \"/usr/lib/python2.7/site-packages/nova/compute/manager.py\", line 375, in decorated_function |
| | return function(self, context, *args, **kwargs) |
| | File \"/usr/lib/python2.7/site-packages/nova/compute/manager.py\", line 4054, in finish_resize |
| | self._set_instance_obj_error_state(context, instance) |
| | File \"/usr/lib/python2.7/site-packages/oslo_utils/excutils.py\", line 220, in __exit__ |
| | self.force_reraise() |
| | File \"/usr/lib/python2.7/site-packages/oslo_utils/excutils.py\", line 196, in force_reraise |
| | six.reraise(self.type_, self.value, self.tb) |
| | File \"/usr/lib/python2.7/site-packages/nova/compute/manager.py\", line 4042, in finish_resize |
| | disk_info, image_meta) |
| | File \"/usr/lib/python2.7/site-packages/nova/compute/manager.py\", line 4007, in _finish_resize |
| | old_instance_type) |
| | File \"/usr/lib/python2.7/site-packages/oslo_utils/excutils.py\", line 220, in __exit__ |
| | self.force_reraise() |
| | File \"/usr/lib/python2.7/site-packages/oslo_utils/excutils.py\", line 196, in force_reraise |
| | six.reraise(self.type_, self.value, self.tb) |
| | File \"/usr/lib/python2.7/site-packages/nova/compute/manager.py\", line 4002, in _finish_resize |
| | block_device_info, power_on) |
| | File \"/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py\", line 7363, in finish_migration |
| | fallback_from_host=migration.source_compute) |
| | File \"/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py\", line 3179, in _create_image |
| | backend.create_snap(libvirt_utils.RESIZE_SNAPSHOT_NAME) |
| | File \"/usr/lib/python2.7/site-packages/nova/virt/libvirt/imagebackend.py\", line 938, in create_snap |
| | return self.driver.create_snap(self.rbd_name, name) |
| | File \"/usr/lib/python2.7/site-packages/nova/virt/libvirt/storage/rbd_utils.py\", line 382, in create_snap |
| | tpool.execute(vol.create_snap, name) |
| | File \"/usr/lib/python2.7/site-packages/eventlet/tpool.py\", line 125, in execute |
| | six.reraise(c, e, tb) |
| | File \"/usr/lib/python2.7/site-packages/eventlet/tpool.py\", line 83, in tworker |
| | rv = meth(*args, **kwargs) |
| | File \"/usr/lib/python2.7/site-packages/rbd.py\", line 594, in create_snap |
| | raise make_ex(ret, 'error creating snapshot %s from %s' % (name, self.name)) |
| | ", "created": "2023-09-12T22:36:17Z"} |
| flavor | 8c-8g-200G (f3463d6d-5d5c-45b7-b371-29e84c8a49e9) |
| hostId | a6531d2353b9eb7730d1cee93db522b51442cf6b2df6ef58026a39fb |
| host_status | UP |
| id | 8c1fb8d2-d90d-4250-b64f-b18e2df0465c |
| image | centos7.4 (47c2723b-f479-4a58-977c-e102c2b1d4ef) |
| key_name | - |
| locked | False |
| metadata | {} |
| name | hegui-test-linux7.2-4 |
| os-extended-volumes:volumes_attached | [] |
| out-network network | 111.11.199.77 |
| own-network network | 10.233.61.44 |
| security_groups | default |
| status | ERROR |
| tenant_id | 8d71dc6fb0f244c0875717774b66a8c2 |
| updated | 2023-09-12T22:41:34Z |
| user_id | 5357091ec61b472bb75668dfe3e2b7e5 |
+--------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@controller01 neutron]#
[root@controller01 neutron]# nova reset-state --active 8c1fb8d2-d90d-4250-b64f-b18e2df0465c
Reset state for server 8c1fb8d2-d90d-4250-b64f-b18e2df0465c succeeded; new state is active
[root@controller01 neutron]#
[root@controller01 neutron]# nova show 8c1fb8d2-d90d-4250-b64f-b18e2df0465c
+--------------------------------------+----------------------------------------------------------+
| Property | Value |
+--------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig | AUTO |
| OS-EXT-AZ:availability_zone | test001 |
| OS-EXT-SRV-ATTR:host | computer07 |
| OS-EXT-SRV-ATTR:hostname | hegui-test-linux7.2-4 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | computer07 |
| OS-EXT-SRV-ATTR:instance_name | instance-000006a9 |
| OS-EXT-SRV-ATTR:kernel_id | |
| OS-EXT-SRV-ATTR:launch_index | 0 |
| OS-EXT-SRV-ATTR:ramdisk_id | |
| OS-EXT-SRV-ATTR:reservation_id | r-2mz46wcx |
| OS-EXT-SRV-ATTR:root_device_name | /dev/vda |
| OS-EXT-SRV-ATTR:user_data | IyEvYmluL2Jhc2gKcGFzc3dkIHJvb3Q8PEVPRgpyb290CnJvb3QKRU9G |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | - |
| OS-EXT-STS:vm_state | active |
| OS-SRV-USG:launched_at | 2023-09-12T16:14:42.000000 |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| config_drive | |
| created | 2023-09-12T16:14:21Z |
| description | hegui-test-linux7.2-4 |
| flavor | 8c-8g-200G (f3463d6d-5d5c-45b7-b371-29e84c8a49e9) |
| hostId | a6531d2353b9eb7730d1cee93db522b51442cf6b2df6ef58026a39fb |
| host_status | UP |
| id | 8c1fb8d2-d90d-4250-b64f-b18e2df0465c |
| image | centos7.4 (47c2723b-f479-4a58-977c-e102c2b1d4ef) |
| key_name | - |
| locked | False |
| metadata | {} |
| name | hegui-test-linux7.2-4 |
| os-extended-volumes:volumes_attached | [] |
| out-network network | 111.11.199.77 |
| own-network network | 10.233.61.44 |
| progress | 0 |
| security_groups | default |
| status | ACTIVE |
| tenant_id | 8d71dc6fb0f244c0875717774b66a8c2 |
| updated | 2023-09-12T23:28:25Z |
| user_id | 5357091ec61b472bb75668dfe3e2b7e5 |
+--------------------------------------+----------------------------------------------------------+
[root@controller01 neutron]#
[root@controller01 neutron]# nova stop 8c1fb8d2-d90d-4250-b64f-b18e2df0465c
/var/lib/nova/instances/
目录【存放实例信息的目录】[root@computer07 ~]# cd /var/lib/nova/instances/
[root@computer07 instances]# ls
154f17ab-d37b-4162-a870-4016c107312a 6e5783f1-e12c-494d-bcdc-60389105b658 9bdb337a-f247-4d45-8a89-f9288b54d5dd compute_nodes
2cec04ce-5ca2-4910-ae7d-d782b8a2c23c 7e10aa19-3caa-4e95-b4e0-2df5de633023 b39a8ac9-2c20-4d4e-b820-fedc59b0385c e2e90bec-0d3a-4185-80da-0e2cf6218ed5
5b4f6012-d48a-444a-bf8b-b3acb48b054a 8c1fb8d2-d90d-4250-b64f-b18e2df0465c_resize _base locks
[root@computer07 instances]#
[root@computer07 instances]# mv 8c1fb8d2-d90d-4250-b64f-b18e2df0465c_resize 8c1fb8d2-d90d-4250-b64f-b18e2df0465c
[root@computer07 instances]#
[root@computer07 instances]# ls
154f17ab-d37b-4162-a870-4016c107312a 6e5783f1-e12c-494d-bcdc-60389105b658 9bdb337a-f247-4d45-8a89-f9288b54d5dd compute_nodes
2cec04ce-5ca2-4910-ae7d-d782b8a2c23c 7e10aa19-3caa-4e95-b4e0-2df5de633023 b39a8ac9-2c20-4d4e-b820-fedc59b0385c e2e90bec-0d3a-4185-80da-0e2cf6218ed5
5b4f6012-d48a-444a-bf8b-b3acb48b054a 8c1fb8d2-d90d-4250-b64f-b18e2df0465c _base locks
[root@computer07 instances]#
此时虚拟机就已经回退完成了,可以正常开机了。