CentOS 安装 KVM
程序员文章站
2022-06-12 15:38:01
...
KVM:Kernel-based Virtual Machine(基于内核的虚拟机)。
(1)确认是否能够安装KVM
(2)安装KVM
(3)配置网络Bridged Network
(4)安装虚拟机
配置kvm的IP
(5)虚拟机操作
KVM的配置文件
查看已安装的kvm
启动停止重启kvm
配置kvm
链接kvm
退出kvm
查看kvm
快照kvm
复制kvm
删除kvm
(1)确认是否能够安装KVM
# grep -E 'svm|vmx' /proc/cpuinfo > /dev/null && echo OK # grep flags /proc/cpuinfo|grep lm > /dev/null && echo OK
(2)安装KVM
# yum -y install libguestfs libvirt libvirt-client python-virtinst qemu-kvm qemu-img virt-manager virt-top virt-viewer virt-who virt-install bridge-utils # systemctl start libvirtd # systemctl enable libvirtd
(3)配置网络Bridged Network
# systemctl disable NetworkManager # systemctl stop NetworkManager # vi /etc/sysconfig/network-scripts/ifcfg-br0 DEVICE=br0 BOOTRPOTO=none TYPE=Bridge ONBOOT=yes DEFROUTE=yes IPV6INIT=no NM_CONTROLLED=yes USERCTL=no IPADDR=192.168.21.176 NETMASK=255.255.255.0 GATEWAY=192.168.21.254 DNS1=219.149.6.99 # vi /etc/sysconfig/network-scripts/ifcfg-p4p1 TYPE=Ethernet BOOTPROTO=static IPV6INIT=no NAME=p4p1 UUID=4497ef0a-b570-49fc-bd41-cca65af5934d DEVICE=p4p1 ONBOOT=yes IPADDR=192.168.21.176 PREFIX=24 GATEWAY=192.168.21.254 DNS1=219.149.6.99 BRIDGE=br0 # systemctl restart network # ifconfig # brctl show
(4)安装虚拟机
# qemu-img create -f qcow2 /var/lib/libvirt/images/kvm01_centos7.img 20G # ls -l /var/lib/libvirt/images # virt-install \ --name=kvm01_centos7 \ --hvm \ --virt-type kvm \ --vcpus=2 --ram=1024 \ --network bridge=br0 \ --disk path=/var/lib/libvirt/images/kvm01_centos7.img,size=20 \ --location=/tmp/CentOS-7-x86_64-Minimal-1511.iso \ --os-type=linux --os-variant=rhel7 \ --accelerate \ --nographics \ --autostart \ --extra-args "console=ttyS0"
配置kvm的IP
# virsh start kvm01_centos7 # virsh console kvm01_centos7 # vi /etc/sysconfig/network-scripts/ifcfg-eth0 # shutdown -r now
(5)虚拟机操作
KVM的配置文件
# ll /etc/libvirt/qemu/
查看已安装的kvm
# virsh list --all
启动停止重启kvm
# virsh start kvm01_centos7 # virsh shutdown kvm01_centos7 # virsh reboot kvm01_centos7
配置kvm
# virsh dumpxml kvm01_centos7 # virsh edit kvm01_centos7
链接kvm
# virsh console kvm01_centos7
退出kvm
引用
# Ctrl+]
# Ctrl+5
# Ctrl+5
查看kvm
# virsh dominfo kvm01_centos7 # virt-top
快照kvm
# virsh snapshot-list kvm01_centos7 # virsh snapshot-create-as kvm01_centos7 kvm01_centos7-snapshot-2016-09-06-001 # virsh snapshot-revert kvm01_centos7 kvm01_centos7-snapshot-2016-09-06-001 # virsh snapshot-delete kvm01_centos7 kvm01_centos7-snapshot-2016-09-06-001
复制kvm
# virsh shutdown kvm01_centos7 # virt-clone -o kvm01_centos7 -n kvm02_centos7 -f /var/lib/libvirt/images/kvm02_centos7.img # ll /var/lib/libvirt/images/ # virsh list --all
# virsh start kvm02_centos7 # virsh console kvm02_centos7 # vi /etc/hosts # vi /etc/hostname (CentOS6是/etc/sysconfig/network) # vi /etc/sysconfig/network-scripts/ifcfg-eth0 # vi /etc/udev/rules.d/70-persistent-net.rules # shutdown -r now
删除kvm
# virsh autostart --disable kvm01_centos7 # virsh destroy kvm01_centos7 # virsh undefine kvm01_centos7
上一篇: 写给自己的2015
下一篇: 滴滴背后的大数据应用
推荐阅读
-
Unity Android安装apk后显示两个app的问题
-
怎么配置PHP环境和安装Zendstdio编辑器
-
LAMP(Apache MySQL PHP)一键安装包教程(CentOS 5 32bit)
-
想用centos5.5 x64搭建lnmp生成环境,求怎么进行相关软件的版本选择
-
PHP在ubuntu中编译安装 - 走一趟再说
-
php安装wordpress
-
memcached - linux下安装php的memcache扩展
-
Windows下全新安装Apache2,PHP5,MYSQL5,Zend(1)_PHP教程
-
Windows下安装PHP单元测试环境PHPUnit图文教程_PHP
-
phpunit 的大局安装