Tuesday, May 9, 2017

Avamar customized backups


We are also using Avamar v7 to backup up the Linux file systems and the Oracle databases w/the RMAN plugin. I spent a few weeks with one of our DBAs thoroughly documenting the following processes:

Backup database & logs
Restore to same instance
Restore (DUPLICATE) to another (DEV/TEST) instance.

First, on each server, you'll need to make the avtar-flags.txt file. If you are backing up large databases (> 500GB), you'll want to utilize multiple RMAN channels to speed things up. Depending on the size of your database(s) and the number of channels, set the avtar-flags.txt "--hashcachemax=" directive appropriately (see EMC/Avamar docs for details). Also, if you are targeting a Data Domain unit, set these directives in the avtar-flags.txt file:

--ddr
--ddr-index=1

Here's a copy of my avtar-flags.txt file from a Linux (RHEL 5) server; note that this is targeting a Data Domain (using dd-boost, hence the --ddr line), and the databases being backed up are around 4TB (4,000 GB) and we use 4 RMAN channels, hence the --hashcachemax=2000:

--pidname=Oracle
--pidnum=1002
--logfile=/usr/local/avamar/var/clientlogs/avtar.log
--vardir=/var/avamar
--id=AVAMAR_BACKUP_USERNAME
--ap=AVAMAR_BACKUP_PASSWORD
--path=/linux_clients/HOSTNAME.EXAMPLE.COM
--expires=10
--ddr
--ddr-index=1
--enable-filecache=false
--hashcachemax=2000

IMPORTANT: make sure that the "oracle" user that runs the RMAN process has permission to read the avtar-flags.txt file, and also can write log and cache files into the "vardir" (/var/avamar in my case).

SETTING UP YOUR ENVIRONMENT:
"su - " to the oracle user that will execute RMAN; set your environment like so: (you may need to adjust the paths depending on your install):

# su - oracle-user
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/avamar/lib

We can now execute RMAN. (connect to target and catalog)

# rman
RMAN> connect target sys/SYS_PASSWORD
RMAN> connect catalog CAT_USER/CAT_PASSWORD@CATALOG

# -------------------------- TEST instance backup script - 4 channels ---------------------------

