出处http://blog.csdn.net/tantexian/article/details/39204993
环境:centos6.5 openstack ice版
1、
2、
3、
vim /usr/bin/nova-manage
load_entry_point('nova==2014.1.1', 'console_scripts', 'nova-manage')()
第一个参数定向到 /usr/lib/python2.6/site-packages/nova-2014.1.1-py2.6.egg-info/
然后搜索EGG-INFO/entry_points.txt
vim /usr/lib/python2.6/site-packages/nova-2014.1.1-py2.6.egg-info/entry_points.txt
|
搜索
load_entry_point('nova==2014.1.1', 'console_scripts', 'nova-manage')()
|
console_scripts、nova-manage
得到入口地址为:
nova-manage = nova.cmd.manage:main
|
4、
5、
@args('--host', metavar='<host>', help='Host')
@args('--service', metavar='<service>', help='Nova service')
def list(self, host=None, service=None):
"""Show a list of all running services. Filter by host & service
name
"""
servicegroup_api = servicegroup.API()
ctxt = context.get_admin_context()
services = db.service_get_all(ctxt) #获取nova service数据库表所有数据
services = availability_zones.set_availability_zones(ctxt, services)
if host:
services = [s for s in services if s['host'] == host]
if service:
services = [s for s in services if s['binary'] == service]
print_format = "%-16s %-36s %-16s %-10s %-5s %-10s"
print(print_format % ( #此处打印出图1.1
_('Binary'),
_('Host'),
_('Zone'),
_('Status'),
_('State'),
_('Updated_At')))
for svc in services:
alive = servicegroup_api.service_is_up(svc) #检测服务是否为alive 、重点解析此处的代码根据
art = (alive and ":-)") or "XXX"
active = 'enabled'
if svc['disabled']:
active = 'disabled'
print(print_format % (svc['binary'], svc['host'],
svc['availability_zone'], active, art,
svc['updated_at']))
图1.1:
6、service_is_up:(根据到7讲解is_up函数)
注:大家可以再下图中看到,判断服务状态,可以有多重方式,有db、还有zookeeper等。从上图可知本次中使用的为db检查服务状态。
7、讲解is_up函数:
def is_up(self, service_ref):
"""Moved from nova.utils
Check whether a service is up based on last heartbeat.
"""
last_heartbeat = service_ref['updated_at'] or service_ref['created_at'] #获取服务最后一次更新时间,或者第一次创建时间,最为心跳时间
if isinstance(last_heartbeat, six.string_types): #此处代码就是将上面获取的心跳时间,转换成datetime时间
# NOTE(russellb) If this service_ref came in over rpc via
# conductor, then the timestamp will be a string and needs to be
# converted back to a datetime.
last_heartbeat = timeutils.parse_strtime(last_heartbeat)
else:
# Objects have proper UTC timezones, but the timeutils comparison
# below does not (and will fail)
last_heartbeat = last_heartbeat.replace(tzinfo=None)
# Timestamps in DB are UTC.
elapsed = timeutils.delta_seconds(last_heartbeat, timeutils.utcnow()) #此处计算出心跳时间与当前时间的差值
LOG.debug('DB_Driver.is_up last_heartbeat = %(lhb)s elapsed = %(el)s',
{'lhb': str(last_heartbeat), 'el': str(elapsed)})
return abs(elapsed) <= CONF.service_down_time#此处根据差值来判断服务是否正常(比较时间为配置文件配置。如下图:)
nova.conf中:
所以最近更新时间,或者第一次创建时间与当前时间间隔少于CONF.service_down_time(60秒),则认为服务alive
从这里也可以得知为什么控制节点和计算节点的时间要一致。
接下来试验验证一下:
现在强制修改数据库表中nova-compute的update_at时间:
由2014-08-04 23:51:24修改为:2014-08-04 22:51:24
再来查看状态:
版权声明:欢迎大家转载,转载请注明出处blog.csdn.net/tantexian。
相关推荐
9. **nova-manage service list**:检查Nova服务的状态,确认各个组件是否正常运行。 10. **nova-manage floating list**:列出所有浮动IP,浮动IP用于为虚拟机提供动态可分配的公网IP地址。 11. **keystone ...
su -s /bin/sh -c "nova-manage db sync" ``` 4. **验证数据库表**: ```bash mysql -u root -p000000 -e "use nova; show tables;" ``` ##### 步骤三:注册Nova服务至Keystone服务器 为确保Nova服务能够正常...
- **查看现有的浮动IP列表**: 使用`nova-manage floating list`命令来查看当前存在的浮动IP地址。 - **为实例分配浮动IP**: 使用`nova floating-ip-create <pool>`命令为实例创建并分配一个浮动IP,之后使用`nova ...
- `nova-manage service list` 列出Nova服务的状态,Nova是OpenStack的计算服务。 14. **创建密钥对**: - `nova keypair-add oskey 创建一个新的密钥对,`oskey.priv` 是私钥文件。 - `chmod 600 oskey.priv` ...
- 使用命令`nova-manage floating list`。 - **为实例分配浮动IP**: - 首先使用命令`novafloating-ip-create <pool>`获取一个浮动IP地址。 - 使用命令`nova add-floating-ip <instance> <ip_address>`将浮动IP...
# keystone endpoint-create --service-id=$(keystone service-list | awk '/ identity / {print $2}') \ --publicurl=http://$HOST:35357/v2.0 \ --internalurl=http://$HOST:35357/v2.0 \ --adminurl=http://$...
例如,Compute服务(Nova)可以与Image Service(Glance)集成,以便在启动实例时自动选择合适的镜像。 ##### 架构样例 典型的OpenStack部署通常包括以下几类节点: - **控制节点**:运行OpenStack的服务端组件,...
- **检查服务状态:** 使用`nova service-list`命令来查看Nova服务的状态,确保所有服务都已启动并运行正常。 #### 六、安装和配置Dashboard **1. 安装Dashboard** - **安装Horizon:** Horizon是OpenStack的Web...
为了方便后续操作,可以将一些常用的环境变量添加到`/etc/profile`文件中,例如`SERVICE_TOKEN`、`OS_TENANT_NAME`、`OS_USERNAME`等。 #### 四、注意事项 - 在安装过程中,切忌简单地复制粘贴命令,而应该仔细...