Cinder 调试 - cinder service 状态为 down
1. 问题
我们经常会发现某个cinder service 的状态为 down。比如下面例子中 controller 上的 cinder-scheduler 和 block1 节点上 cinder-volume 的状态都为 down。
s1@controller:~$ cinder service-list
+------------------+---------------------------+------+---------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+---------------------------+------+---------+-------+----------------------------+-----------------+
| cinder-backup | controller | nova | enabled | up | 2015-03-30T00:53:32.000000 | None |
| cinder-scheduler | controller | nova | enabled | down | 2015-03-30T00:51:53.000000 | None |
| cinder-volume | block1 | nova | enabled | down | 2015-03-30T00:54:43.000000 | None |
| cinder-volume | block2@lvmdriver-b21 | az1 | enabled | up | 2015-03-30T00:54:14.000000 | None |
| cinder-volume | block2@lvmdriver-b22 | az1 | enabled | up | 2015-03-30T00:54:13.000000 | None |
| cinder-volume | network@lvmdriver-network | nova | enabled | up | 2015-03-30T00:54:08.000000 | None |
+------------------+---------------------------+------+---------+-------+----------------------------+-----------------+
先来看看 cinder-list 的实现代码:
class ServiceController(wsgi.Controller):
@wsgi.serializers(xml=ServicesIndexTemplate)
def index(self, req):
"""Return a list of all running services.
Filter by host & service name.
"""
context = req.environ['cinder.context']
authorize(context)
detailed = self.ext_mgr.is_loaded('os-extended-services')
now = timeutils.utcnow() //获取controller 当前的时间
services = db.service_get_all(context) //从 db 获取所有的 cinder service 列表
...
svcs = []
for svc in services: //轮询每个 service
delta = now - (svc['updated_at'] or svc['created_at']) //获取 updated_at。不存在的话,获取 created_at,并和当前时间计算时间差
alive = abs(utils.total_seconds(delta)) <= CONF.service_down_time //获取时间差值的绝对值,并检查是否小于配置的 server_down_time,该配置项默认是60秒
art = (alive and "up") or "down" //如果差值小于60,则service 状态为 up,否则为 down
active = 'enabled'
......
svcs.append(ret_fields)
return {'services': svcs}
可见 service 的 up/down 状态取决于数据库中 service 表对应某 service 的行的 updated_at 列的值和当前 controller 节点的时间的差值是否在配置的范围之内。
2. Cinder Service 的 update_at 值更新机制
cinder 的各种service,比如cinder-api,cinder-backup 等,都是 /cinder/service.py 文件中 class Service(service.Service) 的一个实例,该类的 start 方法如下:
def start(self):
version_string = version.version_string()
LOG.info(_('Starting %(topic)s node (version %(version_string)s)'),
{'topic': self.topic, 'version_string': version_string})
...if self.report_interval: //如果设置了 report_interval 配置项,那么该 service 将启动一个无限循环来执行 report_state 方法,运行间隔就是 report_interval,其默认值是 10 秒
pulse = loopingcall.FixedIntervalLoopingCall(
self.report_state)
pulse.start(interval=self.report_interval,
initial_delay=self.report_interval)
self.timers.append(pulse)
report_state 方法会更新 db 中serive 的各个属性,其中 updated_at 的值就是所在节点上执行一次该方法的时刻。
def report_state(self):
"""Update the state of this service in the datastore."""
ctxt = context.get_admin_context()
zone = CONF.storage_availability_zone
state_catalog = {}
try:
...
service_ref = db.service_get(ctxt, self.service_id) // 获取service 的 ref
...
db.service_update(ctxt, self.service_id, state_catalog) //更新该 service
...
3. 问题定位步骤
(1)看看是不是在 cinder.conf 中 report_interval 配置项的值是多少,如果超过了 service_down_time 配置项默认的 60 秒,那么该service 的状态肯定就是 'down' 了。
(2)看 service 所在节点的时间,它的时间和 controller 节点的时间误差必须在 [service_down_time - report_interval ] 之内,也就是在使用默认配置情况下,时间差必须在 50 秒之内。
(3)看看 service 的 log 文件中,确认 report_state 方法是不是都按时被调用了,不方便看的话,在代码中加个注释吧。比如:
2015-04-11 15:26:24.210 8517 DEBUG cinder.service [-] enter report_state .. report_state /usr/lib/python2.7/dist-packages/cinder/service.py:283
4. 问题解决
(1). 检查 block1 的时间
发现 block1 的时间 和 controller 不同步。通过同步 block1 和 controller 的时间,block1 上的 cinder-volume 的状态变为了 up。
(2). 检查 cinder-scheduler service 的 updated_at
发现 cinder-scheduler 的 updated_at 是 2015-03-30 01:32:26, 而 controller 的当前时间是 2015-04-11 02:26:20。排除时间差因素,基本可以确定是该服务的时间上报出了问题。检查 cinder-schedule 的log,发现因为 bug 该 service 真的down了。fix bug,然后重启服务,其状态变为 up。
Cinder 调试 - cinder service 状态为 down的更多相关文章
- C#创建、安装、卸载、调试Windows Service(Windows 服务)的简单教程
前言:Microsoft Windows 服务能够创建在它们自己的 Windows 会话中可长时间运行的可执行应用程序.这些服务可以在计算机启动时自动启动,可以暂停和重新启动而且不显示任何用户界面.这 ...
- 监听调试web service的好工具TCPMon
监听调试web service的好工具TCPMonhttp://ws.apache.org/commons/tcpmon/download.cgi TCPMon Tutorial Content In ...
- 调试Windows Service
调试Windows Service 使用一般的调试方法调试不了Windows Servers,所以参考了一些调试方法 我服务源码中使用了Timer,注意不能使用工具箱内的Timer,用System.T ...
- Cinder 调试 - 无法挂载到虚拟机
1.问题 我们有时候在通过云主机挂载云硬盘的时候会出现挂载不上的问题.像这中问题有多种情况导致的. 看一下我遇到的两种情况. 1.权限问题 在cinder节点查看 /var/log/cinder/ci ...
- 在 UWP 应用中创建、使用、调试 App Service (应用服务)
在 Windows 10 中微软为 UWP 引入了 App Service (即应用服务)这一新特性用以提供应用间交互功能.提供 App Service 的应用能够接收来自其它应用传入的参数进行处理后 ...
- Win7中不能调试windows service
多年前玩过一次windows service,觉得挺简单的. 这次工作要维护产品中的windows service,发现不是那么简单,vs附加调试器的窗体中无法找到windows service进程. ...
- SharePoint 2013 Service 状态无法启动,显示“启动中(Starting)”
Problem 在SharePoint 2013 Central Administration中启动 SharePoint Service(也称为:Service Machine Instance)时 ...
- 【OpenStack Cinder】Cinder安装时遇到的一些坑
最近需要安装Cinder组件,然后遇到了两个比较蛋疼的错误导致controller节点输入cinder service-list一直不能显示cinder节点上的cinder-volume服务. 错误1 ...
- 用.NET WebService Studio调试Web Service解决SOAPAction的问题
话说是这样的,这两天开发一个短信发送功能,客户给了一个 Web Service 地址(没有文档),让我调用就可以发送了, 我在VS 2013添加了服务引用,一切正常,可是执行代理方法时,怎么都报错 R ...
随机推荐
- MySQL数据库 安装图解
下面的是MySQL安装的图解,用的可执行文件:下载地址:http://www.jinhusns.com/Products/Download/?type=xcj相关下载 mysql安装向导启动,按“Ne ...
- ToDoList:一款非常优秀的任务管理软件 —— 工具类
ToDoList是一款非常优秀的任务管理软件,用户可以方便地组织和安排计划.这是一个开源的项目,很多细节都考虑到了,推荐大家使用~ ToDoList 帮你把要做的事情列出来,一项一项,类似思维导图. ...
- LeetCode127:Word Ladder II
题目: Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) ...
- linux 常用技巧
1--查看版本 查看内核版本 # cat /proc/version 查看linux版本 # lsb_release -a或者 cat /etc/issue 2--linux服务器测速 speedte ...
- Ogre2.1 灯光与阴影
Ogre2.1大量光源渲染 Ogre2.1不是采用现在大部分引擎所用的延迟渲染,而是采用一种前向渲染的改进技术,理论基本来自于Forward+,见如下. http://www.klayge.org/? ...
- jquery重置html form
很多时候在ajax提交或者对话框隐藏之后,我们希望重置默认值以便下次打开对话框时保持干净. 因为jquery选择器返回的是list,并且没有对此提供reset方法,所以需要针对单个元素进行reset. ...
- 用javascript实现全选/反选组件
以下是本人制作的全选/反选 组件,供广大同行参考.指正: 效果如图: 在实现的过程中,全选和全部取消选中这两个功能较为简单,只需用for循环遍历所有复选框为true或false即可.反选也较为简单,也 ...
- ASP.NET页面动态添加js脚本
有时我们需要生成自己的JavaScript代码并在运行时动态添加到页面,接下来我们来看一下如何将生成的JavaScript代码动态添加到ASP.NET页面. 为了添加脚本,要将自定义的脚本在一个字符串 ...
- 使用RDCMan管理SharePoint虚拟机的重复要求验证的问题
首先,这个软件可以从这里下载: Remote Desktop Connection Manager 同类型的软件还有很多,我没有很多复杂功能的要求,就选择了这款微软官方的,虽然很久都没有更新过了. 为 ...
- SQL学习笔记:选取第N条记录
Northwind数据库,选取价格第二高的产品. 有两种方法,一个是用Row_Number()函数: SELECT productname FROM ( productname, Row_Number ...