#! /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!