Saturday, February 8, 2020

OS Backup of EXADATA System - Backup Your Filesystem Before Patching

OS Backup of EXADATA System

Creating a Snapshot-Based Backup of Oracle Linux Database Server with Uncustomized Partitions

http://docs.oracle.com/cd/E80920_01/DBMMN/maintaining-exadata-database-servers.htm#DBMMN21377

We do Exadata patching regularly and one of the best practice is that we should always take successful root and /u01 file system backup before any patching.

In case if the patching fails and we are unable to rollback or recover the node back to its previous position in that case these backups will helps in restoring them back to its original state.

Steps:

mkdir -p /root/tar

mount -t nfs -o rw,intr,soft,proto=tcp,nolock 192.168.1.1:/export/Prod-IB-2/backup2/DB_Server_OSBackup/ /root/tar

imageinfo

Kernel version: 4.1.12-61.28.1.el6uek.x86_64 #2 SMP Tue Dec 20 16:51:49 PST 2016 x86_64
Image kernel version: 4.1.12-61.28.1.el6uek
Image version: 12.2.1.1.0.170126.2
Image activated: 2017-03-31 10:55:02 -0400
Image status: success
System partition on device: /dev/mapper/VGExaDb-LVDbSys1

dbnode2:(root)-lvs -o lv_name,lv_path,vg_name,lv_size
  LV                       Path                                  VG      LSize 
  LVDbOra1                 /dev/VGExaDb/LVDbOra1                 VGExaDb 1000.00g
  LVDbSwap1                /dev/VGExaDb/LVDbSwap1                VGExaDb   24.00g
  LVDbSys1                 /dev/VGExaDb/LVDbSys1                 VGExaDb   30.00g
  LVDbSys2                 /dev/VGExaDb/LVDbSys2                 VGExaDb   30.00g
  LVDbVdDBNODE2DBFS_DG /dev/VGExaDb/LVDbVdDBNODE2DBFS_DG VGExaDb  128.00m
  LVDoNotRemoveOrUse       /dev/VGExaDb/LVDoNotRemoveOrUse       VGExaDb    1.00g

dbnode2:(root)-lvcreate -L1G -s -c 32K -n root_snap /dev/VGExaDb/LVDbSys1
  Logical volume "root_snap" created.

dbnode2:(root)- lvs -o lv_name,lv_path,vg_name,lv_size
  LV                       Path                                  VG      LSize 
  LVDbOra1                 /dev/VGExaDb/LVDbOra1                 VGExaDb 1000.00g
  LVDbSwap1                /dev/VGExaDb/LVDbSwap1                VGExaDb   24.00g
  LVDbSys1                 /dev/VGExaDb/LVDbSys1                 VGExaDb   30.00g
  LVDbSys2                 /dev/VGExaDb/LVDbSys2                 VGExaDb   30.00g
  LVDbVdDBNODE2DBFS_DG /dev/VGExaDb/LVDbVdDBNODE2DBFS_DG VGExaDb  128.00m
  LVDoNotRemoveOrUse       /dev/VGExaDb/LVDoNotRemoveOrUse       VGExaDb    1.00g
  root_snap                /dev/VGExaDb/root_snap                VGExaDb    1.00g

dbnode2:(root)-e2label /dev/VGExaDb/root_snap DBSYS_SNAP

dbnode2:(root)-lvs -o lv_name,lv_path,vg_name,lv_size   
  LV                       Path                                  VG      LSize 
  LVDbOra1                 /dev/VGExaDb/LVDbOra1                 VGExaDb 1000.00g
  LVDbSwap1                /dev/VGExaDb/LVDbSwap1                VGExaDb   24.00g
  LVDbSys1                 /dev/VGExaDb/LVDbSys1                 VGExaDb   30.00g
  LVDbSys2                 /dev/VGExaDb/LVDbSys2                 VGExaDb   30.00g
  LVDbVdDBNODE2DBFS_DG /dev/VGExaDb/LVDbVdDBNODE2DBFS_DG VGExaDb  128.00m
  LVDoNotRemoveOrUse       /dev/VGExaDb/LVDoNotRemoveOrUse       VGExaDb    1.00g
  root_snap                /dev/VGExaDb/root_snap                VGExaDb    1.00g

mount -l
/dev/mapper/VGExaDb-LVDbSys1 on / type ext4 (rw) [DBSYS]
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,size=773919m)
/dev/sda1 on /boot type ext4 (rw,nodev) [BOOT]
/dev/mapper/VGExaDb-LVDbOra1 on /u01 type ext4 (rw,nodev) [DBORA]
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
dbnode2:(root)-/zfs-10G/orabknp2

