Exadata中的dbserver_backup.sh脚本

dbserver_backup.sh脚本在老版本的exadata中,它存放在/opt/oracle.SupportTools目录中,主要用于/根文件系统和/boot分区的备份。dbserver_backup.sh脚本是将/根文件的内容复制至另外一个大小与根分区完全一样的其它分区中。

随着Exadata软件版本的不断更新,dbserver_backup.sh脚本同时也包含在计算节点的升级工具中,通常计算节点升级前的检查阶段,会自动地调用dbserver_backup.sh脚本完成操作系统的备份工作。

 

dbserver_backup.sh脚本进行系统备份的前提条件:

1、计算节点的文件系统使用基于LVM的管理方式,除了/boot分区。

2、操作系统系统中应该存在一个大小与/ 根分区完全一致的其它分区,如果不存在这样一个分区,则vg中必须还有足够的剩余空间来创建这样的一个分区。

 

下面,我们来看看dbserver_backup.sh脚本的参数说明:

[root@ggdb01 11.2.3.2.1]# ./dbserver_backup.sh -h

 

Usage: ./dbserver_backup.sh [--backup-to-partition <1|2>] [-help], where options

 

no options - create backup of active /dev/mapper/VGExaDb-LVDbSys1 partition

on /dev/mapper/VGExaDb-LVDbSys2 partition

 

--backup-to-partition - either 1 or 2 (default). Overwrite default behavior. Create backup of active partition on the provided backup partition.

 

-help - print this info

 

[root@ggdb01 11.2.3.2.1]#

从以上的脚本参数说明,基本上也可以看出dbserver_backup.sh脚本的主要作用是将/dev/mapper/VGExaDb-LVDbSys1分区的数据备份至/dev/mapper/VGExaDb-LVDbSys2分区。

 

说明:

1、如果使用dbserver_backup.sh脚本进行系统备份,则必须先检查是否存在非本地文件系统,也即是否存在NFS文件系统,如果存在,则必须先umount掉NFS文件系统。否则备份会失败。

2、检查是否存在LVDbSys1和LVDbSys2两个分区,如果不存在LVDbSys2分区,则必须检查VG中是否有足够的剩余空间来备份操作系统。

3、操作系统中的LV命名,只允许存在两个以"LVDBSys "开头的LV,也即LVDBSys1和LVDBSys2。

 

(1)、手动直接调用dbserver_backup.sh脚本:

[root@dw01db01 ~]# chmod +x /u01/patches/linux_patches/p13741363_112321_Linux-x86-64/13741363/11.2.3.2.1/dbserver_backup.sh

[root@dw01db01 ~]# sh /u01/patches/linux_patches/p13741363_112321_Linux-x86-64/13741363/11.2.3.2.1/dbserver_backup.sh

以下信息是dbserver_backup.sh脚本备份生成的日志:

[INFO] Start to backup root /dev/VGExaDb/LVDbSys1 and boot partitions

[INFO] Check for Volume Group "VGExaDb"

[INFO] Check for the LVM root partition "VGExaDb/LVDbSys1"

[INFO] The active root partition /dev/VGExaDb/LVDbSys1 has proper label DBSYS

[INFO] The backup partition /dev/VGExaDb/LVDbSys2 has no label

[INFO] Root file system is mounted to /dev/mapper/VGExaDb-LVDbSys1

[INFO] LVM root partition size: 30.00G (62914560S)

[INFO] Total amount of free space: 202.80G (425304064S)

[INFO] Create spare root partition in Volume Group "VGExaDb"

Logical volume "LVDbSys2" created

[INFO] Create ext3 file system on spare root partition /dev/VGExaDb/LVDbSys2

[INFO] Mount spare root partition /dev/VGExaDb/LVDbSys2 to /mnt_spare

[INFO] Create LVM snapshot with 1Gb size of the root partition /dev/VGExaDb/LVDbSys1

Logical volume "LVDbSys1Snap" created

[INFO] Mount snapshot partition /dev/VGExaDb/LVDbSys1Snap to /mnt_snap

[INFO] Clone data from the snapshot to the spare root partition

………(略)

[INFO] Unmount snapshot partition /mnt_snap

[INFO] Remove snapshot partition /dev/VGExaDb/LVDbSys1Snap

Logical volume "LVDbSys1Snap" successfully removed

[INFO] Save partition table of /dev/sda in /mnt_spare/part_table_backup.txt

[INFO] Save lvm info in /mnt_spare/lvm_info.txt

