KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management

Contents:
(1.1) virtualization Introduction
(1.2) KVM introduction and installation
(1.3) guestos install and manage virtual machines
(1.4) use scripts to automate deployment vm
(1.5) Example: HA environment quickly erected


(1.1) virtualization description
(1.1.1) In the early days, not virtualized environment, our services are run directly on a physical machine. In fact, we expect each service to have its own operating environment, its own CPU memory and other resources, without disturbing each other, for example, we run the MySQL service on a server, as a SQL statement error, there have been massive consumption of IO resources, lead to other services on the same physical machine can not run, so we hope the resources between the various services are isolated from each other.
For server architecture under our traditional virtualization is not the case, the bottom is the physical hardware, followed by a layer of OS is the operating system layer, and then further on is the app service application layer, which is the traditional model of running a server, this If we have other services, you need to customize a single physical machine deployment of other services, the problem arises that we will find daily consumption per physical machine, for example, only about 10% of the CPU resource consumption, bringing a great waste of hardware resources. KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
To alleviate this problem, improve the efficiency of resource use, we started using virtualization technology, virtualization technology architecture generally, the bottom is the hardware layer, layer up is the operating system OS layer, and then further on what we run each virtual machine, each virtual machine we call guestos, for guestos architecture is the hardware layer, the operating system OS layer, such as three-tier app service application layer.
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
In general CPU instruction execution time will be divided into ringe3, ringe2, ringe1, ringe0 four-level, is where the user instructs ringe3 level, i.e. application instruction, and generally for sensitive ringe0 instruction command, the user is can not issue such a directive, only the kernel will be issued ringe0-level instructions to the CPU. Now we jump to the virtual machine level, but also within a virtual machine out of the virtual hardware layer, there will be a case of sending ringe0 level instruction, but because the virtual machine is working in user space, can only send ringe3 level instructions, it is impossible to send ringe0 level of instruction, so in this case the virtual machine is unable to send ringe0 instructions, this situation which also led to the virtual machine can not work properly. So early because the behavior of the CPU, has led to virtualization is not possible. In 1998 vmware has developed a new technology bt technology, bt technical instruction is the binary conversion technology will convert a virtual machine to a physical CPU to perform, will perform a physical machine after the implementation of the results returned to the virtual machine, this makes the virtual machine's CPU ringe0-level instructions can be executed in user space.
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
When (1.1.2) We use # grep name / proc / cpuinfo cpu command to query information can be found consistent cpu cpu information is information of the virtual machine and a physical machine.
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.1.3) The so-called virtual machine, is an example of some kind of virtualization products created specifically guestos, and the like vmware workstation it is a virtualization product, is a management system to manage each virtual machine, the virtual virtual machine is a basic application. Classified according to the type of virtualization, divided into full virtualization, paravirtualization and hardware-assisted virtualization into three categories.
(1.1.4) The first fully virtualized types of hardware are simulated, because the hardware is analog, so the runtime performance is relatively low, representative of this virtualization products are mainly vmware and virtualbox, due to the very performance low, not suitable for promotion, the company provides a set of tools vmware vmware tools, was able to improve the performance of virtual machines (Figure 1-5).
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.1.5) The second type of paravirtualization, access to real hardware, on our hardware layer, part of the operating system OS layer, the other part is vmm / hypervisor layer, we assume that the hardware resources and 100G hard drive 16G memory, and there is no virtual machine, this time from the OS layer point of view, the operating system is exclusive 100G and 16G hard disk memory resources, then we create two virtual machines on vmm / hypervisor layer, which is a virtual machine direct access to our hardware resources, each virtual machine using 4G memory and 20G hard drive, then assign the physical hardware will really come out related resources to the virtual machine, so this time we'll look at the OS layer will find operating system currently only 8G of memory and 60G hard drive can be used. One of our OS layer called domain-0, each virtual machine called domain-U, because the virtual machine is a direct access to hardware resources, so performance is very high, and because guestos need to access the hardware layer, so each guestos the core had to be modified, so guestos kernel options are open source, such as Linux, Unix and so on. And like Windows system because it is not open source operating system, the kernel can not be modified, so performance is polar, it is generally guestos kernel is Windows operating system will be installed in a paravirtualized drivers can relieve lower performance issues. Paravirtualization is representative of the type of Xen
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.1.6) The third type of hardware-assisted virtualization, virtualization functions of the CPU, so when we need to install the virtual machine must be turned physical machine's CPU virtualization capabilities. The hardware-assisted virtualization is represented by KVM, the above three categories is carried out according to the type of virtualization.
(1.1.7) according to the scope of use of virtualization are classified mainly into two categories: 1. virtualization products for personal use; 2 enterprise-class virtualization products.
Of which the individual virtualization products mainly include: vmware workstation, virtualbox. This type of framework virtualization products mainly for the lowest layer is the hardware layer, layer up OS operating system layer, the layer is then further vmm / hypervisor, then go down on the floor is a one guestos, and we usually seen vmware workstation, virtualbox belong vmm / hypervisor of this layer, in order to make relevant management and control (Figure 1-7) on the virtual machine we run.
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.1.8) enterprise-class virtualization products mainly include: vsphere, citrix, rhev. This type of virtual frame is the bottom product is the hardware layer, layer up is mounted vmm / hypervisor, and then further on a layer of a virtual machine layer is a station. Since there is no operating system layer, but rather mounted directly on the hardware is vmm / hypervisor layer, the conventional mounting method is installed via CD-ROM, U disk, or a network. For vmm / hypervisor layer of each vendor's product is different, if you are using the company's vsphere vmware virtualization products so vmm is ESXI, run it on a virtual machine is vmware; If you are using citrix company's virtualization products so vmm is xenserver, run it on a virtual machine is xen; If you are using Red Hat's virtualization products so rhev vmm is rhevh, run it on a virtual machine is KVM (Figure 1-8).
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.1.9) vmware workstation equivalent GUI client and vmm / hypervisor integrated together, for vsphere, it has created a vCenter, vmware vCenterServer provides a scalable, extensible platform, laid the foundation for virtualization management the foundation. vCenter vmware vsphere can be centrally managed environment compared to other management platforms, greatly enhancing the IT administrators control of virtual environments.