dbnode2:(root)- mkdir /root/mnt

dbnode2:(root)- mount /dev/VGExaDb/root_snap /root/mnt -t ext4

dbnode2:df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VGExaDb-LVDbSys1
                       30G  9.9G   19G  36% /
tmpfs                 756G   87M  756G   1% /dev/shm
/dev/sda1             488M   29M  424M   7% /boot
/dev/mapper/VGExaDb-LVDbOra1
                      985G   38G  907G   4% /u01
192.168.1.1:/export/Nprod-10g-2/backup2/
                      181T     0  181T   0% /root/tar
/dev/mapper/VGExaDb-root_snap
                       30G  9.8G   19G  36% /root/mnt

dbnode2:(root)- lvcreate -L5G -s -c 32K -n u01_snap /dev/VGExaDb/LVDbOra1
  Logical volume "u01_snap" created.

dbnode2:(root)-/zfs-10G/orabknp2
lvs -o lv_name,lv_path,vg_name,lv_size
  LV                       Path                                  VG      LSize 
  LVDbOra1                 /dev/VGExaDb/LVDbOra1                 VGExaDb 1000.00g
  LVDbSwap1                /dev/VGExaDb/LVDbSwap1                VGExaDb   24.00g
  LVDbSys1                 /dev/VGExaDb/LVDbSys1                 VGExaDb   30.00g
  LVDbSys2                 /dev/VGExaDb/LVDbSys2                 VGExaDb   30.00g
  LVDbVdDBNODE2DBFS_DG /dev/VGExaDb/LVDbVdDBNODE2DBFS_DG VGExaDb  128.00m
  LVDoNotRemoveOrUse       /dev/VGExaDb/LVDoNotRemoveOrUse       VGExaDb    1.00g
  root_snap                /dev/VGExaDb/root_snap                VGExaDb    1.00g
  u01_snap                 /dev/VGExaDb/u01_snap                 VGExaDb    5.00g

dbnode2:(root)e2label /dev/VGExaDb/u01_snap DBORA_SNAP

dbnode2:mkdir -p /root/mnt/u01

dbnode2:(root): mount /dev/VGExaDb/u01_snap /root/mnt/u01 -t ext4

dbnode2: df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VGExaDb-LVDbSys1
                       30G  9.9G   19G  36% /
tmpfs                 756G   87M  756G   1% /dev/shm
/dev/sda1             488M   29M  424M   7% /boot
/dev/mapper/VGExaDb-LVDbOra1
                      985G   38G  907G   4% /u01
192.168.1.1:/export/Nprod-10g-2/backup2/
                      181T     0  181T   0% /root/tar
/dev/mapper/VGExaDb-root_snap
                       30G  9.8G   19G  36% /root/mnt
/dev/mapper/VGExaDb-u01_snap
                      985G   38G  907G   4% /root/mnt/u01

OS_Backup_root_backup.sh
#!/bin/ksh
CUR_DATE=`date '+%m%d%y-%H%M%S'`
export CUR_DATE
echo $CUR_DATE
HOST=`hostname cut -d'.' -f1`
export HOST
echo $HOST
cd /root/mnt
tar -pjcvf roottar${HOST}-os-bkp-root-${CUR_DATE}.tar.bz2   tmpbackup_root_${CUR_DATE}.stdout 2 tmpbackup_root_${CUR_DATE}tar.stderr

echo $CUR_DATE

OS_Backup_u01_backup.sh
#!/bin/ksh
CUR_DATE=`date '+%m%d%y-%H%M%S'`
export CUR_DATE
echo $CUR_DATE
HOST=`hostname |cut -d'.' -f1`
export HOST
echo $HOST
cd /root/mnt
tar -pjcvf /root/tar/${HOST}-os-bkp-u01-${CUR_DATE}.tar.bz2 * > /tmp/backup_u01_${CUR_DATE}.stdout 2> /tmp/backup_u01_${CUR_DATE}.stderr

echo $CUR_DATE

Run these shell scripts to take root and /u01 file system backup.

nohup sh OS_Backup_root_backup.sh &
nohup sh OS_Backup_u01_backup.sh &

dbnode2:(root)-/
>umount /root/mnt/u01

dbnode2:(root)-/
>df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VGExaDb-LVDbSys1
                       30G  9.9G   19G  36% /
tmpfs                 756G   87M  756G   1% /dev/shm
/dev/sda1             488M   29M  424M   7% /boot
/dev/mapper/VGExaDb-LVDbOra1
                      985G   65G  879G   7% /u01
