您的位置:首页 > 运维架构 > Linux

centos6下KVM安装支持kickstart

2014-03-04 11:13 316 查看

准备

CPU支持kvm

安装CentOS6.4

关闭Selinux

关闭iptables或者打开相应的端口,vnc需要用到

源,需要用到epel源

在Centos下检查cpu是否支持VT,没Ubuntu那么方便,输入下面命令,有内容输出,就表示支持,没任何显示,表明不支持。
egrep '(vmx|svm)' –color=always /proc/cpuinfo
查看Selinux状态
# sestatus
SELinux status: disabled

KVM

yum install kvm libvirt python-virtinst qemu-kvm virt-viewer  kmod-kvm qemu kvm-qemu-img virt-viewer virt-manager  libvirt-python dejavu-lgc-sans-fonts
启动libvirt服务service messagebus start
service haldaemon start
service libvirtd start
chkconfig messagebus on
chkconfig haldaemon on
chkconfig libvirtd on
查看kvm服务是否正常,目前没任何虚拟机,所以没有内容显示
virsh -c qemu:///system list

Bridge

我们需要对网卡进行设置一下 创建一个文件 /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE="br0"
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=static
IPADDR=192.168.200.100
NETMASK=255.255.255.0
修改 /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
BRIDGE=br0
重启网络服务
/etc/init.d/network restart
查看桥接网络
# brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.00e081de016c       no              eth0
virbr0          8000.5254009219a2       yes             virbr0-nic


VNC

yum install tigervnc tigervnc-server
设置编辑 /etc/sysconfig/vncservers 增加一行
VNCSERVERS="1:root"
创建一个20G qcow2格式的磁盘文件,虚拟机的image放在 /home/kvm 目录下
qemu-img create -f qcow2 -o preallocation=metadata /a8root/VM/ilove_vm01.qcow2 500G
创建虚拟机
virt-install --name ilove01-kvm01 --ram=32768 --vcpus=8 --os-type=linux --os-variant=rhel6 --network bridge:br0  --network bridge:br1  --disk path=/a8root/VM/ilove_vm01.qcow2  --location http://192.168.200.240/centos6.5/ --extra-args "ks=http://192.168.200.240:88/ks_vm_centos6_10.cfg ksdevice=eth1  ip=192.168.200.72  netmask=255.255.240.0 gateway=192.168.200.2 " --graphics vnc,listen=192.168.200.70,port=5901  --force  --autostart


然后用vnc 客户端连接就可以看到安装界
添加硬盘
virsh  edit  supdj-kvm01
<disk type='block' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source dev='/dev/mapper/a8data-vm_disk1'/>
<target dev='vdb' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</disk>


#virsh edit supdj-kvm01

<graphics type='vnc' port='5901' autoport='no' listen='192.168.10.150' keymap='en-us'/>

在其中加入passwd的属性,更改为如下:
<graphics type='vnc' port='5901' autoport='no' listen='192.168.10.150' passwd='12345678' keymap='en-us'/>
其中passwd的位置可以随意.

.更改完成之后,保存退出vim.命令行中会提示修改成功,就ok了.如果不成功,就要检查编加的时候,是不是写错什么了.下次重启生效
好了,这样就ok了

在线添加这台qcow2虚拟磁盘# virsh attach-disk ilove_vm01 /a8root/VM/ilove_vm01_add01.qcow2 vdb --cache=none --subdriver=qcow2

本文出自 “一阵风” 博客,请务必保留此出处http://chenwenming.blog.51cto.com/327092/1367416
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: