码迷,mamicode.com
首页 > 其他好文 > 详细

KVM_install and shell

时间:2014-08-15 13:00:39      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:kvm_install and shell

#!/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=)(.*)/\1disabled/‘ /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}:" a

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=`uuidgen`

        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\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" 


本文出自 “linux网络服务搭建” 博客,谢绝转载!

KVM_install and shell,布布扣,bubuko.com

KVM_install and shell

标签:kvm_install and shell

原文地址:http://8824130.blog.51cto.com/8814130/1540365

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!