SEP sesam Extension for Oracle

From SEPsesam
Jump to: navigation, search

Copyright © SEP AG 1999-2017. All rights reserved.

Any form of reproduction of the contents or parts of this manual is allowed only with the express written permission from SEP AG. When compiling and designing user documentation SEP AG uses great diligence and attempts to deliver accurate and correct information. However, SEP AG cannot issue a guarantee for the contents of this manual.

Introduction

The SEP sesam online module for Oracle/RMAN integrates Oracle Recovery Manager (RMAN) with SEP sesam to efficiently back up and restore Oracle databases. Oracle provides a Media Management Layer (MML) for saving Oracle databases to SEP sesam Server. The MML API gives the Recovery Manager (RMAN) access to the backup application.

For Oracle, SEP sesam represents a media management utility. It handles media and devices and loads, unloads and labels media. SEP sesam provides online backup and restore for Oracle target database(s).

RMAN manages the target database (the database containing the control files, data files and optional archived redo logs that are being backed up or restored) and all Oracle server processes on the target database.

Information sign.png Note
The procedures and features explained herein provide only information about the SEP sesam-specific parts of Oracle backup. For detailed information on Oracle-specific backup and recovery, see Oracle database documentation.

System Requirements

  • Check the list of supported versions. It is recommended to upgrade the SEP sesam Server and Client components to the latest version during the regular upgrade process.
  • Check the SEP sesam ORACLE Licensing Whitepaper for details on the licenses required.
  • Make sure that an installed Oracle server with a running Oracle application and database is available.
  • Install the SEP sesam Client package on the Oracle server. You can download it from SEP Download Center. For details, see SEP Sesam Quick Install Guide.
  • Verify that the SEP sesam file system backup process on the client is working and that data can be restored.
  • To perform Oracle online backup, the Oracle database must be running ARCHIVELOG mode.

The following are Oracle default installation settings. You can adjust the paths and variables according to your needs.

ORACLE SID=mydb
ORACLE BASE=/opt/oracle
ORACLE HOME=/opt/oracle/product/oracle
$ORACLE HOME/bin is in the search path

Installing the Oracle extension on an Oracle server

Prerequisite

  • Before installing the Oracle extension, make sure that a SEP sesam Client is already installed on the target Oracle server and that regular file system backup and restore were completed successfully.
  • If you have a SEP sesam Client version 4.4 installed, the library file libobk.so (Linux) or orasbt (Windows) will already be installed in the <sesam_install>/bin/sesam directory as a part of the client package. If you are using a SEP sesam Client version prior to 4.4, you will have to download the required extension from SEP sesam online backup modules for Oracle databases site.

Installing on Linux/Unix

  1. Login as Oracle user.
  2. Create a new directory sob in $ORACLE HOME.
  3. If you are using SEP sesam Client version 4.4, skip this step. If you are using an earlier SEP sesam Client version and have downloaded the required extension, unpack the file <OS> sob sesam-oracle-client<version>.tgz into the sob directory.
  4. Create a symbolic link in $ORACLE HOME/lib to the library file libobk.so, which resides in <sesam_install>/bin/sesam. If the file already exists, you must rename it.
oracle@oraclesrv:/> cd $ORACLE_HOME
oracle@oraclesrv:/product/oracle> mkdir sob
oracle@oraclesrv:/product/oracle> ln -s /opt/sesam/bin/sesam/libobk.so sob/
oracle@oraclesrv:/product/oracle> ln -s /opt/sesam/bin/sesam/libobk.so lib/

Installing on Windows

  1. Go to the <ORACLE HOME>\bin directory and rename the file orasbt.dll, if it exists.
  2. Copy the SEP sesam file orasbt.dll from the <sesam_install>/bin/sesam directory to the <ORACLE HOME>\bin directory.
  3. Encryption is enabled as of SEP sesam version 4.4.2. Copy msvcr90.dll, msvcr100.dll, cm_crypt.dll, libeay32.dll, ssleay32.dll and md5.dll from the <sesam_install>/bin/sesam directory to the <ORACLE HOME>\bin directory.

