Friday, January 18, 2013

How to Configure RMAN & Archive Backup


Legato Backup Setup & Rman Archive Backup
Configure backup in new server , Please add the backup server ip on /etc/hosts
[oracle@svrqatdb ~]$  cat /etc/hosts
127.0.0.1       localhost.localdomain   localhost
::1     localhost6.localdomain6 localhost6
#New Networker Storage Nodes
60.111.69.69    svrlegat-dz2
60.111.69.66    svrlegat-dz2-node1

Step 1: Install RPM’s fro Legato  with root user .
RPM’s :     lgtoclnt-7.5.2-1 x86_64
                lgtonmo-5.0-1 x86_64
lgtoman-7.5.2-1 x86_64
libXp-1.0.0-8.1.el5 i386
libXp-1.0.0-8.1.el5 x86_64
libXpm-3.5.5-3 x86_64
openmotif-2.3.1-2.el5_4.1 x86_64
netpbm-10.35.58-8.el5
system-config-network-tui-1.3.99.18-1.0.1.el5
system-config-network-1.3.99.18-1.0.1.el5
xinetd-2.3.14-10.el5
NetworkManager-0.7.0-10.el5
netpbm-progs-10.35.58-8.el5
net-tools-1.60-81.el5
telnet-0.17-39.el5
NetworkManager-glib-0.7.0-10.el5
NetworkManager-gnome-0.7.0-10.el5
gnome-netstatus-2.12.0-5.el5
system-config-netboot-0.1.45.1-1.0.1.el5
system-config-netboot-cmd-0.1.45.1-1.0.1.el5
NetworkManager-0.7.0-10.el5
NetworkManager-glib-0.7.0-10.el5
net-snmp-libs-5.3.2.2-9.el5


Step 2: if the installation is successful please verify
[oracle@svrqatdb ~]$ rpm -aq --queryformat '%{NAME}-%{VERSION}-%{RELEASE} %{ARCH}\n' |grep lgto
lgtoclnt-7.5.2-1 x86_64
lgtonmo-5.0-1 x86_64
lgtoman-7.5.2-1 x86_64
[oracle@ svrqatdb ~]$ rpm -aq --queryformat '%{NAME}-%{VERSION}-%{RELEASE} %{ARCH}\n' |grep libXp
libXp-1.0.0-8.1.el5 i386
libXp-1.0.0-8.1.el5 x86_64
libXpm-3.5.5-3 x86_64
[oracle@ svrqatdb ~]$ rpm -aq --queryformat '%{NAME}-%{VERSION}-%{RELEASE} %{ARCH}\n' |grep openmotif
openmotif-2.3.1-2.el5_4.1 x86_64
[oracle@mrlanslxdbsblprd01 lib]$ rpm -aq |grep -i net
netpbm-10.35.58-8.el5
system-config-network-tui-1.3.99.18-1.0.1.el5
system-config-network-1.3.99.18-1.0.1.el5
xinetd-2.3.14-10.el5
NetworkManager-0.7.0-10.el5
netpbm-progs-10.35.58-8.el5
net-tools-1.60-81.el5
telnet-0.17-39.el5
NetworkManager-glib-0.7.0-10.el5
NetworkManager-gnome-0.7.0-10.el5
gnome-netstatus-2.12.0-5.el5
system-config-netboot-0.1.45.1-1.0.1.el5
system-config-netboot-cmd-0.1.45.1-1.0.1.el5
NetworkManager-0.7.0-10.el5
NetworkManager-glib-0.7.0-10.el5
net-snmp-libs-5.3.2.2-9.el5

Step 3:
[oracle@ svrqatdb ~]$
[oracle@ svrqatdb sbin]$ vi  nsrnmo
#!/bin/ksh
#
# Sample:
#
ORACLE_HOME=/u01/app/oracle/db/tech_st/11.1.0
# Samples:
#
PATH=/usr/sbin:/nsr/bin:/bin
# Samples:
#       ORACLE_SID=orcl10g
#
ORACLE_SID=SVRQAT