(1.2)KVM的介绍及安装
KVM的全称是Kernel-based Virtual Machine,它属于vmm/hypervisor,是虚拟机的管理器,属于内核的模块。KVM是一个开源的系统虚拟化模块,自Linux2.6.20之后集成在Linux的各个主要发行版本中。它使用Linux自身的调度器进行管理,所以相对于Xen,其核心源代码很少。目前KVM已经成为学术界的主流vmm之一。
(1.2.1)因为KVM属于内核模块,是内核空间的组成部分,用户是无法直接管理的,如果用户需要控制KVM那么就必须要使用对应的工具,早期使用的工具是qemu,它是一种模拟器(emulation),纯粹是模拟出来的,和物理硬件没有任何的关联性,qemu是用户空间的一个管理工具,结合KVM使用,随着后来的发展出现了qemu-kvm这样专门的管理工具。后来红帽公司基于qumu基础上开发出了一个libvirt的API程序,在这个API之上有很多的管理工具,例如openstack、rhev、virt-manager、virsh、virt-install、virt-view,其中libvirt不仅可以管理KVM,还可以管理qemu,例如使用openstack管理虚拟机的时候,就是使用libvirt管理qemu,同样也是可以使用libvirt管理KVM的,所以当我们的libvirt服务没有启动起来,那么是无法创建虚拟机的,因此我们需要保证libvirtd服务一直处于正常运行的状态。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.2.2)我们目前使用的是vmware workstation模拟物理机,在vmware中在创建所需的KVM虚拟机,这是一种嵌套虚拟化,由于KVM属于硬件辅助虚拟化,所以必须要开启CPU的支持。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.2.3)接着我们在vms002主机上将KVM安装起来,首先在vms002主机上查询可以安装的包virtual,接着使用yum将virtual软件包使用groupinstall方式安装起来。此时我们重启系统后使用# egrep '(vmx|svm)' /proc/cpuinfo查询到当前环境的cpu虚拟化支持已经启用了。并且发现此时libvirtd服务已经正常的启动了,且自动设置了开机自动启动。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.2.4)接着我们介绍相关管理KVM的工具,在xshell中我们我们使用软件自带的传输方式将Windows物理机中的rhel7.1的镜像传到vms002虚拟机上,使用快捷键Ctrl+Alt+F(ctrl+alt+f)。并在.bash_profile文件中的环境变量处添加qemu-kvm可执行命令的路径,使得系统可以执行qemu-kvm命令。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.2.5)接着我们准备创建一个虚拟机出来,①首先为这个虚拟机创建一个硬盘文件,②接着创建一个虚拟机,使用刚刚创建出来的这个硬盘文件。KVM生成的文件格式一般为raw和qcow2,vmware生成的文件格式一般为vmdk,virtualbox生成的文件格式一般为vdi,Xen生成的文件格式一般为raw和qcow2。使用命令# qemu-img create -f qcow2 test.qcow2 8G,此时我们便创建了一个8G的硬盘文件了。
注意:# qemu-img --help可以通过此命令查询帮助信息。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.2.6)我们使用-m命令指定所需要的内存的大小为512M,--smp指定的是启动的顺序,--boot order=cd指的是boot启动先从c(hard disk)启动,再从d(CD-ROM)启动,-cdrom指的是从我们所添加的光盘镜像开始启动,-hda指的是我们从哪块硬盘开始启动的。此时我们便创建了一个虚拟机,监听在本地回环接口的5900端口
注意:# qemu-kvm --help可以通过这个命令查询相关的帮助信息。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.2.7)此时我们保持vms002主机上创建的虚拟机一直运行,并打开另外一个连接vms002的终端去安装VNC软件。安装完毕后,便可以使用vnc连接到5900端口,此时便正常的连接到了虚拟机。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.2.8)随着我们在QEMU管理工具中开始安装操作系统,我们的虚拟机的硬盘文件的容量也开始逐渐增大了,虚拟机硬盘文件在/vdisk/目录下的test.qcow2文件中。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.2.9)对于生成的test.qcow2文件,我们也可以对虚拟机的硬盘文件进行压缩以节约空间资源,其中convert指的是类型转换,-c表示的是压缩,-O表示的是输出的格式,输出的文件名rhel7.img。此时我们使用压缩过的rhel7.img文件引导虚拟机,发现仍然是可以正常的引导起来的。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management