Creating an Oracle type backup task

For Oracle backups, the SEP sesam Server acts as a media manager. It handles media and provides scheduling, media management and monitoring for Oracle backups and restores. Oracle RMAN controls the Oracle server processes and is responsible for maintaining the information in the recovery catalog and control file for performing Oracle backups and restores.

To configure an Oracle database backup, you must first create a task for the Oracle client in the SEP sesam environment.

  1. From Main Selection -> Tasks -> By clients, select the Oracle client then click New backup task. The New backup task window opens.
  2. Enter the Task name. Give your task a meaningful and descriptive name (max. 15 letters) that clearly identifies it, for example orax10_DB-orcl.
  3. From the Backup type drop-down list, select Oracle.
  4. Under Source, enter the name of the Oracle database and click OK to create the task.
Oracle-Task3 en.jpg


Creating a schedule and SEP sesam command event

You can use SEP sesam scheduling to start the command sbc_oracle_rman.sh on the Oracle server remotely. You must first create a schedule.

  1. From Main Selection -> Scheduling -> Schedules, click New schedule. The Schedule window opens.
  2. Oracle-Backup-Schedule en3.jpg


  3. Configure your schedule and click OK.
  4. In the Schedule window, right-click the newly-created schedule and select New command event. The New task event window opens.
  5. Oracle-Backup-Command-Select en2.jpg


  6. Under the Execution parameter, click the List button. The Commands window opens. Create a new command by clicking the Create button and entering the appropriate values in the required fields (command name, client and command).
  7. Oracle-Backup-Command-Definition en2.jpg


    Name
    Name of the command event
    Command
    Enter the full command that will be executed on the Oracle server.
    Client
    Select the hostname of the Oracle server from the list.
    User
    Enter a username - the name of the user responsible for processing the command with his rights on the Oracle server.
  8. Click OK to save the command and confirm the new command event.
  9. Oracle-Backup-Command-Event-Complete en2.jpg

Setting remote command permissions

By default, the SEP sesam Server has no rights to execute commands remotely on a SEP sesam Client, e.g., on an Oracle server. You have to specify a user in the sesam_cmdusers_allow file to run a command. For details on Windows-specific configuration of command events, see How to configure a command event.

  1. To assign the proper permissions for executing commands, copy the file sesam_cmdusers_allow from the template directory of the SEP sesam Client to the /etc directory of the Oracle server.
  2. Example:

    cp /opt/sesam/skel/templates/sesam_cmdusers.allow /etc
    
  3. Edit the file to set the appropriate values. You will have to define the user that will execute the command, followed by the respective command.
  4. Example (referencing the example above):

    oracle /opt/oracle/product/10.2/db_1/sob/sbc_oracle_rman.sh
    

Embedding a plain-text password (optional)

To avoid entering a plain text password in the remote command, do one of the following:

  • Embed the password into the script sbc_oracle_rman.sh.
  • Instead of using SEP sesam command event, execute a RMAN backup script with modified environment variables (SESAM_SERVER, SESAM_JOB, etc.). Make sure that you are granted privileges to access the database. The backup command should be issued from the Oracle Enterprise Manager scheduler.

If the Oracle Recovery Catalog database is used, the calling parameters will not use the password of the Oracle database. In such an event, the sbc_oracle_rman.sh/.cmd will be called with the password of the RMAN user for the Recovery Catalog database.

Testing the Oracle extension using sbttest

You can check and diagnose the media management API with the help of the sbttest Oracle diagnostic tool. Functionality testing of libobk.so is carried out without interfering with running databases.

  1. Set the following environment variables:
    • SESAM SERVER=<Name of SEP sesam Server>
    • SESAM JOB=<Job name of Oracle backup> Name of an already configured task on SEP sesam Server with task type Oracle
    • SESAM POOL=<Media pool name> Name of an already configured media pool on SEP sesam Server
  2. Execute sbttest. The output should be similar to the one below.
