最近更新时间:2019-10-30 19:54:37
使用自定义镜像时,为保证运行该镜像的实例能成功完成初始化配置,建议用户在服务器上安装cloud-init服务。
目前仅Linux云服务器支持安装cloud-init服务。
root
用户。对于Ubuntu系统,需要换至root
帐号。rpm -e cloud-init
rm -rf /etc/conf/cloud/*
rm -rf /var/lib/cloud/*
apt-get purge cloud-init
rm /usr/bin/cloud-init*
检查镜像环境的Python解释器版本,如果为Python2.6及以下版本,需要安装下列依赖组件:
pip install 'requests<2.20.0'
命令安装requests 2.20.0版本以下的版本。pip install 'jsonschema<=2.5.1'
命令安装jsonschema 2.5.1版本以下的版本。pip install setuptools==36.7.0
命令安装setuptools 37版本以下的版本。tar -zxvf cloud-init-18.3.tar.gz
cloud-init-18.3
。
cd cloud-init-18.3
安装 python-pip。
apt-get/yum install python-pip -y
pip install -r requirements.txt
安装 cryptography。
pip install cryptography # Python 2.7 执行此命令
pip install 'cryptography<=1.3.1' # Python 2.6 执行此命令
python setup.py build
python setup.py install --init-system systemd # systemd 自启动管理服务,执行此命令
python setup.py install --init-system sysvinit # sysvinit 自启动管理服务,执行此命令
python setup.py install --init-system upstart # upstart 自启动管理服务(ubuntu 14使用),执行此命令.
如果操作系统使用 sysvinit 自启动管理服务,使用以下命令:
chkconfig --add cloud-init-local
chkconfig --add cloud-init
chkconfig --add cloud-config
chkconfig --add cloud-final
chkconfig cloud-init-local on
chkconfig cloud-init on
chkconfig cloud-config on
chkconfig cloud-final on
如果操作系统使用 systemd 自启动管理服务,具体操作步骤如下所示。
ln -s /usr/local/bin/cloud-init* /usr/bin/
systemctl enable cloud-init-local.service
systemctl start cloud-init-local.service
systemctl enable cloud-init.service
systemctl start cloud-init.service
systemctl enable cloud-config.service
systemctl start cloud-config.service
systemctl enable cloud-final.service
systemctl start cloud-final.service
systemctl status cloud-init-local.service
systemctl status cloud-init.service
systemctl status cloud-config.service
systemctl status cloud-final.service
ln -s /usr/lib/systemd/system/cloud-config.target /usr/lib/systemd/system/multi-user.target.wants/cloud-config.target
ln -s /lib/systemd/system/cloud-config.target /lib/systemd/system/multi-user.target.wants/cloud-config.target
如果操作系统使用 upstart 自启动管理服务,对于Ubuntu和Debian操作系统,使用以下命令:
ln -s /usr/local/bin/cloud-init* /usr/bin/