Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make OpenStack Linux Image

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces you how to make OpenStack Linux image, the content is very detailed, interested friends can use for reference, I hope it can be helpful to you.

OpenStack's instance is deployed through the Glance image, so preparing the image is a must. The following describes how to make a Linux image, as well as a discussion of Windows image.

Download clould image

The easiest way is to use a standard image. Mainstream Linux distributions provide cloud images that can be used directly in OpenStack at the download address:

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/

Let's take Ubuntu16.04 as an example to demonstrate how to import a standard image into Glance.

Create a Glance image

Log in to OpenStack and open the Project-> Compute- > Mirror menu.

Click the create Mirror button.

Enter image-related information on the creation page, including:

The image name is "Ubuntu 16.04"

"Mirror Source" Select "Image File"

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

"Image format" Select "QCOW2"

Fill in "20" for the minimum disk, which is equivalent to setting the minimum capacity of the instance boot disk

Check the "Common" selection box so that all Project can use the image

Click the "create Image" button to start uploading the image. When complete, the new mirror appears on the list of mirrors.

Custom image

The cloud image is a standard mirror, has no image interface, is in the US time zone, and can only be logged in with a key. You can customize the image as needed by:

Deploy an instance through the cloud image.

Customize the instance.

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

Deploy the new instance later through this snapshot.

Let's take the CentOS standard image as an example to demonstrate each step of customizing the image, including adding a graphical interface, setting China time zone, setting ssh password login, and so on.

1. Deploy an instance through a cloud image

Go to the "Project-> Compute- > Image" menu, and click the "start the CVM" button after the image "CentOS6".

Name it "centos6-vm".

Because the cloud image is accessed by default through the key pair, click the "access & Security" tab and select the pre-created key pair "template".

Click "run" and centos6-vm is deployed successfully.

Manage key pairs in the Project-> Compute- > access & Security menu. This is where "template" was created. Existing key pairs are also supported.

Download and keep the private key file template.pem when you create the key, and log in to centos6-vm through this file.

Ssh-I / template.pem centos@172.17.24.97

Then switch to the root user:

Sudo su-

two。 Customize the instance

Set China time zone

Cp / usr/share/zoneinfo/Asia/Shanghai / etc/localtime

Set up the yum source

To install graphics and other related packages, the yum source needs to be prepared in advance (of course, you can also use the source on the official website). Then edit / etc/yum.repos.d/CentOS-Base.repo

If it is CentOS7, the content is as follows:

Install development tools and graphical interfaces

CentOS6 installs the following packages:

Yum groupinstall "Desktop"

Yum groupinstall "X Window System"

Yum groupinstall "Development tools"

CentOS7 installs the following packages:

Yum groupinstall "Server with GUI"

Yum groupinstall "GNOME Desktop"

Yum groupinstall "Development Tools"

Set the system to start the graphical interface by default

CentOS6, editor / etc/inittab

CentOS7, execute systemctl set-default graphical.target

Set root password

Set the root password to "passw0rd" by default

Allow root to log in via password ssh

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

Restart the ssh service

Service sshd restart

Modify / etc/cloud/cloud.cfg

Cloud image initializes instance with cloudinit, such as configuring network, extend system disk, etc. All configurations of cloudinit are written in / etc/cloud/cloud.cfg. The following configuration will allow root to log in through password ssh.

At this point, centos6-vm is ready to launch the graphical interface and log in via ssh with a password.

Install cloud-utils-growpart (CentOS 6 only)

Cloudint will use this software to manage disk partitions, because it is not installed in CentOS6 cloud image, so it needs to be installed manually. Download address: 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

3. Create a new mirror

We finished the customization in instance, and then took a snapshot of instance to generate a new mirror. Click the "create snapshot" button after "centos6-vm".

Name the snapshot.

Click create Snapshot.

4. Deploy a new instance

Click "start CVM" to deploy the new instance through the snapshot.

Click "run" and the instance is deployed successfully.

As you can see, the instance has a graphical interface started, and root can be logged in with a ssh password.

Convert snapshot to image (optional)

There are two types of Glance images: image and snapshot. The type of image created by snapping instance is snapshot, which may be inconvenient sometimes, so you can convert snapshot to image.

Taking CentOS 6.7n as an example, you can directly glance image-create it by converting it to an image type. The steps are as follows:

1. Record the ID in its details as: 228f7bdc-fcf1-4f6a-8a7a-298b86f9e94b

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

3. Execute glance image-create to 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

4. The newly created mirror type is image.

These are the general operations of customizing OpenStack Linux images.

On how to create an OpenStack Linux image to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report