删除 OpenStack Nova Volume 时遇到的 error_deleting 问题

前段时间 VPSee 在 OpenStack Nova 上删除一个 volume 的时候(vol-00000002)报错,检查了一下 volume 的状态是 error_deleting 然后就无法删除了,不管用 euca-delete-volume 还是 nova-manage volume delete 都无法删除。

# euca-delete-volume vol-00000002
ApiError: ApiError: Volume status must be available

# euca-describe-volumes 
VOLUME	vol-00000002  10  nova	error_deleting (mycloud, node01, None, None)	2011-08-30T13:15:24Z
VOLUME	vol-00000003  10  nova	available (mycloud, node01, None, None)	2011-08-30T13:20:04Z

查了一下要删除的 volume-00000002 的情况:

# lvdisplay
...
--- Logical volume ---
  LV Name                /dev/nova-volumes/volume-00000002
  VG Name                nova-volumes
  LV UUID                UgOwdr-W61E-MrdG-PrdY-IToa-LBi8-2XJjXF
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                10.00 GiB
  Current LE             2560
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           251:2
...

既然用工具没法删除的话就干脆从数据库里直接删除,无非就是一条记录而已,先从 nova 数据库里找到这条 volume 记录并设置状态为 deleted,然后删除实际对应的 LVM. 从数据库里找到相应的表和记录后设置 status 为 deleted 状态:

# mysql -u root -p
Enter password:

mysql> use nova;

mysql> select status,id from volumes;
+----------------+----+
| status         | id |
+----------------+----+
| creating       |  1 |
| error_deleting |  2 |
| available      |  3 |
+----------------+----+
3 rows in set (0.00 sec)

mysql> update volumes set status='deleted' where id='2';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

退出 mysql 数据库操作回到命令行就会看到 vol-00000002 的状态是 deleted 的,然后用 lvmremove 命令删除:

# euca-describe-volumes 
VOLUME	vol-00000002  10  nova	deleted (mycloud, node01, None, None)	2011-08-30T13:15:24Z

# ls /dev/nova-volumes/
volume-00000002 volume-00000003

# lvremove /dev/nova-volumes/volume-00000002 
Do you really want to remove active logical volume volume-00000002? [y/n]: y
  Logical volume "volume-00000002" successfully removed

最后用 nova-manage 命令从数据库里彻底删除 vol-00000002(当然也可以直接在 mysql 里用 SQL 语句操作删除对应的记录 DELETE FROM volumes WHERE id=’2′;):

# nova-manage volume delete vol-00000002

# euca-describe-volumes 
VOLUME	vol-00000003  10  nova	available (mycloud, node01, None, None)	2011-08-30T13:20:04Z

评论 (1 Comment)

  1. 从 nova-volume.log 日志中, 看到是 sudo dd …. 造成的删除出错, 由此, 推出是由于 nova 用户没有 sudo 权, 使用root 开放 nova 用户的sudo 使用权即可

发表评论