ubutnu 22 安装 kvm WebVirtMgr

1.kvm安装 参见https://sharadchhetri.com/install-kvm-on-ubuntu-20-04-lts-desktop/

sudo apt -y update
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils

sudo adduser `id -un` libvirt
sudo adduser `id -un` kvm

sudo grep `id -un` /etc/group
virsh list --all


sudo apt install virt-manager

2.WebVirtMgr 参见 https://blog.csdn.net/qq_34146694/article/details/84871240

docker run -itd --name virtmgr -p6080:6080 -p8080:8080 --restart=always jieshao/web_kvm:onlyweb

修改网络为桥接
sudo vi /etc/netplan/00-installer-config.yaml

network:
  ethernets:
    eno5:
      dhcp4: no
      dhcp6: no
    eno6:
      dhcp4: no
      dhcp6: no
    eno7:
      dhcp4: no
      dhcp6: no
    eno8:
      dhcp4: no
      dhcp6: no
  version: 2
  bridges:
    br0:
      interfaces:
        - eno5
        - eno6
        - eno7
        - eno8
      addresses:
        - 192.168.1.140/24
      optional: true
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
          - 233.5.5.5
          - 114.114.114.114
      dhcp4: no
      dhcp6: yes

打开主机防火墙
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT

sudo vi /etc/libvirt/libvirtd.conf

listen_tls = 0
listen_tcp = 1
auth_tcp = "none"

sudo vi /etc/default/libvirtd

LIBVIRTD_ARGS="-l -d"
start_libvirtd=yes

重启 sudo service libvirtd restart ,可能会报错,不用管它。 netstat -an|grep 16509 端口起来就行。
sudo systemctl enable docker
sudo systemctl enable libvirtd

修改webVirMgr密码
sudo docker exec virtmgr bash
/webvirmgr/manage.py changepassword admin

登录后
add connection 172.17.0.1,用户名密码暂时没什么用,随便设
添加存储池
Create Custom Instance
修改xml
网络:

 <interface type='bridge'>
  <mac address='52:54:00:4b:73:d6'/>
  <source bridge='br0'/>
  <target dev='vnet0'/>
  <model type='virtio'/>
  <alias name='net0'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

差异磁盘:

 <disk type='file' device='disk'>
  <driver name='qemu' type='qcow2'/>
  <source file='子盘路径.img' index='2'/>
  <backingStore type='file' index='3'>
    <format type='qcow2'/>
    <source file='父盘路径.img'/>
    <backingStore/>
  </backingStore>
  <target dev='vda' bus='virtio'/>
  <alias name='virtio-disk0'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>

双光驱

   <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='1'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source/>
      <backingStore/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

建差分盘用命令
sudo qemu-img create -f qcow2 -F qcow2 -o backing_file=父盘路径.img,size=60G 子盘路径.img

标签: none

评论已关闭