# NSR_RMAN_ARGUMENTS=/home/oracle/logs/rmanmsglog.log
# Samples:
#
NSR_SB_DEBUG_FILE=/home/oracle/logs/nsrnmostart.log

# Optional variable: TNS_ADMIN
# Samples:
        TNS_ADMIN=/u01/app/oracle/db/tech_st/11.1.0/network/admin/SVRQAT_ svrqatdb


 [oracle@ svrqatdb ~]$ps -eaf|grep nsr
root      2696     1  0 Jan10 ?        00:00:00 /usr/sbin/nsrexecd

If above is not running, start it as oracle user
/etc/init.d/networker stop/start

[oracle@ svrqatdb ~]$ cd $ORACLE_HOME/lib
[oracle@ svrqatdb lib]$ ln -s /usr/lib/libnwora.so libobk.so

Step 5:

[oracle@ svrqatdb ~]$  rpm -qa | grep lgto
lgtonmo-5.0-1
lgtoclnt-7.5.2-1
lgtoman-7.5.2-1

[oracle@ svrqatdb applogs]$ls –ltr /nsr/applogs/nsrorara.log
total 18128
-rw-r--r-- 1 root   root           0 Jun 3  2010 nsrorara.log

Step 6: nsrnmoadmin  The command must be run as root
[root@ svrqatdb ~]$ nsrnmoadmin -r list

[oracle@ svrqatdb ~]$ nsrnmoadmin -r add sid=GRCUAT  home=/u01/app/db/11.1.0  connect=/u01 tns=/u01/app/db/11.1.0/network/admin
Note: For EBS TNS_ADMIN is mandatory also uncommment it in function export_environment_variables

[root@ svrqatdb ~]$ cd /nsr/res/
[root@ svrqatdb res]$ ls -ltr nwora.res
-rw-r--r-- 1 root root 2154 Apr 18  2011 nwora.res
Note: to verify the detail on nwora.res

This was resolved by creating directory /nsr/tmp/nwora/ 

[root@ svrlegat-dz2 ~]$ cd /nsr/tmp/nwora/
[root@ svrqatdb nwora]$ ls -ltr
total 4
-rwxrwxrwx 1 root root 0 Oct 28  2010 nwora.res.lck


Step 7: To restart the network with root user
[root@ svrqatdb  ~] cd /etc/init.d
[root@ svrqatdb init.d]./networker start
[root@ svrqatdb init.d]$ ps -eaf |grep nsrexecd
root      3016     1  0  2010 ?        00:14:17 /usr/sbin/nsrexecd

Test an backup to tape
run {
        allocate channel ch1 type 'sbt_tape';
        allocate channel ch2 type 'sbt_tape';
        send 'NSR_ENV=(NSR_SERVER=svrlegat-dz,NSR_CLIENT= svrqatdb,NSR_DATA_VOLUME_POOL=svr dqs db)';
                backup spfile;
        release channel ch1;
        release channel ch2;
}



Cronjobs:

# Archive backup script
00,36 * * * * /bin/sh  /home/oracle/scripts/arch_backup.sh 50
++++++++ script ++++ arch_backup.sh +++++++
#!/bin/bash
source /home/oracle/.bash_profile

used_sp=`df -TH /archivelogs | grep % | awk {'print $5'} | sed '$!d' | sed 's/%//g'`
echo "Used space for the archive log destination FS is ${used_sp}%"  > /tmp/arch_back_`date +%F`.log

if [ $used_sp -gt $1 ];then
echo "Archive log destination FS usage is above threshold"  >> /tmp/arch_back_`date +%F`.log
echo "Starting Archivelog Backup"  >> /tmp/arch_back_`date +%F`.log

rman << EOF  >> /tmp/arch_back_`date +%F`.log
connect target /
run {
        allocate channel ch1 type 'sbt_tape';
        allocate channel ch2 type 'sbt_tape';
        send 'NSR_ENV=(NSR_SERVER=svrlegat-dz,NSR_CLIENT=svrqatdb-bk,NSR_DATA_VOLUME_POOL=svr dqs db)';
        crosscheck archivelog all;
        backup archivelog all delete input;
        release channel ch1;
        release channel ch2;
}
EOF


