标签:介绍 最大 date pre 功能 inter lis 启动 编辑
设置-处理器-虚拟化
yum install libvirt virt-install qemu-kvm -y
systemctl start libvirtd.service
systemctl status libvirtd.service
virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name centos7 --memory 1024 --vcpus 1 --disk /opt/centos7.raw,format=raw,size=10 --cdrom /opt/CentOS-7-x86_64-DVD-1810.iso --network network=default --graphics vnc,listen=0.0.0.0 --noautoconsole
安装VNC工具连接
virsh list
virsh list --all
virsh start centos7
virsh reboot centos7
virsh shutdown centos7
virsh destroy centos7
virsh dumpxml centos7
virsh dumpxml centos7 > centos7.xml
virsh destroy centos7
virsh undefine centos7
virsh define centos7.xml
virsh domrename panghu shouhu
virsh suspend centos7
virsh resume centos7
virsh autostart centos7
ll /etc/libvirt/qemu/autostart/
把虚拟机磁盘迁移到/data目录并且启动
virsh shutdown centos7
mkdir /data
mv /opt/centos7.raw /data
virsh edit centos7
--------------------
<source file='/data/centos7.raw'/>
--------------------
virsh start centos7
virsh list
virsh vncdisplay centos7
ssh 192.168.122.77
登录进需要开启console的虚拟机并添加参数
ssh 192.168.122.77
grubby --update-kernel=ALL --args="console=ttyS0,115200n8"
grep "115200" /boot/grub2/grub.cfg
reboot
virsh destroy centos7
virsh start centos7
virsh console centos7
退出
ctrl + ]
raw:不支持做快照,性能好
qcow2:支持快照,性能不如raw好
qemu-img info centos7.raw
qemu-img create -f qcow2 /data/centos7.qcow2 1G
qemu-img info centos7.qcow2
qemu-img resize /data/centos7.qcow2 1T
virsh destroy centos7
qemu-img convert -f raw -O qcow2 centos7.raw centos7.qcow2
virsh edit centos7
------------------------------------------
<driver name='qemu' type='qcow2'/>
<source file='/opt/centos7.qcow2'/>
------------------------------------------
virsh start centos7
virsh console centos7
virsh snapshot-list centos7
virsh snapshot-create-as centos7 snap1
virsh snapshot-list centos7
virsh snapshot-revert centos7 snap1
virsh snapshot-delete centos7 snap1
virsh snapshot-list centos7
virsh shutdown centos7
virt-clone --auto-clone -o centos7 -n centos7-backup
virsh list --all
virsh dumpxml web-blog-backup |grep "qcow2"
virsh snapshot-list centos7
qemu-img create -f qcow2 -b centos7.qcow2 centos7-clone.qcow2
qemu-img info centos7-clone.qcow2
virsh dumpxml centos7 > centos7-clone.xml
sed -i '/uuid/d' centos7-clone.xml
sed -i '/mac address/d' centos7-clone.xml
sed -i 's#centos7.qcow2#centos7-clone.qcow2#g' centos7-clone.xml
sed -i '/\<nam/s#centos7#centos7-clone#g' centos7-clone.xml
virsh define centos7-clone.xml
virsh list --all
virsh start centos7-clone
virsh iface-bridge eth0 br0
cd /opt
qemu-img create -f qcow2 -b centos7.qcow2 bridge.qcow2
virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name centos7-bridge --memory 1024 --vcpus 1 --disk /opt/bridge.qcow2 --boot hd --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole
virsh console centos7-bridge
ip a
ping xxxx
qemu-img create -f qcow2 centos7-add.qcow2 10G
virsh attach-disk centos7 /opt/centos7-add.qcow2 vdb --subdriver qcow2
virsh console centos7
fdisk -l
mkfs.xfs /dev/vdb
mount /dev/vdb /mnt/
df -h
virsh attach-disk centos7 /opt/centos7-add.qcow2 vdb --subdriver qcow2
virsh attach-disk centos7 /opt/centos7-add.qcow2 vdb --subdriver qcow2 --config
virsh detach-disk centos7 vdb
virsh detach-disk centos7 vdb
virsh detach-disk centos7 vdb --config
qemu-img info /opt/centos7-add.qcow2
qemu-img resize /opt/centos7-add.qcow2 +10G
virsh attach-disk centos7 /opt/centos7-add.qcow2 vdb --subdriver qcow2
virsh console centos7
fdisk -l /dev/vdb
mount /dev/vdb /mnt/
df -h|tail -1
xfs_growfs /dev/vdb
df -h|tail -1
virsh attach-interface centos7 --type bridge --mac 52:54:00:b1:b5:8a --source br0 --model virtio detachinterface
virsh attach-interface centos7 --type bridge --mac 52:54:00:b1:b5:8a --source br0 --model virtio detachinterface --config
virsh detach-interface centos7 bridge
virsh detach-interface centos7 bridge
virsh detach-interface centos7 bridge --config
virt-install --virt-type kvm --os-type=linux --os-variant rhel7 --name centos7 --
memory 512,maxmemory=2048 --vcpus 1 --disk /opt/centos7.qcow2 --boot hd --network bridge=br0 --
graphics vnc,listen=0.0.0.0 --noautoconsole
virsh destroy centos7
virsh setmaxmem centos7 4096M
virsh start centos7
virsh console centos7
free -h
virsh setmem centos7 2048M --live
virsh console centos7
free -h
virsh setmem centos7 2048M --config
virsh console centos7
free -h
virsh edit centos7
------------------------------------------------
<vcpu placement='static' current='2'>4</vcpu>
------------------------------------------------
virsh setvcpus centos7 4 --live
setvcpus centos7 4 --config
标签:介绍 最大 date pre 功能 inter lis 启动 编辑
原文地址:https://www.cnblogs.com/alaska/p/12387244.html