我在测试时遇到下面问题:
现象:
在部署完虚拟机后,第一次启动时启动的比较慢,大概要花数分钟,这个时间不是花在磁盘镜像拷贝上,而是花在cloud-init上。经过与ibm同事讨论,认为要删除/etc/resolv.conf,但删除了这个文件后,现象仍然存在。有哪个兄弟遇到过这个问题。
看了一下cloud-init的log如下,有两个间隔2分钟的地方。
2016-12-19 09:24:26,585 - util.py[DEBUG]: Writing to/opt/freeware/var/lib/cloud/instances/180c7383-e478-4d8a-a36f-d3c88b0a03c6/sem/config_set_hostname- wb: [420] 23 bytes
2016-12-19 09:24:26,587 - helpers.py[DEBUG]: Runningconfig-set_hostname using lock (
2016-12-19 09:24:26,588 - cc_set_hostname.py[DEBUG]: Setting thehostname to node1.localdomain (node1)
2016-12-19 09:24:26,588- util.py[DEBUG]: Running command ['/usr/sbin/chdev', '-l', 'inet0', '-a','hostname=node1'] with allowed return codes [0] (shell=False, capture=True)
2016-12-19 09:27:04,963- util.py[DEBUG]: Running command ['/usr/bin/uname', '-S', 'node1'] withallowed return codes [0] (shell=False, capture=True)
2016-12-19 09:27:04,975 - __init__.py[DEBUG]: Non-persistentlysetting the system hostname to node1
2016-12-19 09:27:04,976- util.py[DEBUG]: Running command ['hostname', u'node1'] with allowed returncodes [0] (shell=False, capture=True)
2016-12-19 09:29:49,308- helpers.py[DEBUG]: Running config-update_etc_hosts using lock(
2016-12-19 09:29:49,309 -cc_update_etc_hosts.py[DEBUG]: Configuration option 'manage_etc_hosts' is notset, not managing /etc/hosts in module update_etc_hosts
首先从cloud-init的日志可以追踪到cloud-init默认会去搜寻dns,如果您的环境中使用了dns那样速度会很快,如果没有使用dns可以通过辅助脚本删除resolv.cnf文件。
然后cloud-init的modules是可以自定义的,我们可以删除不必要的modules,这样在部署时候就不需要去检测查找python脚本,也可以在一定程度上加快部署速度。
收起