192.168.1.1:/export/Nprod-10g-2/backup2/
                      181T   21G  181T   1% /root/tar

dbnode2:(root)-umount /root/mnt

dbnode2:(root)-rm -rf /root/mnt

dbnode1:(root)-lvs -o lv_name,lv_path,vg_name,lv_size
  LV                 Path                            VG      LSize 
  LVDbOra1           /dev/VGExaDb/LVDbOra1           VGExaDb 1000.00g
  LVDbSwap1          /dev/VGExaDb/LVDbSwap1          VGExaDb   24.00g
  LVDbSys1           /dev/VGExaDb/LVDbSys1           VGExaDb   30.00g
  LVDbSys2           /dev/VGExaDb/LVDbSys2           VGExaDb   30.00g
  LVDoNotRemoveOrUse /dev/VGExaDb/LVDoNotRemoveOrUse VGExaDb    1.00g
  root_snap          /dev/VGExaDb/root_snap          VGExaDb    1.00g

dbnode1:(root)-lvremove /dev/VGExaDb/root_snap
Do you really want to remove active logical volume root_snap? [y/n]: y
  Logical volume "root_snap" successfully removed

dbnode1:(root)-lvs -o lv_name,lv_path,vg_name,lv_size
  LV                 Path                            VG      LSize 
  LVDbOra1           /dev/VGExaDb/LVDbOra1           VGExaDb 1000.00g
  LVDbSwap1          /dev/VGExaDb/LVDbSwap1          VGExaDb   24.00g
  LVDbSys1           /dev/VGExaDb/LVDbSys1           VGExaDb   30.00g
  LVDbSys2           /dev/VGExaDb/LVDbSys2           VGExaDb   30.00g
  LVDoNotRemoveOrUse /dev/VGExaDb/LVDoNotRemoveOrUse VGExaDb    1.00g


dbnode2:(root)-lvremove /dev/VGExaDb/u01_snap
Do you really want to remove active logical volume u01_snap? [y/n]: y
  Logical volume "u01_snap" successfully removed

dbnode2:(root)-lvremove /dev/VGExaDb/root_snap
Do you really want to remove active logical volume root_snap? [y/n]: y
  Logical volume "root_snap" successfully removed

dbnode2:(root)-lvs -o lv_name,lv_path,vg_name,lv_size
  LV                       Path                                  VG      LSize 
  LVDbOra1                 /dev/VGExaDb/LVDbOra1                 VGExaDb 1000.00g
  LVDbSwap1                /dev/VGExaDb/LVDbSwap1                VGExaDb   24.00g
  LVDbSys1                 /dev/VGExaDb/LVDbSys1                 VGExaDb   30.00g
  LVDbSys2                 /dev/VGExaDb/LVDbSys2                 VGExaDb   30.00g
  LVDbVdDBNODE2DBFS_DG /dev/VGExaDb/LVDbVdDBNODE2DBFS_DG VGExaDb  128.00m
  LVDoNotRemoveOrUse       /dev/VGExaDb/LVDoNotRemoveOrUse       VGExaDb    1.00g

dbnode2:(root)-umount /root/tar

dbnode2:(root)-lvs -o lv_name,lv_path,vg_name,lv_size
  LV                       Path                                  VG      LSize 
  LVDbOra1                 /dev/VGExaDb/LVDbOra1                 VGExaDb 1000.00g
  LVDbSwap1                /dev/VGExaDb/LVDbSwap1                VGExaDb   24.00g
  LVDbSys1                 /dev/VGExaDb/LVDbSys1                 VGExaDb   30.00g
  LVDbSys2                 /dev/VGExaDb/LVDbSys2                 VGExaDb   30.00g
  LVDbVdDBNODE2DBFS_DG /dev/VGExaDb/LVDbVdDBNODE2DBFS_DG VGExaDb  128.00m
  LVDoNotRemoveOrUse       /dev/VGExaDb/LVDoNotRemoveOrUse       VGExaDb    1.00g

dbnode2:(root)-df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VGExaDb-LVDbSys1
                       30G  9.9G   18G  36% /
tmpfs                 756G   87M  756G   1% /dev/shm
/dev/sda1             488M   29M  424M   7% /boot
/dev/mapper/VGExaDb-LVDbOra1
                      985G   65G  879G   7% /u01
dbnode2:(root)-/

Regards,
Mallik

No comments:

Post a Comment

Query taking more time?  1. DML Query (Insert, Update,) Cause: locks / deadlocks  Fix/Solution: kill / Ask user to do commit/rollback   2. S...