官方文档:https://www.linux-kvm.org/page/Documents 安装桌面环境和虚拟化主机yum groupinstall -y "GNOME 桌面" \ "虚拟化主机" "virtualization-platform" "network-file-system-client" "remote-system-management" #查看虚拟化主机组信息 yum groupinfo "虚拟化主机" 设置以图形化界面启动systemctl set-default graphical.target 查看是否开启cpu虚拟化grep -E "vmx|svm" /proc/cpuinfo && echo "支持KVM虚拟化" || echo "不支持KVM虚拟化" lsmod | grep kvm && echo "支持KVM虚拟化" || echo "不支持KVM虚拟化" 安装管理工具#安装:虚拟化图行管理工具 yum install virt-manager -y #安装:电源管理工具 yum install acpid -y #安装:NetworkManager网卡管理组件 yum install NetworkManager -y #安装工具包 yum install virt-install -y yum install virt-viewer -y #远程连接工具 yum install openssh-askpass -y #安装虚拟化桥接网络工具 yum install bridge-utils -y #启动NetworkManager网卡管理组件 systemctl enable NetworkManager.service systemctl restart NetworkManager.service #启动libvirtd虚拟化服务进程 systemctl enable libvirtd.service systemctl start libvirtd.service 查看进程状态(以libvirtd为例)#查看状态 systemctl status libvirtd.service #查看是否允许开机启动 systemctl list-unit-files|grep libvirtd
#查看服务关联进程 ps aux|grep libvirtd pstree|grep libvirtd 查看网卡信息
ip a
nmcli conn show 配置虚拟化<NAT地址转换>网络#查看:默认的default.xml虚拟网络配置文件 cat /etc/libvirt/qemu/networks/default.xml
#手动编辑修改/etc/libvirt/qemu/networks/default.xml vim /etc/libvirt/qemu/networks/default.xml <network> <name>default</name> <uuid>b4f7d394-6b54-4ef1-ad9c-cf63f458dd63</uuid> <forward mode='nat'/> <bridge name='virbr0' stp='on' delay='0'/> <mac address='52:54:00:a9:8a:a6'/> <ip address='192.168.123.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.123.2' end='192.168.123.254'/> </dhcp> </ip> </network> #开启路由转发(默认开启) sysctl -w net.ipv4.ip_forward=1 sysctl -a | grep net.ipv4.ip_forward #重启使配置生效 init 6 #查看虚拟网络列表 virsh net-list --all kvm部署虚拟机
运行virt-manager 工具
图形化界面安装虚拟机镜像文件需要执行权限
接下来就是普通的系统安装流程 命令行安装虚拟机virt-install --os-variant rhel7 \ --name testkvm2 \ --memory 512,maxmemory=1024 \ --vcpus 1,maxvcpus=2 \ --network network=default,model=virtio \ --disk device=disk,path=/var/lib/libvirt/images/testkvm2.disk01,format=qcow2,size=3,bus=virtio,cache=writeback,io=threads \ --location /mnt/CentOS-7-x86_64-DVD-1708.iso \ --graphics vnc,port=-1 \ --autostart
#查看命令帮助信息
xshell连接使用#需要xmanager-passive virt-manager (责任编辑:IT) |