Kvm_install and Shell

Source: Internet
Author: User

#! /Bin/bash

/Etc/init. d/NetworkManager stop

Chkconfig NetworkManager off

Service iptables stop

Chkconfig iptables off

Setenforce 0

Lang = en. UF-8

Yum-y groupinstall "virtualization" "virtualization client" "virtualization platform" "virtualization Tools"

Sed-r's/(SELinux =) (. *)/\ 1 disabled/'/etc/SELinux/config



# Cd/var/lib/libvirt/images/

# Qemu-IMG create-F qcow2 server6.img 20g // install first server name Si server6.4 size 20g


# Qemu-IMG create-B/var/lib/libvirt/images/server6.img-F qcow2 rhel6basenode1. img

Mimic server name is rhel6basenode1. img



Shell:

#! /Bin/bash

Lang = C


Read-P "plese Enter start a number {01-99}:"

Read-P "plese enter end a number {01-99}:" B


Vers = centos_server6.img

Name = centos_server6

Soufile =/var/lib/libvirt/images/$ vers

Dump =/var/lib/libvirt/WGL. xml

Error =/var/lib/libvirt/images/error. Log


For (num = $ A; $ num <= $ B; num ++ ))

Do

UUID = 'uidgen'

Rm-RF/var/lib/libvirt/WGL. xml

KL =/var/lib/libvirt/images/centos6 _ $ {num}. img

Qemu-IMG create-B $ soufile-F qcow2 $ Kl &>/dev/null

/Usr/bin/virsh dumpxml $ Name> $ dump 2>/$ error> & 1

Sed-I "s/$ name/centos6 _ $ {num}/" $ dump

Sed-I "/<UUID>/S/<UUID>. * <\/UUID>/<UUID >$ {UUID} <\/UUID>/" $ dump

Sed-I "/source file/S/<source file = '. * '\/>/<source file =' \/var \/Lib \/libvirt \/images \/centos6 _ $ {num }. IMG '\/>/"$ dump

If ["$ num"-lt 10]; then

Sed-I "/MAC address/S/f/$ {num}/" $ dump

Else

Sed-I "/MAC address/S/EF/$ {num}/" $ dump

Fi

Virsh define $ dump &>/dev/null

Echo-e "$ centos _ $ {num} \ t [OK]"

Done

Network:

# Cat ifcfg-eth0

Device = "eth0"

Nm_controlled = "no"

Onboot = "yes"

Bridge = "public"

Type = "Ethernet"

Bootproto = "None


# Cat ifcfg-Public

Device = "public"

Nm_controlled = "yes"

Onboot = "yes"

Type = "bridge"

Bootproto = static

Ipaddr = 192.168.3.56

Netmask = 255.255.252.0

Dns1 = 192.168.1.6

Dns2 = 192.168.1.7

Delay = "0"


This article is from the "Linux Network Service Building" blog!

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.