博客之前搬运过一篇文章: Centos下部署KVM虚拟机,但是由于CentOS周期原因,所以博主已经将服务器更换为Debian11,下面更新Debian11安装kvm虚拟机的办法。
更新源:
apt update -y
安装依赖:
apt-get install qemu-kvm virtinst bridge-utils libvirt-daemon-system \ libvirt-dev libvirt-clients virt-top libguestfs-tools libosinfo-bin qemu-system virt-manager -y
安装完成后,配置网卡桥接,这步如果是极客用户,可以不用配置,将br网卡桥接到当前服务器网卡即可,如果嫌麻烦,建议按照下面步骤部署:
将网卡名改为br0,省去桥接步骤,配置参考如下:
root@198-46-200-50-host:~# cat /etc/network/interfaces
source /etc/network/interfaces.d/* auto lo iface lo inet loopback auto br0 iface br0 inet static address 198.46.200.50/28 gateway 198.46.200.49 bridge_ports eno1 bridge_stp off bridge_waitport 0 bridge_fd 0
建议直接修改当前网卡名,修改之前记得先备份网卡配置。
处理完成后,重启服务器,执行ip a 查看网卡是否生效:
root@198-46-200-50-host:~# ip a 1: lo:mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s25: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 00:25:90:a1:a9:7d brd ff:ff:ff:ff:ff:ff 3: eno1: mtu 1500 qdisc fq master br0 state UP group default qlen 1000 link/ether 00:25:90:a1:a9:7c brd ff:ff:ff:ff:ff:ff 4: br0: mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 00:25:90:a1:a9:7c brd ff:ff:ff:ff:ff:ff inet 198.46.200.50/28 brd 198.46.200.63 scope global br0 valid_lft forever preferred_lft forever inet6 fe80::225:90ff:fea1:a97c/64 scope link valid_lft forever preferred_lft forever 8: vnet0: mtu 1500 qdisc fq master br0 state UNKNOWN group default qlen 1000 link/ether fe:54:00:18:7d:4d brd ff:ff:ff:ff:ff:ff inet6 fe80::fc54:ff:fe18:7d4d/64 scope link valid_lft forever preferred_lft forever root@198-46-200-50-host:~#
生效后,运行 virsh 命令列出 KVM 虚拟机的可用网络:
virsh net-list --all
输出如下:
Name State Autostart Persistent ---------------------------------------------------------- default inactive no yes
可以看到Autostart为no,我们将其设置为开机自启:
virsh net-start default vrish net-autostart default
至此,基础环境配置完成。
镜像下载:https://down.idc.wiki/ISOS/ 下载后,参考Centos7部署虚拟机流程,部署虚拟机即可。