配置CentOS 阿里云源
1 | mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup |
安装开发工具
1 | yum install kernel-headers-`uname -r` kernel-devel-`uname -r` vim gcc make automake autoconf gcc-c++ wget curl libcurl |
安装kvm
1 | yum install -y libvirt-admin.x86_64 libvirt-client.x86_64 libvirt-daemon.x86_64 libvirt-daemon-config-network.x86_64 libvirt-daemon-config-nwfilter.x86_64 libvirt-daemon-driver-interface.x86_64 libvirt-daemon-driver-lxc.x86_64 libvirt-daemon-driver-network.x86_64 libvirt-daemon-driver-nodedev.x86_64 libvirt-daemon-driver-nwfilter.x86_64 libvirt-daemon-driver-qemu.x86_64 libvirt-daemon-driver-secret.x86_64 libvirt-daemon-driver-storage.x86_64 libvirt-daemon-driver-storage-core.x86_64 libvirt-dbus.x86_64 libvirt-devel.x86_64 libvirt-gconfig.i686 libvirt-gconfig.x86_64 libvirt-gconfig-devel.x86_64 libvirt-glib.x86_64 libvirt-glib-devel.x86_64 libvirt-gobject.x86_64 libvirt-gobject-devel.x86_64 libvirt-java.noarch libvirt-java-devel.noarch libvirt-java-javadoc.noarch libvirt-nss.x86_64 libvirt-python.x86_64 libvirt-snmp.x86_64 nbdkit-plugin-libvirt.x86_64 ocaml-libvirt.x86_64 ocaml-libvirt-devel.x86_64 php-libvirt.x86_64 php-libvirt-doc.noarch python36-libvirt.x86_64 rubygem-ruby-libvirt.x86_64 rubygem-ruby-libvirt-doc.noarch collectd-virt.x86_64 fence-agents-virsh.x86_64 libvirt.x86_64 libvirt-bash-completion.x86_64 libvirt-daemon-driver-storage-disk.x86_64 libvirt-daemon-driver-storage-gluster.x86_64 libvirt-daemon-driver-storage-iscsi.x86_64 libvirt-daemon-driver-storage-logical.x86_64 libvirt-daemon-driver-storage-mpath.x86_64 libvirt-daemon-driver-storage-rbd.x86_64 libvirt-daemon-driver-storage-scsi.x86_64 libvirt-daemon-kvm.x86_64 libvirt-daemon-lxc.x86_64 libvirt-docs.x86_64 libvirt-libs.x86_64 libvirt-lock-sanlock.x86_64 libvirt-login-shell.x86_64 perl-Sys-Virt.x86_64 virt-manager.noarch |
安装磁盘工具qemu
1 | yum install -y centos-release-qemu-ev.noarch ipxe-roms-qemu.noarch libvirt-daemon-driver-qemu.x86_64 qemu.x86_64 qemu-common.x86_64 qemu-guest-agent.x86_64 qemu-img.x86_64 qemu-kvm.x86_64 qemu-kvm-common.x86_64 qemu-system-alpha.x86_64 qemu-system-arm.x86_64 qemu-system-cris.x86_64 qemu-system-lm32.x86_64 qemu-system-m68k.x86_64 qemu-system-microblaze.x86_64 qemu-system-mips.x86_64 qemu-system-moxie.x86_64 qemu-system-or32.x86_64 qemu-system-s390x.x86_64 qemu-system-sh4.x86_64 qemu-system-unicore32.x86_64 qemu-system-x86.x86_64 qemu-system-xtensa.x86_64 qemu-user.x86_64 libvirt-lock-sanlock.x86_64 qemu-kvm-tools.x86_64 |
安装网络工具
1 | yum install -y bridge-utils.x86_64 cockpit-bridge.x86_64 console-bridge-devel.x86_64 net-tools iproute |
1 | yum install libguestfs-bash-completion.noarch libguestfs-benchmarking.x86_64 libguestfs-devel.x86_64 libguestfs-gfs2.x86_64 libguestfs-gobject.x86_64 libguestfs-gobject-devel.x86_64 libguestfs-java.x86_64 libguestfs-java-devel.x86_64 libguestfs-javadoc.noarch libguestfs-man-pages-ja.noarch libguestfs-man-pages-uk.noarch libguestfs-rsync.x86_64 libguestfs-xfs.x86_64 ocaml-libguestfs.x86_64 ocaml-libguestfs-devel.x86_64 python-libguestfs.x86_64 ruby-libguestfs.x86_64 libguestfs.x86_64 libguestfs-inspect-icons.noarch libguestfs-rescue.x86_64 libguestfs-tools.noarch libguestfs-tools-c.x86_64 libguestfs-winsupport.x86_64 lua-guestfs.x86_64 nbdkit-plugin-guestfs.x86_64 perl-Sys-Guestfs.x86_64 |
补全功能
1 | yum install -y bash-completion.noarch bash-completion-extras.noarch libguestfs-bash-completion.noarch libvirt-bash-completion.x86_64 |
1 | yum install -y virt-dib.x86_64 virt-install.noarch virt-manager.noarch virt-manager-common.noarch virt-p2v-maker.x86_64 virt-v2v.x86_64 virt-viewer.x86_64 virt-who.noarch |
1 | egrep '(vmx|svm)' /proc/cpuinfo |
virt-install
1 | –name 指定虚拟机的名称 |
1 | virt-install --name=gurobi --memory=512,maxmemory=1024 --vcpus=1,maxvcpus=2 --os-type=linux --os-variant=rhel7 --location=/tmp/CentOS-7-x86_64-DVD-1708.iso --disk path=/kvm_data/gurobi.img,size=10 --bridge=br0 --graphics=none --console=pty,target_type=serial --extra-args="console=tty0 console=ttyS0" |
1 | virsh console xxx # 进入指定的虚拟机,进入的时候还需要按一下回车 |