![]() | c | ![]() | ![]() |
![](https://i-blog.csdnimg.cn/blog_migrate/200491d1ae6203cbdf7e02dca39a75b1.gif)
文档内容
适用于:Oracle Exalogic Elastic Cloud Software - 版本 2.0.4.0.0 和更高版本Linux x86-64 Oracle Virtual Server(x86-64) Guest vServers that are created using v2.0.4.0.0 and v2.0.6.x.x of the Exalogic Guest Base Template, or those upgraded to v2.0.6.x.x, both Oracle Linux v5.x and v6.x . The Guest vServers must have either an LVM-based system disk or an ext3-based system disk for the script and procedure to work. The script and procedure described in this document does not apply to Guest vServers that are running earlier versions of EECS (2.0.1.x.0). 目标目前,通过客户虚拟机创建模板通常使用Exalogic管理员手册中记录的步骤。该步骤可以在Exalogic管理员手册的附录中找到: 然而,由于手动的步骤很多,该流程繁琐且耗时。 本文档的目标旨在提供一个自动化脚本来完成客户虚拟机模板的创建过程。这里,客户虚拟机可以包含客户的定制化内容,例如:
除此之外,在以下用例中可能也需要创建客户虚拟机模板以达到快速重建虚拟机的目的:
解决方案使用现有客户虚拟机创建模板的步骤如下所示: 先决条件 1. 检查根目录(/)是否在基于LVM或ext3的系统盘上: a. 使用root账户登录至客户虚拟机。 b. 运行df –kH命令并找到根分区对应的文件系统。
[root@ext3VM ~]# df -kH
Filesystem Size Used Avail Use% Mounted on /dev/xvda2 4.5G 3.3G 1022M 77% / /dev/xvda1 99M 22M 73M 23% /boot tmpfs 2.0G 0 2.0G 0% /dev/shm /dev/xvdb 1008M 34M 924M 4% /vol 2号分区(p2)是本文所述脚本的默认分区。如果根目录的文件系统不在2号分区,则需要记录其对应的分区号,并在创建模板时使用-p选项来指定其对应的分区号。
[root@lvmVM ~]# df -kH
Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 7.4G 3.8G 3.3G 54% / tmpfs 2.1G 0 2.1G 0% /dev/shm /dev/xvda1 254M 55M 187M 23% /boot 这里需要记录下根目录对应的卷组名和逻辑卷名。如果他们的名字和默认名不同(卷组的默认名为VolGroup00,逻辑卷的默认名为LogVol00),在创建模板时需要使用-v和-l选项来指定其对应的卷组名和逻辑卷名。 c. 使用df -kH命令的输出获得以下子目录所对应的文件系统:
[partition_number],subdirectory,disk name
例如,如果目录/var/log存在于文件系统/dev/xvdb4,那么在文本文件上应记录为如下所示:
p4,/var/log,xvdb
如果目录/etc存在于文件系统/dev/xvdc(该文件系统在磁盘名后没有分区号),那么在文本文件上应记录为如下所示:
,/etc,xvdc
对于每个使用不同于根目录的LVM逻辑卷的子目录,在LVM对应的文本文件上使用以下格式记录(每个子目录一行):
Volume Group,Logical Volume,subdirectory
例如,如果目录/var/log存在于文件系统/dev/mapper/VolGroup01-LogVol00,那么在文本文件上应记录为如下所示:
VolGroup01,LogVol00,/var/log
流程 1. 使用EM Ops Center(EMOC)停止需要用来创建模板的客户虚拟机。 注意: 在执行创建模板的步骤前,必须要确保其对应的客户虚拟机已经停止了。如果创建模板时客户虚拟机仍在运行,使用该模板创建新的虚拟机时将会报错。
[root@elcontrol ~]# mkdir /OVS-Repo
[root@elcontrol ~]# mount -t nfs xx.xx.xx.xx:/export/ExalogicRepo /OVS-Repo -o ro where xx.xx.xx.xx is the IP address of the ZFS storage appliance on the IPoIB-storage network. This IP address is the same as that used for the ExalogicControl mount in the Exalogic Control vServer, and may be obtained by running the following command:
[root@elcontrol ~]# grep ExalogicControl /etc/fstab
xx.xx.xx.xx:/export/ExalogicControl /mnt/elcontrol nfs rw 0 0 4. 为了创建模板,还需要使用Exalogic客户虚拟机基础模板的vm.cfg文件。这里,首先拷贝Exalogic v2.0.4.0.0或v2.0.6.0.0 的模板文件(例如,v2.0.6.0.0模板的文件名为el_base_linux_guest_vm_template_2.0.6.0.0_64.tgz)至一个ZFS share(例如/common/images)并解压缩。之后,记录下vm.cfg文件所在的路径。
[root@elcontrol ~]# mkdir -p /u01/common/images
[root@elcontrol ~]# mount -t nfs 10.196.xx.xx:/shares/export/common/images /u01/common/images -o rw [root@elcontrol ~]# mkdir /u01/common/images/template_tmp
6. 拷贝附件中的脚本CreateTemplateFromVServerUniversal.sh至Exalogic控制虚拟机上root用户的home目录(/root)。
[root@gelcontrol ~]# ./CreateTemplateFromVServerUniversal.sh - -n <vServer Name>|-u <vServer UUID> [-r <Repository Directory>] [-w <Working Directory>] [-d <Destination Directory>] [-c <vm.cfg Location>] [-t <Root File System Type>] [-v <Volume Group of />] [-l <Logical Volume of />] [-p <ext3 Partition of />] [-addrootlvs <File Stating Additional LVM Systems>] [-addrootps <File Stating Additional ext3 Systems>] [-olver <ol Version>] [-log <Log File Location>] [-z | -Z]
其中: -n <vServer Name> 用来创建模板的虚拟机的名称。
注意:
[root@elcontrol ~]#./CreateTemplateFromVServerUniversal.sh -n dev-test-vServer -r /OVS-Repo -w /u01/common/images/template_tmp -d /u01/common/images/template -c /u01/common/images/EGBT_v20600/BASE/vm.cfg -Z
下例使用了一个基于ext3的v2.0.4.0.x的虚拟机来创建模板,该虚拟机的UUID为0004fb0000060000dd8468372041a19d:
[root@elcontrol ~]# ./CreateTemplateFromVServerUniversal.sh –u 0004fb0000060000dd8468372041a19d -r /OVS-Repo -w /u01/common/images/template_tmp -d /u01/common/images/template -c /u01/common/images/EGBT_v20400/BASE/vm.cfg -Z
8. 脚本运行后,结果模板将被创建在目标目录中,文件名为el_template_<vServer_Name>.tgz(如果使用了-n选项)或el_template_<vServer_UUID>.tgz(如果使用了-u选项)。
卸载之后,/OVS-Repo目录即可被删除。
重要提示: 本文所述之脚本并不是一个线程安全的程序。因此,不允许在同一系统中并行运行多个脚本进程。如果有多个虚拟机模板需要创建,则需要顺序地逐一进行。 参考NOTE:1594674.1 - Exalogic Virtual Environment - Guest vServer Upgrade to the latest Oracle Linux v5.x Versionhttp://docs.oracle.com/cd/E18476_01/doc.220/e25258/appendix.htm#BABFHAFD | ![]() |
![]()
|
![](https://i-blog.csdnimg.cn/blog_migrate/200491d1ae6203cbdf7e02dca39a75b1.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/200491d1ae6203cbdf7e02dca39a75b1.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/200491d1ae6203cbdf7e02dca39a75b1.gif)