oracle@oraclesrv:~/product/10g/lib> export SESAM_SERVER=backsrv
oracle@oraclesrv:~/product/10g/lib> export SESAM_JOB=oracle_test
oracle@oraclesrv:~/product/10g/lib> export SESAM_POOL=DISK
oracle@oraclesrv:~/product/10g/lib> sbttest test1 -trace sbttest.log
The sbt function pointers are loaded from libobk.so library.
-- sbtinit succeeded
-- sbtinit (2nd time) succeeded
Note: This SBT library does not handle version 2.0 of SBT.
sbtinit: Media manager is version 2.3.1.1
sbtopen for output successful
sbtwrite successful, wrote 100 buffers
sbtclose successful after sbtwrite
sbtinfo successful
file t1 is on volume 5:3
sbtopen for input successful
file was created by this program; seed=27600, bufsize=16384, bufcount=100
sbtread successful, read 100 buffers
sbtclose successful after sbtread
sbtremove successful
*** The SBT API test was successful ***

If the test fails, you can check SEP sesam-specific trace messages in sbttest.log.

Configuring the Oracle environment

Enabling ARCHIVELOG mode

To perform an online backup, the Oracle database must operate in ARCHIVELOG mode. Oracle recommends that you shut down the database and perform an offline backup to protect against any problems before switching from NOARCHIVELOG mode. This will be the final backup of the database in NOARCHIVELOG mode and can be used if anything goes wrong during the change to ARCHIVELOG mode.

To change the database archiving mode, you must be connected to the database with administrator privileges (AS SYSDBA).

  1. Start sqlplus from the console with Oracle database admin credentials. #> sqlplus "/as sysdba"
  2. Check the archiving online backup mode. #> select name, log_mode from v$database; NAME LOG_MODE --------- ------------ MYDB ARCHIVELOG
  3. If the database log mode shows ARCHIVELOG, you can perform an Oracle RMAN online backup. If it shows NOARCHIVELOG mode, proceed as follows:

  4. Shutdown the database MYDB. #> shutdown immediate;
  5. Start the database and set it to Mount status. To change the archive mode, the database must be mounted but not open. #> startup mount;
  6. Switch to ARCHIVELOG mode. #> alter database archivelog;
  7. Bring the database online. #> alter database open;

Check the archiving mode again (see step 2). By enabling ARCHIVELOG mode, online redo log files are archived before they are reused. It is recommended that you specify the location for these archive logs to avoid storing them in random locations. Note that if your archive log destination runs out of space, the database will shut down. For details, see Oracle documentation Specifying Archive Destinations.

Enabling disaster recovery with autobackup

Information sign.png Note

RMAN can be configured to automatically back up the control file and server parameter file, enabling smoother disaster recovery of a complete Oracle database. It is recommended that this option is always enabled.

If no recovery database catalog is configured and the database keeps track of backups using a control file, the Oracle administrator must enable the CONTROL FILE AUTOBACKUP option.

  1. Using RMAN, check that the CONTROL FILE AUTOBACKUP option is enabled.
  2. RMAN> show controlfile autobackup;
    RMAN configuration parameters for database with db_unique_name XE are:
    CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
    
  3. If the autobackup option is off, enable it.
  4. RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
    

The autobackup option enables RMAN to recover the database even if the current control file, catalog and server parameter file are lost. During Oracle backup, a special save set for the control file is created on the SEP sesam server. The control file provides database consistency information used for recovery and can be used to restore database information on a freshly installed or different system.

Setting up RMAN backup

This section explains only the SEP sesam-specific part of Oracle RMAN. For details about RMAN and setting up a correct backup strategy, see Oracle database documentation.

The following example script performs a full database backup:

oracle@oraclesrv:/product/oracle/bin> cat ora_full.rman
connect target
run{
allocate channel t1 type ’SBT’ parms ’ENV=(SESAM_SERVER=backup,SESAM_JOB=oracle_full,SESAM_POOL=DISK)’;
backup database
format ’O%d_%u.dat’;
filesperset 100;
release channel t1;
}