(1.3)guestos安装及管理虚拟机
(1.3.1)由于QEMU工具管理工具是传统的使用方式,使用起来非常的不方便,目前企业中通常使用的是libvirt这个API接口来管理虚拟机,在上层使用比较便捷的工具是virt-manager。(记住:要等qemu-kvm安装的虚拟机完成后在使用virt-manager)
注意:打开远端图形化界面的三个条件:①ssh -X;②服务器那边要有Xclient,同时也要安装了xorg-x11-xauth;③客户端需要运行Xserver
# yum list xauth*---查询图形化界面的安装软件包
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.2)我们选择本地镜像安装,内存大小选择512M。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.3)我们创建的硬盘大小选择8G即可,默认镜像文件的存放位置是在/var/lib/libvirt/images/目录当中的。如果我们想将镜像文件的位置改变,则可以选择“选择管理的或者其他现有存储”,此时如果我们存放的位置是在一个逻辑卷当中,那么以后就可以使用逻辑卷的快照功能对虚拟机做备份,那么备份的效率会非常的高。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.4)接着我们给虚拟机设置一个名称,在安装前自定义配置,并使用默认的网络设置。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.5)接着我们在Disk 1当中的磁盘总线选择VirtIO,这样虚拟机使用的便是半虚拟化技术,性能是非常高的,如果选择的是IDE或者其他的类型,那么使用的将是全虚拟化技术,会感觉到性能非常的低。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.6)接着NIC网卡的设备类型也要选择VirtIO,这样虚拟机使用的是半虚拟化技术,性能也是非常高的。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.7)我们的显示协议部分,选择的类型为VNC,Keymap要对应的选择en-us,这样我们的虚拟机的显示器部分才会显示正常,此时选择完毕后点击应用,便可以开始正常的安装了。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.8)此时我们一台虚拟机便已经创建了出来,并且在/var/lib/libvirt/images/目录下也产生了虚拟机的硬盘镜像文件了。通过控制台也可以方便的对虚拟机进行控制操作了。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.9)目前在我们vms002主机上的sda上划分一个分区用来创建逻辑卷node
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.10)接着我们在此逻辑卷上创建一个虚拟机node
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.11)并且设置好硬盘类型、网卡类型以及显示协议类型为VirtIO
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.12)此时我们安装的虚拟机就会开始安装在/dev/vg0/node逻辑卷中了
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.13)以上都是自己创建一个全新的虚拟机,其实我们也是可以通过导入已经安装好系统的虚拟机镜像来创建虚拟机的。我们将之前的压缩镜像rhel7.img拷贝到/var/lib/libvirt/images/目录。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.14)接着硬盘类型选择VirtIO、网卡的类型选择VirtIO、显示协议选择VNC且字符编码选择en-us
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.3.15)此时通过导入已有镜像快速创建虚拟机的方式便实现了。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management


