kvm笔记总结
待记录
windows虚拟机(kvm)复制粘贴
https://forum.suse.org.cn/t/topic/15406
https://bbs.deepin.org/zh/post/259929
https://dausruddin.com/how-to-enable-clipboard-and-folder-sharing-in-qemu-kvm-on-windows-guest/
virt-mannager打不开
https://stackoverflow.com/questions/29468421/gtk-warning-cannot-open-display-launching-background-gtk
https://segmentfault.com/a/1190000039811754
KVM Web管理平台
1.WebVirtMgr
https://www.cnblogs.com/cnsre/p/12881921.html#3518-1530603185411
2.virt-mannager
克隆
https://cloud.tencent.com/developer/article/2017453
https://www.cnblogs.com/5201351/p/4461000.html
刪除
https://www.jianshu.com/p/6ca7910363d1
报错总结
https://www.cnblogs.com/daisyyang/p/10953202.html
常用命令总结
参考链接:
https://cloud.tencent.com/developer/article/2115851
- 启动
virsh start [name]
- 停止
virsh stop[name]
- 重启
virsh restart [name]
- 查看所有的列表
virsh list --all
批量安裝windows项目总结
安装kvm相关包:
sudo apt install qemu-kvm virt-manager libvirt-daemon-system -y
sudo systemctl --now enable libvirtd
sudo chown -R jasmine. /filecoin_1
mkdir /filecoin_1/kvm/libvirt -pv
sudo mv /var/lib/libvirt /filecoin_1/kvm/
sudo ln -sv /filecoin_1/kvm/libvirt /var/lib/libvirt
通过xml文件创建虚拟机:
virsh define /etc/libvirt/qemu/win-test.xml
os-images:/filecoin_1/kvm/libvirt/person/os-images/
file:/filecoin_1/kvm/libvirt/images/win/
win10: /filecoin_1/kvm/libvirt/person/os-images/Windows10.iso
host=win1 && qemu-img create -f qcow2 $host/$host.qcow2 40G
克隆虚拟机
host=win2 && virt-clone -o windows10-test -n $host -f /filecoin_1/kvm/libvirt/images/win/$host/$host.qcow2
/filecoin_1/kvm/libvirt/images/win/win1/win10-1.qcow2
内存管理:
https://www.cnblogs.com/ygbh/p/17420868.html
virt-install --virt-type kvm --name windows10 --ram 4096 --vcpus 2 \
--cdrom=/filecoin_1/kvm/libvirt/person/os-images/Windows10.iso \
--disk path=/filecoin_1/kvm/libvirt/images/win/win-test/win-test.qcow2 --network network=default \
--graphics vnc,listen=0.0.0.0 --noautoconsole
for i in `seq 24 50`;do host=win$i && virt-clone -o windows10-test -n $host -f /filecoin_1/kvm/libvirt/images/win/$host/$host.qcow2;done
kvm命令:
pdf
kvm克隆细节:
https://www.cnblogs.com/5201351/p/4461000.html
kvm配置网桥网络(虚拟机和物理机在同一个内网)
ubuntu网桥配置文件更改:
jasmine@JMT-SW7-F12-DLR-0-166:~$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
enp4s0:
dhcp4: no
dhcp6: no
bridges:
br0:
dhcp4: no
dhcp6: no
addresses:
- 10.20.0.166/21
gateway4: 10.20.0.1
nameservers:
addresses: [223.6.6.6]
interfaces:
- enp4s0
version: 2
网桥配置完成后,需要检查两个内核参数配置
- ipv4转发配置
- bridge-nf-call-iptables 网桥iptables设置问题
cat /proc/sys/net/bridge/bridge-nf-call-iptables
值 要为0,不为0 需要重置
echo 0 > /proc/sys/net/bridge/bridge-nf-call-iptables
sudo tee /etc/sysctl.d/kubernetes.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
跨机器迁移kvm虚拟机
- 导出kvm虚拟机的xml配置文件,并拷贝到目标机器的/etc/libvirt/qemu/ 这个目录下
virsh list --all| grep ubuntu
virsh domblklist k8s_ubuntu_template
virsh dumpxml k8s_ubuntu_template > k8s_ubuntu_template.xml
scp *.xml DEST_HOST_IP:/etc/libvirt/qemu/
- 拷贝虚拟机的系统盘
scp -r ubuntu2204/ DEST_HOST_IP:`pwd`
- DEST_HOST操作导入
virsh define /etc/libvirt/qemu/k8s_ubuntu_template.xml
- 启动后检查
virsh start domain
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?