run{
allocate channel c1 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so ENV=(PATH=/bin:/usr/local/avamar/bin)";
allocate channel c2 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so ENV=(PATH=/bin:/usr/local/avamar/bin)";
allocate channel c3 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so ENV=(PATH=/bin:/usr/local/avamar/bin)";
allocate channel c4 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so ENV=(PATH=/bin:/usr/local/avamar/bin)";

send channel='c1' '"--flagfile=/usr/local/avamar/etc/avtar-flags.txt"
"--logfile=/var/avamar/c1_TEST_avoracle.log" "--bindir=/usr/local/avamar/bin"
"--cacheprefix=c1_TEST"';
send channel='c2' '"--flagfile=/usr/local/avamar/etc/avtar-flags.txt"
"--logfile=/var/avamar/c2_TEST_avoracle.log" "--bindir=/usr/local/avamar/bin"
"--cacheprefix=c2_TEST"';
send channel='c3' '"--flagfile=/usr/local/avamar/etc/avtar-flags.txt"
"--logfile=/var/avamar/c3_TEST_avoracle.log" "--bindir=/usr/local/avamar/bin"
"--cacheprefix=c3_TEST"';
send channel='c4' '"--flagfile=/usr/local/avamar/etc/avtar-flags.txt"
"--logfile=/var/avamar/c4_TEST_avoracle.log" "--bindir=/usr/local/avamar/bin"
"--cacheprefix=c4_TEST"';

crosscheck backup;
backup database;
crosscheck archivelog all;
backup archivelog all not backed up 1 times;

## Cleanup old backups and files:
## DELETE NOPROMPT ARCHIVELOG ALL;
## DO NOT DELETE ARCHIVELOG
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT OBSOLETE;

release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
exit;

# -------------------------- END OF TEST instance backup script - 4 channels ---------------------------
BE CAREFUL WITH QUOTES/DOUBLE QUOTES; IF YOU MISS ONE, RMAN WILL ERROR, BUT IT WILL NOT BE APPARENT WHAT THE ERROR WAS!!!

I'll post the recovery and clone instructions in another reply.


#################################



RESTORE TO SAME INSTANCE

Get the "dbid" of the database you are going to restore; your DBA will know how to do this. Setup your environment (see previous post) and execute RMAN, connecting to target & catalog; here is an example set of scripts to recover a dropped database that we had backed up; this uses 1 RMAN channel.

The idea is to 1st restore the controlfile, then restore the database, then recover it. Here's the example for an instance called "TEST" with a fictional "dbid" of 1234:

Single channel RMAN restore; instance name TEST, dbid=1234*.

*Note: 1234 is not an actual/valid DBID

---------------------------START RMAN TEST INSTANCE RECOVER SCRIPT-------------------

# Restore controlfile:

set dbid=1234;

run{
allocate channel c1 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so ENV=(PATH=/bin:/usr/local/avamar/bin)";

send channel='c1' '"--flagfile=/usr/local/avamar/etc/avtar-flags.txt"
"--logfile=/var/avamar/c1_TEST_avoracle.log" "--bindir=/usr/local/avamar/bin"’;

restore controlfile;
startup mount;
release channel c1;
}

# list backup;
# exit;

# Restore & Recover database; single channel:

run{
allocate channel c1 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so ENV=(PATH=/bin:/usr/local/avamar/bin)";

send channel='c1' '"--flagfile=/usr/local/avamar/etc/avtar-flags.txt"
"--logfile=/var/avamar/c1_TEST_avoracle.log" "--bindir=/usr/local/avamar/bin"’;

restore database;
recover database;
release channel c1;
}

alter database open resetlogs;
exit;

---------------------------END RMAN TEST INSTANCE RECOVER SCRIPT-------------------

See next post for cloning/duplicating an instance w/RMAN & Avamar using RMAN DUPLICATE syntax.


#######################################


CLONE AN INSTANCE - RESTORING A BACKUP TO A DIFFERENT INSTANCE:

This example is an instance clone/refresh of a backup taken on the same host.
We are restoring to instance "NEW" from backup of instance "TEST".
We are using ASM for our datafiles, and 2 RMAN channels.

So we'll connect to "NEW" using sqlplus, drop the database, and put it in "startup nomount", ready for a clone/restore.

"su - " to oracle user that has access to instance "NEW" and prepare the instance:

# Drop, Startup database:

sqlplus / as sysdba <
shutdown abort
startup mount restrict
REM drop database ;
shutdown abort
startup nomount
EOF


Set up your environment (see 1st reply), execute RMAN, connecting to target (TEST), aux (NEW) and catalog:

# rman target sys/SYS_PASSWORD@TEMP auxiliary / catalog CAT_USER/CAT_PASSWORD@CATALOG

DUPLICATE the backed up TEMP instance to NEW, renaming the files/paths (ASM in this example) appropriately.

----------------START RMAN DUPLICATE SCRIPT----------------

RUN {
ALLOCATE auxiliary channel x1 type sbt_tape PARMS 'SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so ENV=(PATH=/bin:/usr/local/avamar/bin)'
SEND '"--flagfile=/usr/local/avamar/etc/avtar-flags.txt" "--logfile=/var/avamar/x1_NEW_avoracle.log" "--bindir=/usr/local/avamar/bin"';
ALLOCATE auxiliary channel x2 type sbt_tape PARMS 'SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so ENV=(PATH=/bin:/usr/local/avamar/bin)'
SEND '"--flagfile=/usr/local/avamar/etc/avtar-flags.txt" "--logfile=/var/avamar/x2_NEW_avoracle.log" "--bindir=/usr/local/avamar/bin"';

DUPLICATE TARGET DATABASE TO NEW db_file_name_convert=('+ASMDISKGROUP/TEMP','+ASMDISKGROUP/NEW')
logfile group 1 ('+ASMDISKGROUP') size 1g,
        group 2 ('+ASMDISKGROUP') size 1g,
        group 3 ('+ASMDISKGROUP') size 1g,
        group 4 ('+ASMDISKGROUP') size 1g;
}


----------------END RMAN DUPLICATE SCRIPT----------------


Note: Merged SEND cmd into ALLOCATE cmd in the above example.
Note: The spfile must exist, and the db_name and db_unique_name and ORACLE_SID should all match.
Note: The avtar-flags file must be from the server where the source db was backed up from.


We run single instance and RAC environments and back them up without any special configurations, using the same methodology. We did NOT use the rac_config script for our RAC instances. For those, we always just backup/restore from 1 node, just like we would on a single instance host. Works fine.

For example, a 3 node RAC database consisting of node1.example.com, node2.example.com, and node3.example.com.

We install the Avamar client on all 3 servers and register them with the Avamar system for file system backups. Then on node1, we also install the AvamarRMAN plugin, and do the Oracle RMAN backups/restores from there.

Note that we schedule, initiate/control all backups/restores using RMAN on the Oracle servers; this way the DBAs control/schedule all backups & restores & and feel comfortable with this arrangement.

=====================================================================

run{
allocate channel c1 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so" format '%d_%T_%s_%U';
send channel 'c1' '"--prefix=11g/prodstby/" "--flagfile=/u02/backdir/avamarbkp.txt" "--cacheprefix=prodstby_c1" "--logfile=/usr/local/avamar/c1_avtar.log" "--bindir=/usr/local/avamar/bin"';
allocate channel c2 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so" format '%d_%T_%s_%U';
send channel 'c2' '"--prefix=11g/prodstby/" "--flagfile=/u02/backdir/avamarbkp.txt" "--cacheprefix=prodstby_c2" "--logfile=/usr/local/avamar/c2_avtar.log" "--bindir=/usr/local/avamar/bin"';
allocate channel c3 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so" format '%d_%T_%s_%U';
send channel 'c3' '"--prefix=11g/prodstby/" "--flagfile=/u02/backdir/avamarbkp.txt" "--cacheprefix=prodstby_c3" "--logfile=/usr/local/avamar/c3_avtar.log" "--bindir=/usr/local/avamar/bin"';
allocate channel c4 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so" format '%d_%T_%s_%U';
send channel 'c4' '"--prefix=11g/prodstby/" "--flagfile=/u02/backdir/avamarbkp.txt" "--cacheprefix=prodstby_c4" "--logfile=/usr/local/avamar/c4_avtar.log" "--bindir=/usr/local/avamar/bin"';
allocate channel c5 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so" format '%d_%T_%s_%U';
send channel 'c5' '"--prefix=11g/prodstby/" "--flagfile=/u02/backdir/avamarbkp.txt" "--cacheprefix=prodstby_c5" "--logfile=/usr/local/avamar/c5_avtar.log" "--bindir=/usr/local/avamar/bin"';
allocate channel c6 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so" format '%d_%T_%s_%U';
send channel 'c6' '"--prefix=11g/prodstby/" "--flagfile=/u02/backdir/avamarbkp.txt" "--cacheprefix=prodstby_c6" "--logfile=/usr/local/avamar/c6_avtar.log" "--bindir=/usr/local/avamar/bin"';
allocate channel c7 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so" format '%d_%T_%s_%U';
send channel 'c7' '"--prefix=11g/prodstby/" "--flagfile=/u02/backdir/avamarbkp.txt" "--cacheprefix=prodstby_c7" "--logfile=/usr/local/avamar/c7_avtar.log" "--bindir=/usr/local/avamar/bin"';
allocate channel c8 type sbt PARMS="SBT_LIBRARY=/usr/local/avamar/lib/libobk_avamar64.so" format '%d_%T_%s_%U';
send channel 'c8' '"--prefix=11g/prodstby/" "--flagfile=/u02/backdir/avamarbkp.txt" "--cacheprefix=prodstby_c8" "--logfile=/usr/local/avamar/c8_avtar.log" "--bindir=/usr/local/avamar/bin"';
backup as compressed backupset database section size 10000m;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
release channel c7;
release channel c8;
}

#########FLAG FILE ############


--server=192.168.6.151
--hashcachemax=8000
--pidname=oracle
--pidnum=1002
--bindir=/usr/local/avamar/bin
--vardir=/usr/local/avamar/var
--sysdir=/usr/local/avamar/etc
--id=prod@/prod_Servers
--ap=Pr0d123
--path=/Prod_Servers/proddbdr-scan.ortix.com/proddbdr-scan.ortix.com
--expires=7
--ddr
--ddr-index=1
--account=/Noor_Servers/proddbdr-scan.ortix.com/proddbdr-scan.ortix.com
--enable-filecache=false


No comments:

Post a Comment