KVM's support for OpenStack Linux system image production

Source: Internet
Author: User
Tags nameserver yum repolist

1.1 Creating a virtual machine
Qemu-img create-f qcow2/home/rhel7.0.qcow2 20G//create 20G dynamic disk
Root permission execution
Virt-install--os-variant List
rhel7:red Hat Enterprise Linux 7
Virt-install--connect=qemu:///system--name rhel7.0--ram 4096--vcpus 4--network network=default--disk path=/home/rhe L7.0.qcow2,format=qcow2,device=disk,bus=virtio,cache=writeback--cdrom/home/liutuan/iso/xxx.iso--vnc--os-type Linux--os-variant Rhel7
Domain installation still in progress. Can reconnect to
The console to complete the installation process. Connect to the operating system installation interface via virtual Machine Manager

1.2 Operating system Installation process
Graphical interface installation, new test login user,














1.3 Operating System Configuration
#selinux
Setenforce 0
Sed-i "S/selinux=enforcing/selinux=disabled/g"/etc/selinux/config
#iptables//Turn off the firewall
Systemctl Stop Iptables.service
Systemctl Disable Iptables.service

1.4 Qemu-guest-agent Installation and configuration
#需要外部安装源 @updates
Yum Install Qemu-guest-agent

echo "Nozeroconf=yes" >>/etc/sysconfig/network

1.5 Configuring virtual machines 163 Yum Source
1.5.1 Configuring Internet IP for virtual machines

NIC configuration for host and virtual machines:


1.5.2 Configuring the Yum Source
Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Modify the Eth0 profile: Leave four rows, delete various UUID
#网络IP
[email protected] network-scripts]# cat Ifcfg-eth0
Name=eth0
Type=ethernet
Onboot=yes
Bootproto=dhcp
Vim/etc/resolv.conf
#MAC
Nameserver 114.114.114.114
Restart Network
Ping baidu.com
Rm-f/etc/yum.repos.d/*
wget Http://mirrors.163.com/.help/CentOS7-Base-163.repo
Vim/etc/yum.repos.d/centos7-base-163.repo
:%s/$releasever/7/g
: X
Yum Clean All
Yum Makecache
Yum List

1.6 Cloud-init Installation and configuration
#调通互联网, don't forget to delete the network configuration at the end.
For RHEL-7
Yum Install Cloud-init
Yum Install Cloud-utils-growpart

Vim/etc/cloud/cloud.cfg
Users

    • Default

disable_root:0
ssh_pwauth:0

Locale_configfile:/etc/sysconfig/i18n
Mount_default_fields: [~, ~, ' auto ', ' defaults,nofail ', ' 0 ', ' 2 ']
Resize_rootfs_tmp:/dev
ssh_deletekeys:0
Ssh_genkeytypes: ~
Syslog_fix_perms: ~

Cloud_init_modules:

    • Migrator
    • Bootcmd
    • Write-files
    • Growpart
    • Resizefs
    • Set_hostname
    • Update_hostname
    • Update_etc_hosts
    • Rsyslog
    • Users-groups
    • Ssh

Cloud_config_modules:

    • Mounts
    • Locale
    • Set-passwords
    • Yum-add-repo
    • Package-update-upgrade-install
    • TimeZone
    • Puppet
    • Chef
    • Salt-minion
    • Mcollective
    • Disable-ec2-metadata
    • Runcmd

Cloud_final_modules:

    • Rightscale_userdata
    • Scripts-per-once
    • Scripts-per-boot
    • Scripts-per-instance
    • Scripts-user
    • Ssh-authkey-fingerprints
    • Keys-to-console
    • Phone-home
    • Final-message

System_info:
Default_user:
Name:centos
Lock_passwd:true
Gecos:cloud User
Groups: [Wheel, ADM]
sudo: ["all= (All) Nopasswd:all"]
Shell:/bin/bash
Distro:rhel
Paths
Cloud_dir:/var/lib/cloud
Templates_dir:/etc/cloud/templates
Ssh_svcname:sshd
datasource_list: [‘OpenStack‘,‘ConfigDrive‘]
_# Vim:syntax=yaml
If there is a defaults.cfg in/etc/cloud/cloud.cfg.d/, delete it.

#修改cloud-init configuration file:
Vim/etc/default/grub
#删除GRUB_CMDLINE_LINUX = ... The RHGB quiet configuration item in this row, add Console=tty0 console=ttys0,115200n8
#使修改后的grub配置文件生效
Grub2-mkconfig–o/boot/grub2/grub.cfg
3.7 Sexual configuration and cleanup of redundant settings
Personalized configuration: Slightly
To clean up excess settings:
For example: DNS configuration, disk segmentation, change password, etc.
Vim/etc/resolv.conf
#MAC
Nameserver 114.114.114.114

#root密码
PASSWD Root
Password

#管理开关虚拟机服务 (optional)
Yum Install Acpid
Yum Enable Acpid

#配置硬盘重新分区 (optional)
Yum Install Cloud-utils-growpart

#配置本地YUM源, note whether you need to keep the local ISO source
Mount the local ISO image in a host environment
Virsh Destroy rhel7.0
Virsh Start rhel7.0
Virsh attach-disk--type cdrom--mode readonly rhel7.0 "/home/liutuan/iso/xx7.0.iso" hdc

Virsh dumpxml rhel7.0 > Rhel7.0.xml//Convenient Virsh Create *.xml
#进入虚拟机操作系统
#挂载本地iso

Mkdir-p/mnt/cdrom/mnt/iso
Mount/dev/cdrom/mnt/iso//If there is an error, you need to Attach-disk
Cp–frv/mnt/iso/mnt/cdrom
Rm–rf/mnt/iso
Ls/mnt/cdrom

#配置本地yum源
cd/etc/yum.repos.d/
MV Centos7-base-163.repo Centos7-base-163.repo.bak
Cat >/etc/yum.repos.d/local.repo <<eof
[Local]
Name=local
Baseurl=file:///mnt/cdrom
Gpgcheck=0
Enabled=1
Eof

Kill–s 9 XX (process number)
Yum Clean All
Yum Makecache
Yum Repolist

#关机
Shutdown

1.8 Unbind
#安装工具软件
Yum Install-y libguestfs-tools-c
Ubuntu host sudo apt-get install Libguestfs-tools
Use VM Name
Virt-sysprep-d rhel7.0
Virsh undefine rhel7.0
#镜像制作完毕
md5sum rhel7.0.qcow2 > Rrhel7.0.qcow2.md5sum
Cat Rhel7.0.qcow2.md5sum
781ecc51dde344ffba0e04a7574e6190 Rhel7.0.qcow2

1.9 Image Upload

    1. SCP Rhel7.0.qcow2 controller:/home///can also be uploaded to the control node via the FTP tool
    2. SSH controller upload image img To control node image compression
      Qemu-img convert-f qcow2–o Raw Rhel7.0.qcow2 Rhel7.0.raw
      1.9.1 Upload to glance

SOURCE OPENRC
Glance image-create--property os_type=linux--name "rhel7.0"--is-public true--disk-format raw--container-format bare --file/home/rhel7.0.raw

KVM's support for OpenStack Linux system image production

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.