Home > Article > Operation and Maintenance > In order to ensure that the image source configuration is successful when importing Linux type images, cloud-init should be installed.
The content of this article is about installing cloud-init to ensure that the image source configuration is successful when importing Linux type images. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. helped.
Install cloud-init
If you need to use an existing image to create an ECS instance, you can complete the configuration through the import image function. When importing a Linux type image, in order to ensure that the imported image hostname, NTP, and Yum source are configured successfully, it is recommended that you install cloud-init on the source server, virtual machine, or cloud host in advance.
Note
Currently, Linux distributions that support the installation of cloud-init include CentOS, Debian, Fedora, FreeBSD, Gentoo, RHEL ( Red Hat Enterprise Linux), SLES (SUSE Linux Enterprise Server) and Ubuntu.
If your source server, virtual machine or cloud host has cloud-init installed, you need to confirm that the cloud-init version number is higher than 0.7.9. Images containing lower versions of cloud-init will cause related instances Configuration failed, such as NTP, HostName, Yum, etc.
Log in to the source server, virtual machine or cloud host.
Run cloud-init --version to query the cloud-init version.
If your cloud-init version number is higher than 0.7.9, it means that this version is available. Otherwise you need to install cloud-init.
Prerequisites
Before installing cloud-init, your source server, virtual machine or cloud host must have the following software installed.
git: Download cloud-init source code package
yum installation method: yum install git
Python2.7: The basis for cloud-init operation and installation
yum installation method: yum install python
pip: Install the Python library that cloud-init depends on
yum installation method: yum install python-pip
yum is listed here Installation method. The installation method of the package manager of zypper or apt-get is similar to the installation method of yum.
Install cloud-init
You can follow the following steps to install cloud-init:
Log in to the source of the image to be imported Server, virtual machine or cloud host.
Run git clone https://git.launchpad.net/cloud-init and download the cloud-init source code package from the cloud-init official website.
Run cd cloud-init to enter the cloud-init directory.
Run python setup.py install to install the cloud-init installation file setup.py.
Run vi /etc/cloud/cloud.cfg to modify the configuration file cloud.cfg.
Modify the previous configuration of cloud_init_modules as follows:
# Example datasource config # The top level settings are used as module # and system configuration. # A set of users which may be applied and/or used by various modules # when a 'default' entry is found it will reference the 'default_user' # from the distro configuration specified below users: - default user: name: root lock_passwd: False # If this is set, 'root' will not be able to ssh in and they # will get a message to login instead as the above $user disable_root: false # This will cause the set+update hostname module to not operate (if true) preserve_hostname: false syslog_fix_perms: root:root datasource_list: [ AliYun ] # Example datasource config datasource: AliYun: support_xen: false timeout: 5 # (defaults to 50 seconds) max_wait: 60 # (defaults to 120 seconds) # metadata_urls: [ 'blah.com' ] # The modules that run in the 'init' stage cloud_init_modules:
Troubleshooting
Different images may lack different libraries. You can install them through pip. After installation, repeat the above step 4 again.
The six and oauthlib libraries are missing
During the installation process, if the following message appears, it means that Python is missing the six library. You can install the six library using pip: pip install six.
File "/root/cloud-init/cloudinit/log.py", line 19, in <module> import six ImportError: No module named s )
During the installation process, if the following message appears, it means that Python is missing the oauthlib library. You can install the oauthlib library using pip: pip install oauthlib.
File "/root/cloud-init/cloudinit/url_helper.py", line 20, in <module> import oauthlib.oauth1 as oauth1 ImportError: No module named oauthlib.oaut )
There is no clear missing dependent library when the error is prompted
If the installation error is reported and there is no clear prompt about which dependent libraries are missing, you can follow the requirements displayed in the requirements.txt file of cloud-init library, and run pip install -r requirements.txt to install all dependent libraries.
Next steps
You can import a custom image.
The above is the detailed content of In order to ensure that the image source configuration is successful when importing Linux type images, cloud-init should be installed.. For more information, please follow other related articles on the PHP Chinese website!