<wbr><wbr><wbr><wbr><span style="font-size:16px">最近几天因为系统定制化的需求,集中研究了一下OpenStack的user_data的相关细节<a href="http://blog.sina.com.cn/s/blog_4f4d508a01016nd3.html" target="_blank">OpenStack虚拟机的用户客制化方法(User Data)</a><span style="color:#000000"><a href="http://http://blog.sina.com.cn/s/blog_4f4d508a01016nd3.html" target="_blank">,<span style="font-family:宋体">上一遍博文最后提到了只成功测试了ubuntu的cloudimage,而自己用mirrors上下载的iso镜像创建image后即使安装了cloud-init<span style="color:#000000">这个包,也会出现<span style="color:#000000">诸如在OpenStackdashboard中<span style="color:#000000">创建虚拟机时所填的主机名并<span style="color:#000000">未导入,user_data不可用<span style="color:#000000">等问题,查看cloud-init的log会显示</span></span></span></span></span></span></a></span></span></wbr></wbr></wbr></wbr>
2012-10-30 14:57:43,189 - cloud-init[INFO]:cloud-init start running: Tue, 30 Oct 2012 06:57:43 +0000. up 6.99seconds
2012-10-30 14:57:43,249 - __init__.py[DEBUG]: searching for datasource in ['DataSourceNoCloudNet', 'DataSourceConfigDriveNet','DataSourceOVFNet', 'DataSourceMAAS']
2012-10-30 14:57:43,269 - __init__.py[DEBUG]: Did not find datasource. searched classes: ['DataSourceNoCloudNet','DataSourceConfigDriveNet', 'DataSourceOVFNet','DataSourceMAAS']
而正常的log应该会显示
2012-10-31 10:56:38,008 - cloud-init[INFO]: cloud-init startrunning: Wed, 31 Oct 2012 02:56:37 +0000. up 8.83 seconds
2012-10-31 10:56:38,050 - __init__.py[DEBUG]: searching for datasource in ['DataSourceNoCloudNet', 'DataSourceOVFNet','DataSourceEc2']
2012-10-31 10:56:53,270 - DataSourceEc2.py[DEBUG]: Using metadatasource: 'http://169.254.169.254'
2012-10-31 10:56:53,329 - DataSourceEc2.py[DEBUG]: crawl ofmetadata service took 0s
2012-10-31 10:56:53,329 - __init__.py[DEBUG]: found data sourceDataSourceEc2
日志显示找不到meadata source 169.254.169.254,这是一个内部的local source
<wbr><wbr><wbr><wbr><span style="font-size:16px">昨晚在网上查找了大量资料,发现有关cloud-init的资料比较少,最后在rackspace的网站上发现了一份编辑镜像的代码,终于找到了方法。<br>
按照OpenStack创建ubuntu镜像的官方文档,我们在安装系统后仅仅需要</span></wbr></wbr></wbr></wbr>
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install openssh-server cloud-init
#Remove the network persistence rules from /etc/udev/rules.das their presence will result in
#the network interface in the instance coming up as an interfaceother than eth0.
sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules
然后实际上cloud-init包的安装是需要配置的,配置方法为
echo "cloud-init cloud-init/datasources string NoCloud, OVF,Ec2" > /tmp/debconf-selections
/usr/bin/debconf-set-selections /tmp/debconf-selections
rm -f /tmp/debconf-selections
apt-get -y install cloud-init
debconf-set-selections命令可以在包安装的时候对包进行必要的配置,配置参数NoCloud表示instance运行在一个简单的没有metadata服务的系统上,boot是后连接系统的local metadata sourcehttp://169.254.169.254:80。进行上述配置后,重新制作镜像,上述问题经试验一切正常。
稍后可能在研究下CentOS和Fedora上的解决方法供大家参考。
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com