ECS怎样安装 cloud-init-问答-阿里云开发者社区-阿里云

开发者社区> boxti> 正文

ECS怎样安装 cloud-init

2017-10-18 14:02:59 1963 0

在导入镜像时,为了保证导入的镜像 hostname、NTP 和 Yum 源配置成功,建议您先在实例上安装 cloud-init。目前 cloud-init 支持的系统包括:CentOS、Debian、Fedora、FreeBSD、Gentoo、RHEL(Red Hat Enterprise Linux)、SLES(SUSE Linux Enterprise Server)和 Ubuntu。
本文介绍了如何安装 cloud-init。

前提条件


您的实例中应该已经安装了:

  • git:用于下载 cloud-init 源码包。

    安装命令:yum install git。

  • python2.7:是 cloud-init 运行和安装的基础。

    安装命令:yum install python。

  • pip:用于安装一些 python2.7 里缺少但是 cloud-init 依赖的库。

    安装命令:yum install python-pip。

由于不同系统包管理器不一样,这里只列举了 yum 方式。对于 zypper 或者 apt-get 的包管理器安装方式类似。

操作步骤


您可以按以下步骤安装 cloud-init。

  1. 执行以下命令从 cloud-init 官网下载 cloud-init 源码包。[backcolor=transparent]git clone https[backcolor=transparent]:[backcolor=transparent]//git.launchpad.net/cloud-init

执行以下命令进入 cloud-init 目录。
  1. [backcolor=transparent]cd cloud[backcolor=transparent]-[backcolor=transparent]init

运行以下命令安装 cloud-init 的安装文件 setup.py。
  1. [backcolor=transparent]python setup[backcolor=transparent].[backcolor=transparent]py install

安装过程中,如果出现以下信息,表示 Python 缺少 six 和 oauthlib 库。您可以使用 pip 安装 six 库:pip install six。
  1. [backcolor=transparent][[backcolor=transparent]root@iXXXXXX cloud[backcolor=transparent]-[backcolor=transparent]init[backcolor=transparent]]#[backcolor=transparent] python setup[backcolor=transparent].[backcolor=transparent]py install
  2. [backcolor=transparent]Traceback[backcolor=transparent] [backcolor=transparent]([backcolor=transparent]most recent call [backcolor=transparent]last[backcolor=transparent]):
  3. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"setup.py"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]127[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] [backcolor=transparent]<module>
  4. [backcolor=transparent] glob[backcolor=transparent]([backcolor=transparent]'systemd/*.target'[backcolor=transparent]))[backcolor=transparent] [backcolor=transparent]if[backcolor=transparent] is_f[backcolor=transparent]([backcolor=transparent]f[backcolor=transparent])],
  5. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"setup.py"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]114[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] render_tmpl
  6. [backcolor=transparent] tiny_p[backcolor=transparent]([[backcolor=transparent]sys[backcolor=transparent].[backcolor=transparent]executable[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]'./tools/render-cloudcfg'[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]template[backcolor=transparent],[backcolor=transparent] fpath[backcolor=transparent]])
  7. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"setup.py"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]45[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] tiny_p
  8. [backcolor=transparent] [backcolor=transparent]([backcolor=transparent]cmd[backcolor=transparent],[backcolor=transparent] ret[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]out[backcolor=transparent],[backcolor=transparent] err[backcolor=transparent]))
  9. [backcolor=transparent]RuntimeError[backcolor=transparent]:[backcolor=transparent] [backcolor=transparent]Failed[backcolor=transparent] running [backcolor=transparent][[backcolor=transparent]'/usr/bin/python'[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]'./tools/render-cloudcfg'[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]'systemd/cloud-config.service.tmpl'[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]'tmpXX25hU/cloud-config.service'[backcolor=transparent]][backcolor=transparent] [backcolor=transparent][[backcolor=transparent]rc[backcolor=transparent]=[backcolor=transparent]1[backcolor=transparent]][backcolor=transparent] [backcolor=transparent](,[backcolor=transparent] [backcolor=transparent]Traceback[backcolor=transparent] [backcolor=transparent]([backcolor=transparent]most recent call [backcolor=transparent]last[backcolor=transparent]):
  10. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"./tools/render-cloudcfg"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]10[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] [backcolor=transparent]<module>
  11. [backcolor=transparent] [backcolor=transparent]from[backcolor=transparent] cloudinit [backcolor=transparent]import[backcolor=transparent] templater
  12. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"/root/cloud-init/cloudinit/templater.py"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]29[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] [backcolor=transparent]<module>
  13. [backcolor=transparent] [backcolor=transparent]from[backcolor=transparent] cloudinit [backcolor=transparent]import[backcolor=transparent] log [backcolor=transparent]as[backcolor=transparent] logging
  14. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"/root/cloud-init/cloudinit/log.py"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]19[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] [backcolor=transparent]<module>
  15. [backcolor=transparent] [backcolor=transparent]import[backcolor=transparent] six
  16. [backcolor=transparent]ImportError[backcolor=transparent]:[backcolor=transparent] [backcolor=transparent]No[backcolor=transparent] [backcolor=transparent]module[backcolor=transparent] named six
  17. [backcolor=transparent])

