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 Mirror template based on KVM

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

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to make an Openstack image template based on KVM. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

1. Environmental preparation

ResultsISO preparation

According to the Openstack image you need, download the ISO file you need. Here take the installation and production of CentOS7.2 as an example.

Iso file ready: CentOS-7-x86_64-Minimal-1511.iso

Host preparation

²check whether the cpu of the host supports KVM

Grep-E-o'(vmx | svm)'--color=auto / proc/cpuinfo

Vmx indicates that CPU supports Intel VT technology, while svm represents CPU to support AMD-v technology.

²install libvirt Virtualization Management tools

# yum-y install virt-manager virt-viewer libvirt libvirt-python python-virtinst virt-install

# service libvirtd start

# chkconfig libvirtd on

Host (it is recommended to directly use the physical machine that has installed and deployed Openstack computing nodes. Take 172.16.70.1 as an example) the environment installs centos7.2 operating system and has installed tools such as virt-install, kvm, qemu-img, etc. Upload CentOS-7-x86_64-Minimal-1511.iso to directory / usr/local/src

two。 Mirror image production

Create a virtual machine disk image

Execute the command on the host machine to create a virtual machine disk file

# qemu-img create-f qcow2 / tmp/CentOS-7.20-x86_64.qcow2 40G

Start the virtual machine from ISO

Virt-install-virt-type kvm-name CentOS-7.20-x86_64\

-ram 2048-disk / tmp/CentOS-7.20-x86_64.qcow2,format=qcow2\

-- graphics vnc,listen=0.0.0.0-- noautoconsole\

-- os-type=linux-- os-variant=rhel7\

-- network bridge=br71\

-- cdrom=/usr/local/src/CentOS-7-x86_64-Minimal-1511.iso

Example host * *. * * already has a bridge bridge br71. If you do not use a bridge, the standard red can be replaced by the following line

-- network network=default\

Installation of the virtual machine operating system

Use the tightVNC client tool to connect to the virtual machine. After the connection is completed, under normal circumstances, you will be able to open the installation interface of the virtual machine and complete the installation of the virtual machine operating system according to the normal installation method of the operating system. The installation process is omitted. Note that you can use the default LVM when partitioning the disk, or you can customize the partition structure. The recommendation for virtual machines is to assign only one root partition /, and no other assignments and swap partitions are created. After the installation is successful, click reboot, and note that it will not be restarted. We need to start it manually:

After booting, we connect to the virtual machine.

Use the tightVNC client to connect to the virtual machine. The IP address is the public network address of the host where the virtual machine resides, and the port is the port that the virtual machine listens on. The port number can be queried using the following command:

# netstat-anoplt | grep-I `ps-ef | grep-v grep | grep CentOS-7.20-x86_64 | awk'{print $2}'`

Configure the virtual machine network so that the virtual machine can access a specific yum source.

Install the ACPI service

After startup, you may need to manually configure the network of your virtual machine. In order for the virtualization layer to restart and shut down the virtual machine, the acpid service must be installed and running within the virtual machine.

Run the following command within the CentOS virtual machine to install the ACPI service and configure it to start automatically when the system starts.

# yum install acpid

# systemctl enable acpid

Clear MAC address related information

The operating system will be available in / etc/sysconfig/network-scripts/ifcfg-eth0 and

Files such as / etc/udev/rules.d/70-persistent-net.rules record the MAC address of the network card, but the MAC address of the network card of the virtual machine is different each time the virtual machine is created, so this information must be removed from the configuration file.

Other standardized operations

All the settings that need to be made by all virtual machines can be set up at the mirror level. For example, close SElinux, firewalld, and postfix. And set up the intranet DNS, install the related Agent and so on.

The work of finishing up

Shut down the virtual machine. If you no longer need the virtual machine in the future, you can also delete it directly. It is recommended to keep it to facilitate the customization of virtual machine images later.

It is recommended to install the tool

Gcc tcpdump lsof parted snmpwalk perl wget createrepo perl-ExtUtils-MakeMaker setuptool bzip2 gzip unzip zip net-snmp python-setuptools python-devel

3. Upload image to Openstack Glance service

Uploading image

Copy the image to the control node of Openstack and execute the following command:

Glance image-create-name "CentOS-7.2-x86_64"-disk-format qcow2-min-disk 40-container-format bare-file / tmp/CentOS-7-x86_64.qcow2-progress

This is the end of this article on "how to make an Openstack image template based on KVM". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please 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