Make an OpenStack Linux image-5 minutes a day to play with OpenStack (151)

Source: Internet
Author: User

This is the 1th chapter in the OpenStack implementation experience sharing series.


The instance of OpenStack is deployed through a Glance mirror, so preparing the mirror is a must-do job. This section describes how to make a Linux image, and also discusses Windows mirroring later.

Download Clould image

The simplest approach is to use a standard image. The mainstream Linux distribution provides a cloud image that can be used directly in OpenStack:

centos6:http://cloud.centos.org/centos/6/images/


centos7:http://cloud.centos.org/centos/7/images/


ubuntu14.04:http://cloud-images.ubuntu.com/trusty/current/


ubuntu16.04:http://cloud-images.ubuntu.com/xenial/current/


The following example shows how to import a standard image into a Glance Ubuntu16.04.

Create a Glance image

Login to OpenStack to open the project->compute-> mirroring menu.


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051701351090683.png "/>


Click on the "Create Mirror" button.

650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051701442091140.png "/>

Fill in the image-related information on the Create page, which includes:


    1. The image name is "Ubuntu 16.04"


    2. "Mirror Source" select "Image File"


    3. Click "Select File" to locate the Ubuntu 16.04 Cloud image file Xenial-server-cloudimg-amd64-disk1.img


    4. "Image format" select "QCOW2"


    5. Minimum disk Fill "20", which is equivalent to setting the minimum capacity of the instance boot disk


    6. Tick the "common" selection box so that all project can use the image


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051701548059400.png "/>

Click on the "Create Image" button to start uploading the image. When finished, the new image will appear on the mirror list.


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051701643004269.png "/>

Custom Mirroring

Cloud mirroring is a standard image, no image interface, is a U.S. time zone, and can only be logged on with a key. You can customize the image as needed by:


    1. Deploy an instance from a cloud image.


    2. Customize the instance.


    3. Create a snapshot of the instance, which will be saved in glance.


    4. The new instance is later deployed through the snapshot.


Below we take the CentOS standard image as an example to demonstrate each step of the custom image, custom content includes: Add graphical interface, set up China time zone, set SSH password login and so on.

1. Deploy an instance from the cloud image

Go to the "Project->compute-> Mirroring" menu and click on the "Start Cloud Host" button after Mirroring "CentOS6".


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051701748021948.jpg "/>


Named "CENTOS6-VM".


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051701845004651.png "/>


Because the cloud image is accessed by default via a key pair, click on the "Access & Security" tab and select the pre-created key pair "template".


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051701934093158.png "/>


Click "Run" and the CENTOS6-VM deployment is successful.


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051702012032949.png "/>


Manage key pairs in the project->compute-> Access & Security menu. The "template" is created here. Existing key pairs are also supported.


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051702155031276.png "/>


Download and keep the private key file Template.pem when you create the key, and log in to CENTOS6-VM with this file.


ssh-i <key-path>/template.pem [email protected]


Then switch to the root user:

sudo su–


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051702263024411.png "/>

2. Customizing the Instance

Set China time zone

Cp/usr/share/zoneinfo/asia/shanghai/etc/localtime


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051702349073458.png "/>


Set Yum source


Because you want to install the graphics and other related packages, Yum Source should be prepared in advance (of course, can also use the source of official website). Then edit/etc/yum.repos.d/centos-base.repo


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051702448048634.png "/>


If it is CentOS7, the contents are as follows:


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051702560029547.png "/>


Installing development tools and graphical interfaces


CentOS6 Install the following packages:

Yum Groupinstall "Desktop"

Yum groupinstall "X window System"

Yum Groupinstall "Development tools"


CentOS7 Install the following packages:

Yum Groupinstall "Server with GUI"

Yum Groupinstall "GNOME Desktop"

Yum Groupinstall "Development Tools"


Set the system default startup graphical interface


CentOS6, editor/etc/inittab,


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051702645043560.png "/>


CentOS7, performing Systemctl Set-default graphical.target


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051702742051766.png "/>


Set Root password


Setting the root password defaults to "Passw0rd"


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051702826049348.png "/>


Allow Root to ssh in via password


Edit the/etc/ssh/sshd_config to make the following changes.


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051702895059059.png "/>

650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051702986080965.png "/>


Restart the SSH service


Service sshd Restart


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051703095093797.png "/>


Modify/etc/cloud/cloud.cfg

Cloud image is initialized with Cloudinit instance, such as configuring the network, extend system disk, Cloudinit all the configuration is written in/etc/cloud/cloud.cfg, the following configuration will allow Root Login via password ssh.


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051703186041741.png "/>


At this point, CENTOS6-VM can already start the graphical interface and can log in with a password via SSH.


Install Cloud-utils-growpart (CentOS 6 only)


Cloudint will use this software to manage the disk partition because CentOS6 cloud image is not installed, so it needs to be installed manually. : https://pkgs.org/centos-6/epel-x86_64/cloud-utils-growpart-0.27-10.el6.x86_64.rpm/download/

RPM-UVH cloud-utils-growpart-0.27-10.el6.x86_64.rpm


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051703285051204.png "/>

3. Create a new image

We completed the custom work in instance and then took a snapshot of the instance, creating a new image. Click the "Create snapshot" button after "CENTOS6-VM".


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051703356004037.png "/>


Name the snapshot.

650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051703500003635.png "/>

Click "Create snapshot".


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051703612014147.png "/>

4. Deploy a new instance

Click "Start Cloud Host" to deploy the new instance through the snapshot.


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051703735085531.png "/>

Click "Run" to successfully deploy the instance.


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051703879035154.png "/>


As you can see, the instance has started the graphical interface, and root can log in with an SSH password.


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051703960012341.jpg "/>


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051704059013039.png "/>

Convert snapshot to image (optional)

There are two types of glance images: Image and snapshot, which are snapshot in front of the image created by a snapshot of instance, and can sometimes be inconvenient to convert snapshot to image.


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051704139087108.png "/>


In the case of CentOS 6.7n, you can directly glance the image-create command by converting it to an image type. The steps are as follows:


1. In its details, record the ID: 228f7bdc-fcf1-4f6a-8a7a-298b86f9e94b


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051704230049849.png "/>


2. The image is stored by default on the control node/var/lib/glance/images/228f7bdc-fcf1-4f6a-8a7a-298b86f9e94b.


3. Execute glance image-create create a new mirror.

glance image-create--name "CentOS 6.7"--file 228f7bdc-fcf1-4f6a-8a7a-298b86f9e94b--disk-format Qcow2-- Container-format bare--is-public true--progress


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051704308043815.png "/>


4. The newly created image type is image.


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051704382020398.png "/>


These are the usual operations for customizing OpenStack Linux images, and we'll discuss how to make Windows mirroring in the next section.


650) this.width=650; "Src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170214-1487051704478027218.jpg "/>

Make an OpenStack Linux image-5 minutes a day to play with OpenStack (151)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.