安装过程中,如果出现以下信息,表示 Python 缺少 oauthlib 库。您可以使用 pip 安装 oauthlib 库:pip install oauthlib。
  1. [backcolor=transparent][[backcolor=transparent]root@iXXXXXX cloud[backcolor=transparent]-[backcolor=transparent]init[backcolor=transparent]]#[backcolor=transparent] python setup[backcolor=transparent].[backcolor=transparent]py install
  2. [backcolor=transparent]Traceback[backcolor=transparent] [backcolor=transparent]([backcolor=transparent]most recent call [backcolor=transparent]last[backcolor=transparent]):
  3. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"setup.py"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]127[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] [backcolor=transparent]<module>
  4. [backcolor=transparent] glob[backcolor=transparent]([backcolor=transparent]'systemd/*.target'[backcolor=transparent]))[backcolor=transparent] [backcolor=transparent]if[backcolor=transparent] is_f[backcolor=transparent]([backcolor=transparent]f[backcolor=transparent])],
  5. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"setup.py"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]114[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] render_tmpl
  6. [backcolor=transparent] tiny_p[backcolor=transparent]([[backcolor=transparent]sys[backcolor=transparent].[backcolor=transparent]executable[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]'./tools/render-cloudcfg'[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]template[backcolor=transparent],[backcolor=transparent] fpath[backcolor=transparent]])
  7. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"setup.py"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]45[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] tiny_p
  8. [backcolor=transparent] [backcolor=transparent]([backcolor=transparent]cmd[backcolor=transparent],[backcolor=transparent] ret[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]out[backcolor=transparent],[backcolor=transparent] err[backcolor=transparent]))
  9. [backcolor=transparent]RuntimeError[backcolor=transparent]:[backcolor=transparent] [backcolor=transparent]Failed[backcolor=transparent] running [backcolor=transparent][[backcolor=transparent]'/usr/bin/python'[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]'./tools/render-cloudcfg'[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]'systemd/cloud-config.service.tmpl'[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]'tmpUrhrOM/cloud-config.service'[backcolor=transparent]][backcolor=transparent] [backcolor=transparent][[backcolor=transparent]rc[backcolor=transparent]=[backcolor=transparent]1[backcolor=transparent]][backcolor=transparent] [backcolor=transparent](,[backcolor=transparent] [backcolor=transparent]Traceback[backcolor=transparent] [backcolor=transparent]([backcolor=transparent]most recent call [backcolor=transparent]last[backcolor=transparent]):
  10. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"./tools/render-cloudcfg"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]10[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] [backcolor=transparent]<module>
  11. [backcolor=transparent] [backcolor=transparent]from[backcolor=transparent] cloudinit [backcolor=transparent]import[backcolor=transparent] templater
  12. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"/root/cloud-init/cloudinit/templater.py"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]31[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] [backcolor=transparent]<module>
  13. [backcolor=transparent] [backcolor=transparent]from[backcolor=transparent] cloudinit [backcolor=transparent]import[backcolor=transparent] util
  14. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"/root/cloud-init/cloudinit/util.py"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]48[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] [backcolor=transparent]<module>
  15. [backcolor=transparent] [backcolor=transparent]from[backcolor=transparent] cloudinit [backcolor=transparent]import[backcolor=transparent] url_helper
  16. [backcolor=transparent]File[backcolor=transparent] [backcolor=transparent]"/root/cloud-init/cloudinit/url_helper.py"[backcolor=transparent],[backcolor=transparent] line [backcolor=transparent]20[backcolor=transparent],[backcolor=transparent] [backcolor=transparent]in[backcolor=transparent] [backcolor=transparent]<module>
  17. [backcolor=transparent] [backcolor=transparent]import[backcolor=transparent] oauthlib[backcolor=transparent].[backcolor=transparent]oauth1 [backcolor=transparent]as[backcolor=transparent] oauth1
  18. [backcolor=transparent]ImportError[backcolor=transparent]:[backcolor=transparent] [backcolor=transparent]No[backcolor=transparent] [backcolor=transparent]module[backcolor=transparent] named oauthlib[backcolor=transparent].[backcolor=transparent]oauth1
  19. [backcolor=transparent])

[backcolor=transparent]注意:不同系统缺少的库可能不同,您都可以通过 pip 安装,安装完之后再次执行 python setup.py install。

至此,您已经完成了 cloud-init 安装。
取消 提交回答
全部回答(0)
相关问答

162

回答

惊喜翻倍:免费ECS+免费环境配置~!(ECS免费体验6个月活动3月31日结束)

豆妹 2014-10-29 17:52:21 222996浏览量 回答数 162

145

回答

【新手入门】云服务器linux使用手册

fanyue88888 2012-11-26 17:14:18 157084浏览量 回答数 145

17

回答

阿里云开放端口权限

xcxx 2016-07-20 15:03:33 643124浏览量 回答数 17

38

回答

安全组详解,新手必看教程

我的中国 2017-11-30 15:23:46 256869浏览量 回答数 38

294

回答

Linux Bash严重漏洞修复紧急通知(已全部给出最终修复方案)

qilu 2014-09-25 13:26:50 431613浏览量 回答数 294

248

回答

【史上最详细】阿里云ECS安装wordpress教程

爱映疯wp 2014-03-09 23:55:43 251172浏览量 回答数 248

249

回答

阿里云LNAMP(Linux + Nginx + Apache + MySQL + PHP)环境一键安装脚本

云代维 2014-02-14 15:26:06 302602浏览量 回答数 249

40

回答

阿里云ecs从购买到环境搭建和建站!!(phpstudy一件包)

梦丫头 2014-07-29 20:51:49 162096浏览量 回答数 40

24

回答

【精品问答】python技术1000问(1)

问问小秘 2019-11-15 13:25:00 471406浏览量 回答数 24

13

回答

游戏云精彩帖汇总

nono20011908 2014-08-22 11:00:12 203639浏览量 回答数 13
+关注
boxti
12535
10037
文章
1327
问答
推荐问答
相关电子书
更多
文娱运维技术
立即下载
《SaaS模式云原生数据仓库应用场景实践》
立即下载
《看见新力量:二》电子书
立即下载