CentOS7 Mini版本安装KVM虚拟化

默认服务器为Mini安装,将当前Mini安装系统,升级为KVM虚拟机,通过VNC客户端登录后进行管理KVM

安装VNC工具

VNC英文全称为Virtual Network Computing,可以位操作系统提供图形接口连接方式,简单的来说就是一款桌面共享应用

安装前准备环境

[root@localhost]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost]# sed -i 's/^enabled=0/enabled=1/g' /etc/yum.repos.d/CentOS-Base.repo
[root@localhost]# yum clean all && yum makecache
[root@localhost]# yum check-update

安装图形换界面

[root@localhost]# yum groups install "MATE Desktop"
# 修改默认启动方式为图形化界面
[root@localhost]# systemctl set-default graphical.target
# 恢复为命令模式
[root@localhost]# systemctl set-default multi-user.target
[root@localhost]# 

安装配置VNC

[root@localhost]# yum install tigervnc-server -y
[root@localhost]# cp /usr/lib/systemd/system/vncserver@.service /usr/lib/systemd/system/vncserver@:1.service

# 修改为root身份执行
[root@localhost]# cat /usr/lib/systemd/system/vncserver@:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple

# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver_wrapper root %i
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

[root@localhost]# systemctl daemon-reload

配置VNC账户

[root@localhost]# vncpasswd
*****

开启NVC服务

[root@localhost]# systemctl enable vncserver@:1.service
[root@localhost]# systemctl start vncserver@:1.service

开启对应的防火墙

[root@localhost]# firewall-cmd --permanent --add-service vnc-server
[root@localhost]# systemctl restart firewalld.service

VNC-Client安装

此时可通过访问下载VNC-Client地址下载对应的客户,通过前面分配密码进行认证登录,注意端口默认从5091往后延续

安装KVM虚拟化

[root@localhost]# yum install qemu-kvm libvirt libvirt-client virt-install bridge-utils libguestfs-tools virt-manager virt-viewer
[root@localhost]# reboot
[root@localhost]# systemctl enable libvirtd
[root@localhost]# systemctl start libvirtd