Kvm的部署和安装虚拟机中安装虚拟主机
- 首先部署kvm前提条件:
CPU: 8核
内存:8G
硬盘:128G
服务器硬件支持虚拟化(CPU支持)
参考文档 https://support.huawei.com/enterprise/zh/doc/EDOC1100318044/c887b2ca
2.第二步yum安装下载cockpit
yum -y install cockpit
yum install qemu-kvm libvirt libvirt-daemon virt-install virt-manager libvirt-dbus
systemctl start libvirtd.service
3.设置开机自启动
systemctl enable --now cockpit.socket
4.查看启动的进程端口号为:9090
[root@localhost ~]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 938/sshd: /usr/sbin
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 36253/dnsmasq
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 937/cupsd
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 2841/sshd: root@pts
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 2775/sshd: root@pts
tcp 0 0 127.0.0.1:6012 0.0.0.0:* LISTEN 36705/sshd: root@pt
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::22 :::* LISTEN 938/sshd: /usr/sbin
tcp6 0 0 ::1:6012 :::* LISTEN 36705/sshd: root@pt
tcp6 0 0 ::1:6010 :::* LISTEN 2775/sshd: root@pts
tcp6 0 0 ::1:6011 :::* LISTEN 2841/sshd: root@pts
tcp6 0 0 :::9090 :::* LISTEN 1/systemd
tcp6 0 0 ::1:631 :::* LISTEN 937/cupsd
-
输入本机IP地址加端口访问网页,进行登录
192.168.8.73:9090/
6.进入下面配置文件中注释root用户,登录成功
cat /etc/cockpit/disallowed-users
7.访问成功后,添加网桥
进入添加网桥之后,名称自己修改,端口设置为自己的网卡名称
8.添加和本机相同的镜像,镜像到虚拟机的根目录下
进入到该配置文件中修改为root
vim /etc/libvirt/qemu.conf
9.需要改镜像的属组和主
chown -R root CentOS-Stream-9-latest-x86_64-dvd1.iso
[root@localhost ~]# ll
总用量 9840648
-rw-r--r--. 1 root root 1305 1月 26 15:53 1.sh
drwxr-xr-x. 2 root root 6 1月 26 15:45 公共
drwxr-xr-x. 2 root root 6 1月 26 15:45 模板
drwxr-xr-x. 2 root root 6 1月 26 15:45 视频
drwxr-xr-x. 2 root root 6 1月 26 15:45 图片
drwxr-xr-x. 2 root root 6 1月 26 15:45 文档
drwxr-xr-x. 2 root root 6 1月 26 15:45 下载
drwxr-xr-x. 2 root root 6 1月 26 15:45 音乐
drwxr-xr-x. 2 root root 6 1月 26 15:45 桌面
-rw-------. 1 root root 1053 1月 26 15:44 anaconda-ks.cfg
-rw-r--r--. 1 root root 10076815360 1月 26 16:26 CentOS-Stream-9-latest-x86_64-dvd1.iso
9.修改镜像的权限命令如下:
chmod 700 CentOS-Stream-9-latest-x86_64-dvd1.iso
[root@localhost ~]# ll
总用量 9840648
-rw-r--r--. 1 root root 1305 1月 26 15:53 1.sh
drwxr-xr-x. 2 root root 6 1月 26 15:45 公共
drwxr-xr-x. 2 root root 6 1月 26 15:45 模板
drwxr-xr-x. 2 root root 6 1月 26 15:45 视频
drwxr-xr-x. 2 root root 6 1月 26 15:45 图片
drwxr-xr-x. 2 root root 6 1月 26 15:45 文档
drwxr-xr-x. 2 root root 6 1月 26 15:45 下载
drwxr-xr-x. 2 root root 6 1月 26 15:45 音乐
drwxr-xr-x. 2 root root 6 1月 26 15:45 桌面
-rw-------. 1 root root 1053 1月 26 15:44 anaconda-ks.cfg
-rwx------. 1 root root 10076815360 1月 26 16:26 CentOS-Stream-9-latest-x86_64-dvd1.iso
-
在网页中创建虚拟主机,在左边的菜单栏中找到“应用程序”下载虚拟主机
【总结】到这里就部署完成了。