(1.4)利用脚本自动部署vm
KVM的定制性能很强,使用虚拟机来自动部署主要有两类环境,1.第一种是使用光盘镜像安装在逻辑卷中;2.第二种是通过导入虚拟机已经安装好的镜像实现。
(1.4.1)对于使用光盘镜像安装在逻辑卷中的情形,我们是把已经安装好的虚拟机,作为一个模板,然后利用逻辑卷的快照功能部署虚拟机。首先通过# virsh list --all查看当前KVM中运行的虚拟机个数和状态,在/etc/libvirt/qemu/文件中存放着KVM虚拟机的配置文件
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.2)由于每个虚拟机的OS中都有自己独有的SID,所以对模板虚拟机需要进行重封装,首先进入到KVM中的node虚拟机中的/etc/sysconfig/network-scripts/目录中,并编辑ifcfg-eth0文件
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.3)在node的虚拟机中,将/etc/ssh/目录下的所有ssh_host_开头的文件全部删除,并将虚拟机关闭。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.4)接着在vms002主机上查询安装虚拟机重封装的软件包名,并将软件包安装起来。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.5)接着我们在vms002主机上使用命令# virt-sysprep -d node对虚拟机进行重封装的操作。因为我们node虚拟机是装在/dev/vg0/node这个逻辑卷中的,所以我们现在对node这个虚拟机所做的所有的操作,都会保存在逻辑卷里。我们在vms002主机上操作,创建一个node虚拟机的快照命名为node1,空间为2G。此时我们使用逻辑卷LVM的快照功能进行备份的操作便实现了,非常的方便。LVM逻辑卷快照备份
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.6)接着我们对虚拟机的配置文件进行复制,进入到/etc/libvirt/qemu目录中,复制node.xml为一个新的文件node1.xml,并对node1.xml配置文件进行编辑。并使用uuidgen随机生成一个新的UUID
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.7)接着在node1.xml配置文件中将如下独有的信息进行修改。接着在KVM的面板中创建node1虚拟机,并将虚拟机启动起来。
# virsh define node1.xml
# virsh start node1
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.8-1)故障排错:此时创建的node1虚拟机已经可以运行了,但是发现无法正常的登录系统,出现了grub>报错。此时我们将node1虚拟机关闭掉,然后将cdrom启用起来,并连接到rhel7.1.iso的光盘镜像。并且设置Boot Option中启用引导菜单选项。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.8-2)同时还要在grub界面执行如下的命令(可省)
# set root=(hd0,msdos1)
# linux16 /vmlinuz-3.10.0-229.el7.x86_64 ro root=/dev/vda1
# initrd16 /initramfs-3.10.0-229.el7.x86_64.img
# boot
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.9)故障排错:此时重启虚拟机发现通过F12可以进入到引导菜单了,接着选择Troubleshooting,并选择救援模式。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.10)故障排错:接着选择Continue,此时我们便进入到光盘镜像的系统中了,接着使用切换根的命令chroot,进入到/mnt/sysimage目录中,此为虚拟机操作系统所在的目录。
# chroot /mnt/sysimages
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.11)故障排错:接着在node1虚拟机中操作如下的命令,此时我们的系统就可以正常的启动起来了
# mount /dev/cdrom /mnt
# rpm -ivh /mnt/Packages/kernel-3.10.0-229.el7.x86_64.rpm --force
# grub2-mkconfig -o /boot/grub2/grub.cfg
# grub2-install /dev/vda
# vim /etc/sysconfig/selinux-----将SELinux值改为disabled
# exit
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.12)以后我们创建虚拟机的时候,可以将node虚拟机作为一个模板,例如在node虚拟机中创建一个/bin/aa.sh的脚本,使得开机的时候自动的运行系统所需的服务,例如在/etc/rc.d/rc.local中进行配置运行/bin/aa.sh。运行完一次后再运行# sed -i ‘/aa.sh/d’ /etc/rc.local将运行aa.sh脚本的条目删除掉,在node中把这样的一个设置写完后关机再保存成一个模板后,以后使用模板重启虚拟机时就都只会第一次运行aa.sh脚本,后面再重启都不会再运行这个aa.sh脚本了(参考虚拟机脚本.png)
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.13)此时我们看到执行完脚本后node1虚拟机便已经消失了
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.14)现在我们完成一个用脚本自动部署实例,首先我们将vms002系统还原到最初始的状态,然后将rh436_new.tar.gz文件解压。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.15)首先我们运行server.sh脚本将环境设置一下,然后执行reinstall.sh脚本便可以开始创建虚拟机了。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.4.16)我们已经正常的创建了第一台KVM虚拟机,然后我们按照同样的方式一共创建3台虚拟机。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management