echo "Archive backup Completed" >> /tmp/arch_back_`date +%F`.log
#/bin/mailx -s "${ORACLE_SID} Archive backup completed " svradmins.nar@singiri.com < /tmp/arch_back_`date +%F`.log
else
echo "Archive backup was not initiated as archivelog mount point usage is less than ${1}%." >> /tmp/arch_back_`date +%F`.log
fi

++++++++++++++
run {
        allocate channel ch1 type 'sbt_tape';
        allocate channel ch2 type 'sbt_tape';
        send 'NSR_ENV=(NSR_SERVER=svrlegat-dz,NSR_CLIENT=svrqatdb-bk,NSR_DATA_VOLUME_POOL=svr dqs db)';
        backup archivelog like '/u01/app/oracle/archivelogs/RMAN/SVRQAT_1_269%' delete all input;
        release channel ch1;
        release channel ch2;
}

+++++++++++++++
connect target sys/sysprd@ANSMK4
run {
  allocate channel t1 type 'sbt_tape' ;
  allocate channel t2 type 'sbt_tape' ;
    sql 'alter system checkpoint';
  sql 'alter system archive log current';
  change archivelog all validate;
  backup (archivelog all not backed up 1 times format='al_%d_%t_%s_%p' );
  delete archivelog until time 'sysdate-(1/24)' backed up 1 times to device type sbt;
#  delete noprompt archivelog until time 'sysdate-1' backed up 1 times to device type sbt;
  release channel t1;
  release channel t2;
  }

+++++++++++++++++
run {
        allocate channel ch1 type 'sbt_tape';
        allocate channel ch2 type 'sbt_tape';
    send 'NSR_ENV=(NSR_SERVER=svrlegat-dz,NSR_CLIENT=svrqatdb-bk,NSR_DATA_VOLUME_POOL=svr dqs db)';
        BACKUP ARCHIVELOG FROM SEQUENCE 1250 until SEQUENCE 1252 THREAD 1 DELETE INPUT;
        release channel ch1;
        release channel ch2;
}

+++++++++++++++ This is to delete archives that are already shipped & applied to DR.
run {
  allocate channel t1 type 'sbt_tape' ;
  allocate channel t2 type 'sbt_tape' ;
  allocate channel t3 type 'sbt_tape' ;
  delete noprompt archivelog until sequence 9669 backed up 1 times to device type sbt;
  release channel t1;
  release channel t2;
  release channel t3;
}

+++++++++++++++++++Restore archives +++++++++++++++
run
{
allocate channel t1 type 'sbt_tape' ;
allocate channel t2 type 'sbt_tape' ;
send 'NSR_ENV=(NSR_SERVER=marlgto-dz2,NSR_CLIENT=svrproddb-bk,NSR_DATA_VOLUME_POOL=svr prd)';
restore archivelog from sequence 5323 until sequence 5357;
release channel t1;
release channel t2;
}
+++++++++++ rman_archive_backup.rman +++++++++++++++
run {
  allocate channel t1 type 'sbt_tape' ;
  allocate channel t2 type 'sbt_tape' ;
  allocate channel t3 type 'sbt_tape' ;
  sql 'alter system checkpoint';
  sql 'alter system archive log current';
  change archivelog all validate;
  backup (archivelog all not backed up 1 times format='al_%d_%t_%s_%p' );
  delete noprompt archivelog until time 'sysdate-1' backed up 1 times to device type sbt;
  release channel t1;
  release channel t2;
  release channel t3;
}
++++++++++++++++++++++

run {
        allocate channel ch1 type 'sbt_tape';
           send 'NSR_ENV=(NSR_SERVER=svrlegat-dz,NSR_CLIENT=svrqatdb-bk,NSR_DATA_VOLUME_POOL=svr qat db)';
        backup as compressed backupset archivelog all format ='al_%d_%I_%T_%s_%e_regular' ;
        delete noprompt archivelog until time 'sysdate-1/8' backed up 1 times to device type sbt;
        release channel ch1;
}
#########################################################################

No comments:

Post a Comment