Explanation of the script:

  1. Log into target database (database to be backed up).
  2. Open a backup channel. For parallel backups, additional channels can be allocated.
    SEP sesam specific parameters
    SESAM_SERVER (*) Name of the SEP sesam Server. Optionally, specify a port range (e.g., bcksrv:11001@11003-11007).
    SESAM_JOB (*) Task name for Oracle backup. You should create a task before setting up RMAN backup. See Creating a backup task type Oracle.
    SESAM_POOL (*) Media pool name.
    SESAM_DRIVE Drive number.
    SESAM_TAPE_SERVER Name of the SEP sesam tape server. Optionally, specify a port range (e.g., bcksrv:11001@11003-11007).
    SOB_TRACE Trace level (max. 3).
    SOB_LOGFILE Name of the log file. If no log file is specified, trace messages are written to sbtio.log.

    RMAN specific parameters

    SBT_LIBRARY=<path> Path to the SBT library file (libobk.so) on the system. Use on AIX systems, if the library cannot be found automatically. The library file libobk.so resides in <sesam_install>/bin/sesam.
    Parameter must NOT be part of the ENV= variable. Example: allocate channel t1 type ’SBT’ parms='SBT_LIBRARY=/opt/sesam/bin/sesam/libobk.so ENV=(...)'. See: [[1] Oracle Documentation]
    • (*) = mandatory parameters
    • Format identifier. The format specifier must result in a unique ID. Both Oracle and SEP sesam use this ID to identify the correct save set during restore. Oracle guarantees that the combination of %d%u is unique.
  3. Include 100 files in one save set.
  4. Release the backup channel.

When this script is executed with rman cmdfile ora full.rman, the following appears:

oracle@oraclesrv:\~/product/oracle/bin> ./rman cmdfile ora_full.rman
Recovery Manager: Release 9.2.0.1.0 - ProductionCopyright (c) 1995
RMAN>
connected to target database: MYDB (DBID=2383580887)
RMAN>
connected to recovery catalog database
RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14>
allocated channel: t1
channel t1: sid=16 devtype=SBT_TAPE
channel t1: MMS Version 1.7.0.1
Starting backup at 30-JUL-02
channel t1: starting full datafile backupset
channel t1: specifying datafile(s) in backupset
including current SPFILE in backupset
including current controlfile in backupset
input datafile fno=00001 name=/opt/oracle/oradata/mydb/system01.dbf
input datafile fno=00002 name=/opt/oracle/oradata/mydb/undotbs01.dbf
input datafile fno=00005 name=/opt/oracle/oradata/mydb/example01.dbf
input datafile fno=00010 name=/opt/oracle/oradata/mydb/xdb01.dbf
input datafile fno=00006 name=/opt/oracle/oradata/mydb/indx01.dbf
input datafile fno=00009 name=/opt/oracle/oradata/mydb/users01.dbf
input datafile fno=00003 name=/opt/oracle/oradata/mydb/cwmlite01.dbf
input datafile fno=00004 name=/opt/oracle/oradata/mydb/drsys01.dbf
input datafile fno=00007 name=/opt/oracle/oradata/mydb/odm01.dbf
input datafile fno=00008 name=/opt/oracle/oradata/mydb/tools01.dbf
channel t1: starting piece 1 at 30-JUL-02
channel t1: finished piece 1 at 30-JUL-02
piece handle=b_7_1_MYDB.dat comment=API Version 1.1,MMS Version 1.7.0.1
channel t1: backup set complete, elapsed time: 00:07:47
Finished backup at 30-JUL-02
RMAN>
Recovery Manager complete.

Backing up the Oracle database

On Linux/Unix

