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

Centos 6.5安装配置KVM

时间:2017-12-22 00:41:21      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:centos 6.5安装kvm   kvm部署   

1  egrep --color=auto 'vmx|svm' /proc/cpuinfo


2  yum install kvm qemu-kvm python-virtinst libvirt libvirt-python virt-manager libguestfs-tools virt-viewer


3  modprobe -a kvm kvm_intel  (BIOS里面先开启虚拟化)


4  yum -y  upgrade device-mapper-libs


5  service libvirtd start


6  chkconfig libvirtd on


7  新建虚拟机,磁盘方面设置:

然后进入桌面使用图形化操作,新建虚拟机的时候。

存储:配置存储的时候选择大的分区(编辑---链接详细---存储---添加池---新建卷---选择qcow2格式,只有这个格式才能做快照),默认是选择根分区的存储池的。

设置存储池参考:http://www.3566t.com/news/nosb/1493020.html   http://xiangcun168.blog.51cto.com/4788340/1680498


8  网络方面设置

网络:默认是NAT模式,物理机会有一个virbr0网卡192.168.122.1,虚拟机也是这个网段的192.168.122.133。

需要给虚拟机配置NAT上网。

需要给虚拟机配置iptables端口转发。

物理机防火墙配置文件如下:

# Generated by iptables-save v1.4.7 on Thu Mar 23 18:07:55 2017

*filter

:INPUT ACCEPT [1224:109875]

:FORWARD ACCEPT [1125:176375]

:OUTPUT ACCEPT [415:56424]

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8732 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 465 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 993 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 995 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 99 -j ACCEPT

COMMIT

# Completed on Thu Mar 23 18:07:55 2017

# Generated by iptables-save v1.4.7 on Thu Mar 23 18:07:55 2017

*mangle

:PREROUTING ACCEPT [3600:428906]

:INPUT ACCEPT [1376:127143]

:FORWARD ACCEPT [1448:225520]

:OUTPUT ACCEPT [463:60779]

:POSTROUTING ACCEPT [1902:285843]

-A POSTROUTING -o virbr0 -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill

COMMIT

# Completed on Thu Mar 23 18:07:55 2017

# Generated by iptables-save v1.4.7 on Thu Mar 23 18:07:55 2017

*nat

:PREROUTING ACCEPT [1239:116781]

:POSTROUTING ACCEPT [6:484]

:OUTPUT ACCEPT [6:484]

-A PREROUTING -d 192.168.1.107/32 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.122.133:80

-A POSTROUTING -o eth0 -j MASQUERADE

-A PREROUTING -d 192.168.1.107/32 -p tcp -m tcp --dport 8732 -j DNAT --to-destination 192.168.122.133:8732

-A POSTROUTING -o eth0 -j MASQUERADE

-A PREROUTING -d 192.168.1.107/32 -p tcp -m tcp --dport 25 -j DNAT --to-destination 192.168.122.133:25

-A POSTROUTING -o eth0 -j MASQUERADE

-A PREROUTING -d 192.168.1.107/32 -p tcp -m tcp --dport 110 -j DNAT --to-destination 192.168.122.133:110

-A POSTROUTING -o eth0 -j MASQUERADE

-A PREROUTING -d 192.168.1.107/32 -p tcp -m tcp --dport 143 -j DNAT --to-destination 192.168.122.133:143

-A POSTROUTING -o eth0 -j MASQUERADE

-A PREROUTING -d 192.168.1.107/32 -p tcp -m tcp --dport 443 -j DNAT --to-destination 192.168.122.133:443

-A POSTROUTING -o eth0 -j MASQUERADE

-A PREROUTING -d 192.168.1.107/32 -p tcp -m tcp --dport 465 -j DNAT --to-destination 192.168.122.133:465

-A POSTROUTING -o eth0 -j MASQUERADE

-A PREROUTING -d 192.168.1.107/32 -p tcp -m tcp --dport 993 -j DNAT --to-destination 192.168.122.133:993

-A POSTROUTING -o eth0 -j MASQUERADE

-A PREROUTING -d 192.168.1.107/32 -p tcp -m tcp --dport 995 -j DNAT --to-destination 192.168.122.133:995

-A POSTROUTING -o eth0 -j MASQUERADE

-A PREROUTING -d 192.168.1.107/32 -p tcp -m tcp --dport 99 -j DNAT --to-destination 192.168.122.133:99

-A POSTROUTING -o eth0 -j MASQUERADE

-A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p tcp -j MASQUERADE --to-ports 1024-65535

-A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p udp -j MASQUERADE --to-ports 1024-65535

-A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -j MASQUERADE

-A POSTROUTING -s 192.168.122.0/24 -d 192.168.122.133/32 -p tcp -m tcp --dport 80 -j SNAT --to-source 192.168.122.1

-A POSTROUTING -s 192.168.122.0/24 -d 192.168.122.133/32 -p tcp -m tcp --dport 8732 -j SNAT --to-source 192.168.122.1

-A POSTROUTING -s 192.168.122.0/24 -d 192.168.122.133/32 -p tcp -m tcp --dport 25 -j SNAT --to-source 192.168.122.1

-A POSTROUTING -s 192.168.122.0/24 -d 192.168.122.133/32 -p tcp -m tcp --dport 110 -j SNAT --to-source 192.168.122.1

-A POSTROUTING -s 192.168.122.0/24 -d 192.168.122.133/32 -p tcp -m tcp --dport 143 -j SNAT --to-source 192.168.122.1

-A POSTROUTING -s 192.168.122.0/24 -d 192.168.122.133/32 -p tcp -m tcp --dport 443 -j SNAT --to-source 192.168.122.1

-A POSTROUTING -s 192.168.122.0/24 -d 192.168.122.133/32 -p tcp -m tcp --dport 465 -j SNAT --to-source 192.168.122.1

-A POSTROUTING -s 192.168.122.0/24 -d 192.168.122.133/32 -p tcp -m tcp --dport 993 -j SNAT --to-source 192.168.122.1

-A POSTROUTING -s 192.168.122.0/24 -d 192.168.122.133/32 -p tcp -m tcp --dport 995 -j SNAT --to-source 192.168.122.1

-A POSTROUTING -s 192.168.122.0/24 -d 192.168.122.133/32 -p tcp -m tcp --dport 99 -j SNAT --to-source 192.168.122.1

COMMIT

# Completed on Thu Mar 23 18:07:55 2017


/etc/init.d/iptables restart

重启服务器,测试虚拟机能否上网,其他电脑能否用物理机的IP地址访问虚拟机的web服务。

设置NAT网络参考:http://blog.chinaunix.net/uid-21710354-id-4467679.html


9、查看虚拟机

查看虚拟机:virsh list

查看umail虚拟机的快照:virsh snapshot-list umail

创建umail虚拟机的快照:virsh snapshot-create-as umail umail_webmail-1.6.41-1.el6.x86_64_umail_app-2.2.25-1.el6.x86_64

    

    

    


Centos 6.5安装配置KVM

标签:centos 6.5安装kvm   kvm部署   

原文地址:http://blog.51cto.com/net881004/2053129

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