[INFO] Unmount spare root partition /mnt_spare

[INFO] Backup of root /dev/VGExaDb/LVDbSys1 and boot partitions is done successfully

[INFO] Backup partition is /dev/VGExaDb/LVDbSys2

[INFO] /boot area back up named boot_backup.tbz (tar.bz2 format) is on the /dev/VGExaDb/LVDbSys2 partition.

[INFO] No other partitions were backed up. You may manually prepare back up for other partitions.

[root@dw01db02 oracle.SupportTools]#

从以上的日志我们可以看出,dbserver_backup.sh脚本其实也是利用Linux操作系统的LVM snapshot技术进行的/ 根文件系统备份,最后再将/boot文件系统中的数据备份成boot_backup.tbz文件放在LVDbSys2中。

 

(2)、升级工具调用dbserver_backup.sh脚本:

在计算节点升级工具的不断演变过程中,dbserver_backup.sh脚本也融合到计算节点的升级工具内,可以直接执行升级工具来调用dbserver_backup.sh脚本。

下面,我们以计算节点最新的升级工具patchmgr为例,展示计算节点的升级工具对dbserver_backup.sh脚本的调用。

[root@ggdb01 dbserver_patch_5.170123]# ./patchmgr -h

Usage:

./patchmgr -dbnodes <database_node_list_file>

-backup (yum_repo <baseurl> | -iso_repo <zipped_iso_file>) [-target_version version] [-rolling] [-unkey] |

-precheck (yum_repo <baseurl> | -iso_repo <zipped_iso_file>) [-target_version version] [-unkey] |

-upgrade (yum_repo <baseurl> | -iso_repo <zipped_iso_file>) [-target_version version] [-rolling] [-unkey] |

-rollback [-rolling] [-unkey]

-cleanup [-unkey]

 

MANDATORY PARAMETER

 

-dbnodes db_nodes_list_file

Specifies the name of the database node(s) list file. The file has one

hostname or ip per line.

 

ACTIONS

 

-backup

Perform backup only the database node(s) specified in the host list.

Runs backup in non-rolling fashion unless -rolling option is specified.

而查看patchmgr工具脚本,可以看出,真正进行升级工作的还是dbnodeupdate.sh升级工具,patchmgr工具脚本只是做了一些封装而已,继续查看dbnodeupdate.sh升级工具的代码。

#------------------------------------------------------------------------------

# PROCEDURE : PrepBackup

# INPUT :

# DESCRIPTION :

#------------------------------------------------------------------------------

PrepBackup()

{

local v_record_timings="No"

local v_func_call=${FUNCNAME}

DiaryEntry "${v_func_call}" "Enter" "${v_record_timings}" ${FUNCNAME}

 

v_to_release_maj=`echo ${v_to_release} 2>/dev/null | cut -d \. -f1-5`

# 24784563

# 24826294

 

# When image -ge 121233 we assume we can run dbserver_backup.sh from /opt/oracle.SupportTools

if [ ${v_current_image_id_maj} -ge 121233 ]

then

v_dbserver_backup_sh="/opt/oracle.SupportTools/dbserver_backup.sh"

if ! [ -f "${v_dbserver_backup_sh}" ]

then

# If the file is removed - then just grab the latest one shipping with the helpers

v_dbserver_backup_sh="${v_dbupdate_helpers_loc}/12.1.2.3.2/dbserver_backup.sh"

fi

else

# 24826294 - Images older than 121233 and newer or equal to 112310 can use the one shipping with helpers

if [ ${v_current_image_id_maj} -lt 121233 ] && [ ${v_current_image_id_maj} -ge 112310 ]

then

local v_current_image_version_maj=$(echo ${v_current_image_version} | cut -d \. -f1-5)

v_dbserver_backup_sh="${v_dbupdate_helpers_loc}/${v_current_image_version_maj}/dbserver_backup.sh"

else

if [ ${v_current_image_id_maj} -lt 112310 ]

then

# On 11.2.2.4.2 this script seems missing by default - this may happen on other older images.

# For those cases where this script is missing : just use the one from a release later

v_dbserver_backup_sh="${v_dbupdate_helpers_loc}/11.2.3.1.0/dbserver_backup.sh"

fi

fi

fi

从这部分代码可以看出,所有的计算节点升级工具,在升级前的操作系统备份工作都是调用的dbserver_backup.sh脚本。

posted @ 2017-02-19 22:30  石云华  阅读(512)  评论(0编辑  收藏  举报