解决删除Volume报错的问题
很久没有遇到过删除Volume出错使得Volume处于Error_Deleting状态的情况了,昨天删除一个Volume时又出现了这个问题,这里顺便把解决方法记录一下。 注意我这里针对的是后端采用iscsi方式的,具体到我这里是tgt+lvm方式。
原因
目前我所遇到的删除Volume出错的原因只有一个“设备正忙”,如果你查看Volume所在的存储节点的日志就会看如下类似的内容
[-] Exception during message handling
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/openstack/common/rpc/amqp.py", line 276, in _process_data
rval = self.proxy.dispatch(ctxt, version, method, **args)
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/openstack/common/rpc/dispatcher.py", line 145, in dispatch
return getattr(proxyobj, method)(ctxt, **kwargs)
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/volume/manager.py", line 206, in delete_volume
{'status': 'error_deleting'})
File "/usr/lib64/python2.6/contextlib.py", line 23, in __exit__
self.gen.next()
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/volume/manager.py", line 195, in delete_volume
self.driver.delete_volume(volume_ref)
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/volume/driver.py", line 203, in delete_volume
self._delete_volume(volume, volume['size'])
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/volume/driver.py", line 155, in _delete_volume
run_as_root=True)
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/volume/driver.py", line 98, in _try_execute
self._execute(*command, **kwargs)
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/utils.py", line 187, in execute
cmd=' '.join(cmd))
ProcessExecutionError: Unexpected error while running command.
Command: sudo cinder-rootwrap /etc/cinder/rootwrap.conf dmsetup remove -f /dev/mapper/nova--volumes-volume--c1374407--d1b3--407f--bbcc--7416756071c1
Exit code: 1
Stdout: ''
Stderr: 'device-mapper: remove ioctl failed: Device or resource busy\nCommand failed\n'
那设备为什么会忙呢?首先我们在Volume所在的存储节点通过tgtadm --lld iscsi --mode target --op show 命令来查看我们要删除的Volume的信息如下
Target 7: iqn.2010-10.org.openstack:volume-c1374407-d1b3-407f-bbcc-7416756071c1
System information:
Driver: iscsi
State: ready
I_T nexus information:
I_T nexus: 24
Initiator: iqn.1994-05.com.redhat:351f5adb9c85
Connection: 0
IP Address: 10.61.2.5
LUN information:
......
原来是我们有一个计算节点到这个Volume的链接没有释放。这里我要先说下iscsi+lvm的大致的工作方式,创建Volume时先在配置项指定的VG中创建一个LV大小Volume的大小, 然后通过tgtadm这个管理命令创建一个iscsi Target并将所创建的LV作为Target的后端存储。给实例挂载时,实例所在的计算节点调用iscsiadm命令链接到Volume对应的Target上 然后底层虚拟化软件再把这个Target指定给实例用。卸载Volume的时候就是底层虚拟化软件先从实例中移除这个Target,然后计算节点再释放它。所以如果有计算节点有链接由于某种 原因没有释放Target的话就会出现上面的情况,当时一般情况是不会出现这种问题的,但是我发现如果一个挂载有Volume的实例从一个节点迁移到另一个节点,源节点到Target的链接 并不会释放,也就是同时有两个节点链接到Target上,然后就会出现上面的问题。
解决方法
过程和原因清楚后,解决起来也就简单了,释放链接,重置Volume的状态,然后删除。首先我们登录计算节点用iscsiadm命令释放链接
[root@stack5 ~]# iscsiadm -m node -T iqn.2010-10.org.openstack:volume-c1374407-d1b3-407f-bbcc-7416756071c1 -u
修改数据库,重置Volume的状态
[root@stack5 ~]# mysql -h 10.61.2.12 -u cinder -p cinder -e "update volumes set status ='available' where id = 'c1374407-d1b3-407f-bbcc-7416756071c1'"
以前这样操作后就能正常删除Volume了,但这次竟然还报错了,看来得上绝招了
Clear capabilities
Removing volume: c1374407-d1b3-407f-bbcc-7416756071c1
[-] Exception during message handling
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/openstack/common/rpc/amqp.py", line 276, in _process_data
rval = self.proxy.dispatch(ctxt, version, method, **args)
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/openstack/common/rpc/dispatcher.py", line 145, in dispatch
return getattr(proxyobj, method)(ctxt, **kwargs)
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/volume/manager.py", line 206, in delete_volume
{'status': 'error_deleting'})
File "/usr/lib64/python2.6/contextlib.py", line 23, in __exit__
self.gen.next()
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/volume/manager.py", line 193, in delete_volume
self.driver.remove_export(context, volume_ref)
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/volume/driver.py", line 474, in remove_export
self.tgtadm.remove_iscsi_target(iscsi_target, 0, volume['id'])
File "/usr/lib/python2.6/site-packages/cinder-2012.2.1-py2.6.egg/cinder/volume/iscsi.py", line 168, in remove_iscsi_target
raise exception.ISCSITargetRemoveFailed(volume_id=vol_id)
ISCSITargetRemoveFailed: Failed to remove iscsi target for volume c1374407-d1b3-407f-bbcc-7416756071c1.
解决方法二
这个方法就比较暴力了,直接手动搞了。更新数据库标记Volume为已删除,在存储节点用tgtadm命令删除对应的Target,清空对应LV的数据,用lvremove命令删除LV,搞完收工。
[root@store2 ~]# mysql -h 10.61.2.12 -u cinder -p cinder -e "update volumes set deleted = 1, deleted_at = now() where id = 'c1374407-d1b3-407f-bbcc-7416756071c1'"
[root@store2 ~]# tgtadm --lld iscsi --mode target --op delete --tid 7
[root@store2 ~]# dd if=/dev/zero of=/dev/mapper/nova--volumes-volume--c1374407--d1b3--407f--bbcc--7416756071c1 bs=1M
[root@store2 ~]# lvremove /dev/mapper/nova--volumes-volume--c1374407--d1b3--407f--bbcc--7416756071c1
解决删除Volume报错的问题的更多相关文章
- SharePoint 2013 删除母版页报错“This file may not be moved, deleted, renamed, or otherwise edited”
在使用SharePoint 2013母版页的时候,我复制了一个seattle.master页面,然后想重命名一下发现报错,删除也报错,spd.页面分别试过签入签出以后均报错,错误如下: 尝试找了一下错 ...
- 解决:MySQL 报错:1045 - Access denied for user 'root'@'localhost'(using password YES)
一.前言 今年疯狂迷上了开源,只要看到好的开源项目,就会不顾一切一股脑扎进去研究,五一期间发现一个很好的关于众筹的开源项目,但不巧,这个项目竟然是 PHP 写的,没学过 PHP,自然对这个开源项目毫无 ...
- homestead虚拟机,通过npm下载依赖包和解决运行gulp报错问题 yarn出错问题
homestead虚拟机,通过npm下载依赖包和解决运行gulp报错问题 yarn出错问题 1. 在虚拟器运行 npm 下载依赖组件时报错: npm ERR! EPROTO: protocol err ...
- elasticsearch删除索引报错【原】
如果elasticsearch删除索引报错 curl -X DELETE 'http://10.73.26.66:9200/httpd-34-2017.08.15' {"error" ...
- 解决kylin查询报错:org.apache.kylin.rest.exception.InternalErrorException
报错信息: -- ::, ERROR [Query 12e9c054-760c---b1f06724c9b6-] service.QueryService: : Exception when exec ...
- 完美解决JavaIO流报错 java.io.FileNotFoundException: F:\ (系统找不到指定的路径。)
完美解决JavaIO流报错 java.io.FileNotFoundException: F:\ (系统找不到指定的路径.) 错误原因 读出文件的路径需要有被拷贝的文件名,否则无法解析地址 源代码(用 ...
- Appium 【已解决】提示报错:Attempt to re-install io.appium.android.ime without first uninstalling.
详细报错:Failed to install D:\AutoTest\appium\Appium\node_modules\appium\build\unicode_ime_apk\UnicodeIM ...
- MariaDB:删除数据库报错:error: 'Error dropping database (can't rmdir './shiro', errno: 39)'
今天在删除一个库的时候报错,如下图所示. 删除命名:mysqladmin –u root –p drop shiro 解决办法: 删除./shiro目录下面的所有文件和目录. 重新执行删除命令即可!
- 【Linux】解决Android Stadio报错:error in opening zip file
报错: Failed to complete Gradle Execution Cause: error in opening zip file. 原因: 安装gradle失败引起的,往往是上网需要验 ...
随机推荐
- (Problem 16)Power digit sum
215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of th ...
- Spring如何管理Session【转贴】
在使用Spring进行系统开发的时候,数据库连接一般都是配置在Spring的配置文件中,并且由Spring来管理的.在利用Spring + Hibernate进行开发时也是如此.下面是一个简单的Spr ...
- zk mysql 主从自动切换
zookeeper测试: DBI 版本: /DBI-1.616# zjtest7-redis:/root/DBD-mysql-4.031# perl Makefile.PL Can't exec &q ...
- 基于visual Studio2013解决算法导论之020单链表
题目 单链表操作 解决代码及点评 #include <iostream> using namespace std; struct LinkNode { public: LinkNo ...
- [置顶] jeecg-framework-3.3.2-RELEASE 最新版本发布
平台介绍 JEECG(J2EE CodeGeneration)是一款基于代码生成器的智能开发平台,引领新开发模式(OnlineCoding模式->代码生成器模式->手工MERGE智能开 ...
- Debian为程序添加一个开始菜单,debian添加sublime开始菜单.
下了一个 '绿色' 的程序,想要加到开始菜单里面. 怎么做呢? 我这里以sublime2做例 去http://www.sublimetext.com/2 下载了linux 64位, 解压放到了下面的文 ...
- 管理tips
管理是什么? 我认为达到的目的就是高效.低成本. 成本低才能有盈余,才能活的长和舒服.高效就是无谓的消耗少,以结果为导向. 开源节流,应该包含显性的与隐性的两方面. 隐性成本: 1.会议成本;2.沟通 ...
- c# 阶段总结
然并卵然并卵然并卵然并卵然并卵然并卵然并卵
- 14-UIKit(拖拽手势、布局)
目录: 1.手势创建的拖拽方式 2.frame,bounds,transform,center区别 3.触控(touch) 4.布局 5.代码布局 回到顶部 1.手势创建的拖拽方式 创建手势对象,修改 ...
- Python 30分钟入门——数据类型 & 控制结构
Python是一门脚本语言,我也久闻大名,但正真系统的接触学习是在去年(2013)年底到今年(2014)年初的时候.不得不说的是Python的官方文档相当齐全,假设你是在Windows上学习Pytho ...