The archive <OS> sob 3.0.x.x.tgz file contains the SEP module SBC Oracle client. This module is a shell script that can be called from SEP sesam as a command event (see also Creating a SEP sesam command event.). This wrapper script creates an RMAN script with the given arguments and executes RMAN with the generated script.

 oracle@orax10:~/product/10.2/db_1/sob> ./sbc_oracle_rman.sh
 Usage: ./sbc_oracle_rman.sh -b|r <-l level> -T <TargetDBS> -R <Catalog> -S <SesamServer> \
                             -j <SesamJob> -m <Mediapool> -o <option> -p <Number of streams> <TableSpace>

 Arguments:
  -b: Backup operation. By default, this is a full, online, single channel backup.
  -r: Restore operation. By default, this is a full online, single channel restore.
      NOTE:
      Before restoring an Oracle database, it must be set to the required state,
      e.g., "SHUTDOWN; STARTUP MOUNT;"
      After restore an "ALTER DATABASE OPEN RESETLOGS;" might be necessary.

  -l <copy|full|diff|incr|arch>: Backup level COPY, FULL, DIFF, INCR and ARCHIVELOG.
     Backup level may be combined with ARCHIVELOG backup,
     e.g., -l copy_arch

  -o {option}: The following options are supported:

     delete                    Delete archive logs after backup.
     delete_later              Delete archive logs when successfully backed up 3 times.
     offline                   WARNING: This option will automatically SHUT DOWN
                                        the database before the backup and START it UP after the backup!

     controlfile               Restore control file with RMAN catalog.
     controlfile_DBID={DBID}   Restore control file without RMAN catalog. DBID is required.
     recover                   Recover after restore.
     until={YYYYMMDD-HH:MM:SS} Point-in-time recovery with specified time.

  -T <target database connect string>:  default is ORACLE_SID
  -R <recovery catalog connect string>: default is NoCatalog
  -C <SesamServer>: SEP sesam Server host name
  -S <TapeServer>: tape server host name
  -j <SesamJob>: the name of the SEP sesam job, under which the backup is running
  -v [0|1]: debug on (set -x)
  -m <pool name>: the name of the SEP sesam media pool, used for backup
  -p <number> the number of backup channels
     <TableSpace> a single table space to be backed up or restored
                  If it is not specified, a backup/restore of the whole database is performed.
Example 1 
Level 0 backup of the SID orcl to the SEP sesam Server smsrv to the already configured task orax10_DB-orcl to media pool VTD1 with recovery catalog RCVCAT.
 /opt/oracle/product/10.2/db_1/sob/sbc_oracle_rman.sh -b -l copy -T orcl -R sys/password@RCVCAT -C smsrv -j orax10_DB-orcl -m VTD1
Example 2 
Archive log backup of SID prod to SEP sesam Server backupsrv to the already configured task dbsrv_ora-prod to mediapool DAY, using SEP sesam drive 5 and not using an Oracle recovery catalog.
 /opt/oracle/product/10.2/db_1/sob/sbc_oracle_rman.sh -b -l arch -T prod -C backupsrv -j dbsrv_ora-prod -m DAY -d 5
Example 3 
Full restore of the database prod with automatic recovery from SEP sesam Server smsrv and sesam task orax10_DB-prod from media pool DISK.
  1. Shut down the database with Oracle management tools.
  2.  SQL> shutdown immediate
    
  3. Mount the database.
  4.  SQL> startup mount
    
  5. Restore the database.
  6.  # /opt/oracle/product/10.2/db_1/sob/sbc_oracle_rman.sh -r -T prod -o recover -C smsrv -j orax10_DB-prod -m DISK
    
  7. Open the newly restored database.
  8.  SQL> alter database open;
    
Example 4 
Point-in-time-recovery to the 2nd of February 2011 of database fanta with automatic recovery. Connecting to the already configured SEP sesam task dbserver_ora-fanta in the SEP sesam GUI and using the recovery catalog RCAT.
  1. Shut down the database with Oracle management tools.
  2.  SQL> shutdown immediate
    
  3. Mount the database.
  4.  SQL> startup mount
    
  5. Restore the database.
  6.  # /opt/oracle/product/10.2/db_1/sob/sbc_oracle_rman.sh -r -T fanta -R sys/password@RCAT -o recover,until=20110202-16:31:00 -C sesamsrv -j dbserver_ora-fanta -m Month
    
  7. Open the newly restored database.
  8.  SQL> alter database open resetlogs;
    