(1.5)实例:快速搭建HA环境
(1.5.1)首先我们从vms002主机上连接到node1、node2、node3这三台虚拟机上,并在每台虚拟机上安装高可用集群软件
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.5.2)接着在node1、node2、node3虚拟机上将pcsd服务启动起来并设置开机自动启动。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.5.3)接着给三台虚拟机的高可用集群的用户设置密码,并对三台虚拟机的集群环境进行验证。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.5.4)接着在vms002主机上使用浏览器界面打开,使用https连接node1节点的2224端口。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.5.5)此时我们便可以使用高可用集群创建Nginx、MySQL等服务都是可以的。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.5.6)注意:我们也是可以使用如下的一些子命令进行具体设置的
# virsh --help |grep list
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.5.7)例如我们现在给node1虚拟机中添加一块硬盘,我们在/var/lib/libvirt/images/目录中创建一个node1-2.qcow2的硬盘。
# qemu-img create -f qcow2 node1-2.qcow2 2G
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.5.8)给node1虚拟机添加一块硬盘node1-2.qcow2,并且将添加的硬盘命名为vdb
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management
(1.5.9)如果需要删除指定的虚拟机上的一块硬盘,那么可以使用# virsh detach-disk node1 vdb命令。
KVM virtualization technology explain (a) - Virtualization introduces automated deployment and management

------ This concludes the article, thanks for reading ------

Guess you like

Origin blog.51cto.com/13613726/2460499