Linux KVM 多宿主机的虚拟机互相访问
2021/11/15 7:10:17
本文主要是介绍Linux KVM 多宿主机的虚拟机互相访问,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
两台VM主机 10.0.0.202 10.0.0.203 1》 开启VT
2》 开始查看内核是否内嵌KVM [20:10:08 root@noise ~]#egrep '(vmx|svm)' /proc/cpuinfo flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves arat flush_l1d arch_capabilities [20:18:37 root@noise ~]#ll /dev/kvm crw-rw---- 1 root kvm 10, 232 Nov 14 20:10 /dev/kvm 3》 开始安装工具 [19:08:14 root@noise ~]#apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager virt-viewer 4》开始部署KVM虚拟机 4.1》 建立raw或者qcow2文件 [19:25:33 root@noise ~]#qemu-img create -f raw /data/CentOS-7-x86_64-DVD-2009.raw 10G 4.2》上传系统安装文件镜像 - 用xftp上传镜像 [20:20:20 root@noise ~]#ll /data/CentOS-7-x86_64-DVD-2009* -rw-r--r-- 1 libvirt-qemu kvm 4712300544 Nov 14 19:20 /data/CentOS-7-x86_64-DVD-2009.iso -rw-r--r-- 1 libvirt-qemu kvm 10737418240 Nov 14 20:17 /data/CentOS-7-x86_64-DVD-2009.raw 4.3》 开始安装虚拟机 [19:33:17 root@noise ~]#virt-install --virt-type kvm --name Centos-7-x86_64_1 --memory 1024 --cdrom=/data/CentOS-7-x86_64-DVD-2009.iso --disk=/data/CentOS-7-x86_64-DVD-2009.raw --network network=default --graphics vnc,listen=0.0.0.0 --noautoconsole 4.4》用tightVNC查看虚拟机安装进度
5》 安装完毕,查看是否成功 [20:20:27 root@noise ~]#virsh list --all Id Name State ---------------------------------------------------- 4 Centos-7-x86_64_1 running 6》打开x-manager配置kvm虚拟机 [20:01:19 root@noise ~]#virt-manager 注意,需要先下载x-manager,然后xshell打开x-manager选项
6》 配置KVM虚拟机
7》 配置完毕重启虚拟机 [20:06:38 root@noise ~]#virsh shutdown Centos-7-x86_64_1 Domain Centos-7-x86_64_1 is being shutdown [20:10:03 root@noise ~]#virsh list --all Id Name State ---------------------------------------------------- - Centos-7-x86_64_1 shut off [20:10:05 root@noise ~]#virsh start Centos-7-x86_64_1 Domain Centos-7-x86_64_1 started
8》10.0.0.203 类似配置
9》 此时10.0.0.202里面的kvm虚拟机能ping通10.0.0.203的kvm虚拟机 10》 查看宿主机的网络状态,用的是网桥模式,绑定到eth0,此时大家都在10.0.0.0/24网段,所以都能ping通 10.0.0.202---- [20:27:01 root@noise ~]#ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:75:7d:76 brd ff:ff:ff:ff:ff:ff inet 10.0.0.202/24 brd 10.0.0.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe75:7d76/64 scope link valid_lft forever preferred_lft forever 3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:a1:f8:3b brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:a1:f8:3b brd ff:ff:ff:ff:ff:ff 8: macvtap0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 500 link/ether 52:54:00:b1:b4:97 brd ff:ff:ff:ff:ff:ff inet6 fe80::5054:ff:feb1:b497/64 scope link valid_lft forever preferred_lft forever 10.0.0.203 --- [20:15:15 root@noise ~]#ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:72:d5:3a brd ff:ff:ff:ff:ff:ff inet 10.0.0.203/24 brd 10.0.0.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe72:d53a/64 scope link valid_lft forever preferred_lft forever 3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:21:5f:cc brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:21:5f:cc brd ff:ff:ff:ff:ff:ff 7: macvtap0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 500 link/ether 52:54:00:8c:e2:d9 brd ff:ff:ff:ff:ff:ff inet6 fe80::5054:ff:fe8c:e2d9/64 scope link valid_lft forever preferred_lft forever
这篇关于Linux KVM 多宿主机的虚拟机互相访问的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-12如何创建可引导的 ESXi USB 安装介质 (macOS, Linux, Windows)
- 2024-11-08linux的 vi编辑器中搜索关键字有哪些常用的命令和技巧?-icode9专业技术文章分享
- 2024-11-08在 Linux 的 vi 或 vim 编辑器中什么命令可以直接跳到文件的结尾?-icode9专业技术文章分享
- 2024-10-22原生鸿蒙操作系统HarmonyOS NEXT(HarmonyOS 5)正式发布
- 2024-10-18操作系统入门教程:新手必看的基本操作指南
- 2024-10-18初学者必看:操作系统入门全攻略
- 2024-10-17操作系统入门教程:轻松掌握操作系统基础知识
- 2024-09-11Linux部署Scrapy学习:入门级指南
- 2024-09-11Linux部署Scrapy:入门级指南
- 2024-08-21【Linux】分区向左扩容的方法