KVM

grep -E -i "(svm|vmx|lm)" /proc/cpuinfo
modinfo kvm
lsmod | grep kvm
ls -l /dev/kvm
yum install -y libvirt libvirt-daemon-kvm virt-manager
rpm -ql libvirt-daemon
systemctl start libvirtd.service
virsh iface-bridge ens33 br0
yum install -y xorg-x11-font-utils.x86_64 xorg-x11-server-utils.x86_64 xorg-x11-utils.x86_64 xorg-x11-xauth.x86_64 xorg-x11-xinit.x86_64 xorg-x11-font-utils.x86_64 xorg-x11-drv-ati.x86_64 dejavu-lgc-sans-fonts

yum install libvirt libvirt-client python-virtinst virt-manager virt-install qemu-kvm virt-viewer-y
systemctl start libvirtd.service
virsh iface-bridge eno16777736 br0 --no-stp
systemctl restart network.service
brctl show
[root@node1 ~]# yum -y install virt-viewer
[root@node1 ~]# mkdir /images/centos -p
[root@node1 ~]# virt-install -n centos6.7 -r 512 --vcpus=2,maxvcpus=4 --pxe --disk /images/centos/centos6.7.qcow2,size=120,format=qcow2,bus=virtio,sparse=yes --network bridge=br0,model=virtio --force
[root@node1 ~]# virsh list
virt-viewer 3
[root@node1 ~]# virsh destroy 1
ls /etc/libvirt/qemu
virsh create /etc/libvirt/qemu/centos6.7.xml
virsh undefine centos6.7 --remove-all-storage
virt-install -n cirros -r 128 --disk /images/cirros/cirros-no_cloud-0.3.0-i386-disk.img --import --dry-run
[root@node1 ~]# qemu-img create -f qcow2 -o size=20G,preallocation=metadata /images/cirros/second.qcow2
[root@node1 ~]# qemu-img info /images/cirros/second.qcow2
virsh attach-disk 8 /images/cirros/second.qcow2 vda --targetbus virtio
[root@node1 ~]# virsh detach-disk 8 vda
[root@node1 ~]# virsh attach-interface 8 bridge virbr0
[root@node1 ~]# virsh detach-interface 8 bridge --mac 52:54:00:E7:4D:25
[root@node1 ~]# virsh dumpxml cirros
[root@node1 ~]# virsh vcpucount 8
[root@node1 ~]# virsh vcpuinfo 8
[root@node1 ~]# virsh setvcpus 8 2
[root@node1 ~]# virsh domblklist 8
[root@node1 ~]# virsh domiflist 8
[root@node1 ~]# virsh dominfo 8
[root@node1 ~]# virsh nodeinfo
[root@node1 ~]# virsh uri
[root@node1 ~]# virsh version
[root@node1 ~]# virsh iface-list
[root@node1 ~]# virsh nwfilter-list
[root@node1 ~]# virsh nwfilter-list
[root@node1 ~]# modinfo 8021q
[root@node1 ~]# modprobe 8021q
[root@node1 ~]# yum install vconfig

创建物理桥

[root@node1 ~]# brctl addbr br-ex
[root@node1 ~]# ip link set br-ex up
[root@node1 ~]# ip addr del 192.168.1.131/24 dev eno16777736;ip addr add 192.168.1.131/24 dev br-ex;brctl addif br-ex eno16777736

创建内部桥

[root@node1 ~]# brctl addbr br-in
[oot@node1 ~]# ip link set br-in up

开启路由转发功能

[root@node1 ~]# vim /etc/sysctl.conf
添加
net.ipv4.ip_forward = 1
[root@node1 ~]# ip netns add r1
[root@node1 ~]# ip netns add r2
[root@node1 ~]# ip netns list
[root@node1 ~]# ip netns exec r1 ifconfig -a
lo: flags=8 mtu 65536
http://sihua.blog.51cto.com/377227/1887978

[root@node1 ~]# virt-install -n cirros -r 128 --disk /images/cirros/cirros-no_cloud-0.3.0-i386-disk.img --import
[root@node1 ~]# virt-install -n cirros -r 128 --vcpus=1,maxvcpus=4 --disk /images/cirros/cirros-no_cloud-0.3.0-i386-disk.img --network bridge=br0,model=virtio --import --serial=pty --console=pty --nographics

egrep '(vmx|svm)' /proc/cpuinfo
yum install epel-release net-tools vim unzip zip wget ftp -y
yum install qemu-kvm libvirt virt-install bridge-utils -y
systemctl start libvirtd
systemctl enable libvirtd
virt-install -n think8848-kvmbase -r 2048 --disk /home/kvm-bak/think8848-kvmbase.img,format=qcow2,size=20 --network bridge=br0
--os-type=linux --os-version=rhel7.2 --cdrom /home/iso/centos-7-x86-64.iso --vnc
--vncport=5910 --vnclisten=0.0.0.0
firewall-cmd --zone=public --add-port=5910/tcp --permanent
firewall-cmd --reload
virsh console kvm1

virsh autostart kvm1
http://liqingbiao.blog.51cto.com/3044896/1740740

virsh常用命令一览表
命令 说明
help 显示该命令的说明
quit 结束 virsh,回到 Shell
connect 连接到指定的虚拟机服务器
create 启动一个新的虚拟机
destroy 删除一个虚拟机
start 开启(已定义的)非启动的虚拟机
define 从 XML 定义一个虚拟机
undefine 取消定义的虚拟机
dumpxml 转储虚拟机的设置值
list 列出虚拟机
reboot 重新启动虚拟机
save 存储虚拟机的状态
restore 回复虚拟机的状态
suspend 暂停虚拟机的执行
resume 继续执行该虚拟机
dump 将虚拟机的内核转储到指定的文件,以便进行分析与排错
shutdown 关闭虚拟机
setmem 修改内存的大小
setmaxmem 设置内存的最大值
setvcpus 修改虚拟处理器的数量

/var/lib/libvirt/images

你可能感兴趣的:(KVM)