On Windows

The only difference between the Windows and SEP sesam Linux/Unix Oracle extensions is that the regular Windows shell scripting has no possibility to all parameter by ARGV tags. Consequently, the given parameters must be specified in a precise order when calling the script.

.\sbc_oracle_rman.cmd b full <user>/<password>@<sid> <user>/<password<@<RCAT> <sesam_server> <sesam_job_name> <sesam_drive_number> <mediapoolname> [<tracelevel>] [<tablespace>]

If a user is authorized via oper system login then <sid> is sufficient. If no Recovery Catalog RCAT was used then 'nocatalog' must be specified to use the target database controlfile.

.\sbc_oracle_rman.cmd b full <sid> nocatalog <sesam_server> <sesam_job_name> <sesam_drive_number> <mediapoolname> [<tracelevel>] [<tablespace>]


Example 1 
Full backup with recovery catalog to SEP sesam server backupsrv with SEP sesam backup task type Oracle oracle_db_orcl to media pool ltopool to SEP sesam drive 2.
.\sbc_oracle_rman.cmd b full oracle/password@orcl oracle/password@rcvcat backupsrv oracle_db_orcl 2 ltopool 2
Example 2 
Full backup as above without recovery catalog.
.\sbc_oracle_rman.cmd b full oracle/password@orcl nocatalog backupsrv oracle_db_orcl 2 ltopool 2
Example 3
Full restore to DB 'reco' without recovery catalog.
.\sbc_oracle_rman.cmd r full 'reco' nocatalog backupsrv oracle_db_orcl 2 ltopool

Validating backups using CROSSCHECK

With the CROSSCHECK command, you can crosscheck all Oracle database backups and copies and thus ensure that the files are in place and ready for restore. The CROSSCHECK command synchronizes and checks the validity of the Oracle backups in SEP sesam according to the recovery catalog.

If you have not configured automatic channels for media manager, you must run ALLOCATE CHANNEL FOR MAINTENANCE before CROSSCHECK. Then run CROSSCHECK BACKUP DEVICE TYPE DISK 'SBT'.

Example

allocate channel for maintenance type 'SBT' parms
'ENV=(SESAM_SERVER=sesam,SESAM_JOB=job,SESAM_POOL=pool)';
crosscheck backup;
delete expired;

Crosschecking marks objects that do not exist on the disk or tape as expired in the RMAN repository. Note that this affects the whole save set: if any object that is part of a backup is not found, the whole backup is marked as expired. You can delete all expired backups from RMAN with the command DELETE EXPIRED (see example above).

Troubleshooting

  • Testing the Oracle extension with sbttest on AIX requires the full path to the library with argument -libname, e.g.,
    sbttest test1 -libname /opt/sesam/bin/sesam/libobk.so or ... -libname $ORACLE_HOME/lib/libobk.so.
  • RMAN command on AIX requires that the full path to the library is set in the script via PARMS SBT_LIBRARY={full_path_to_libobk.so}. For details, see RMAN specific parameters.
  • When running sbttest, make sure that the backup_file_name argument is set to a different value for each run of the script. If sbttest is using the same backup_file_name argument on the next run, SEP sesam will return duplicate key error. This happens because the backup_file_name is already written in the SEP sesam results table.
  • Typically, on AIX bash is not included in the list of valid shells. Therefore the first line in sbc_oracle_rman.sh must be adapted to #!/bin/sh.
  • If ORACLE_HOME and ORACLE_SID parameters are not set in the user environment, you must specify them. For example, add the lines
    export ORACLE_HOME=/u01/app/oracle/product/10gR2/db_1 and export ORACLE_SID=PROD_DB or use oraenv to set the appropriate environment. Example:
  • export ORACLE_SID=TEST
    export ORAENV_ASK=NO
    . oraenv
    

See also

Literature

  • Oracle 11g RMAN Backup & Recovery
    by Robert G. Freeman, Matthew Hart, ISBN-13: 978-0071628600