Wednesday, December 21, 2016

Managing Oracle Secure Backup (OSB)
------------------------------------
RMAN interacts with SBT devices through an MML, or media manager. Oracle provides its own MML, in the form of Oracle Secure
Backup.
OSB can back up to a tape library directly, so you don't need any other media management layer. And, best of all, OSB is tightly integrated with the database engine and thus can be controlled and administered via Oracle Enterprise Manager.

OSB can also perform filesystem backups, just like any standalone tool. Clearly, eliminating the need for MMLs for RMAN
backups, combined with this ability to back up filesystems, provides a lower-cost, less-complex alternative for backup and recovery.


OSB Administrative Domain and Servers
-------
An administrative domain is collection of servers (hosts) that you manage as a single group for backup and restore operations. Within an OSB administrative domain, each server can be assigned one or more of the following roles:
-    Administrative (admin) server
-    Media server
-    Client server (or client host)

For each administrative domain, there is only one administrative server that controls the backup, restore, and scheduling operations. An administrative server manages one or more media servers and one or more clients.

A media server is a host that has at least one physical tape device connected to it. Media servers are responsible for transferring data to and from the attached tape devices.

The client host is the server where the Oracle databases and file-system data reside that you want to back up (and potentially restore). For a single-host environment, a server can be the admin server, media server, and client host in the OSB administrative domain.



OSB Interfaces
--------
There are four tools you can use to run and manage OSB backup and restore tasks:
-    Enterprise Manager database control and grid control
-    Oracle Secure Backup Web tool
-    Oracle Secure Backup command line tool (obtool)
-    Recover Manager command line tool (rman)



Installing OSB
------------------------
www.oracle.com/technetwork/database/secure-backup/downloads/

0. Download OSB version 10.3.0.3.0, and saved the zip file osb-10.3.0.3.0_linux32.zip under a staging directory /stage/osb of my admin server in the OSB administrative domain.

1. To perform the OSB installation, you must logon as root.
$ su - root
$ mkdir -p /usr/local/oracle/backup

2.
$ cd /usr/local/oracle/backup
# /stage/osb/osb-10.3.0.3.0_linux32/setup

Leaving the default parameters for now, press ENTER to choose the default answer.

You can install the software on this host in one of the following ways:
(a) administrative server, media server and client
(b) media server and client
(c) client


If you are not sure which option to choose, please refer to the Oracle Secure
Backup Installation Guide. (a,b or c) [a]?
You are going to install all three components of OSB on the same server, so again press ENTER to choose the default answer.
The OSB administrative server, media server, and client are now installed.

Un-install OSB
-------------
To remove the Oracle Secure Backup, as root run the uninstallob shell script located in the OSB_HOME/install directory.
The operating system variable OSB_HOME is commonly set to the /usr/local/oracle/backup directory.




Schedule Oracle Database and File System Data Backups
-----------------------------------
The OSB Web tool is used to configure the tape library and tape drives. Let’s add the oracle user and a Database Backup Storage Selector to enable backup of an Oracle database.
Connect and log into the OSB Web tool using the https:// link as the admin user. Go to the Configure page, click the Users link, click the Add button, and add the oracle user.
After the oracle user is added, click the Edit button, and change Preauthorized Access:
As a result, you will have the admin and oracle users:
Go to Configure: Hosts, and make sure that the server has the mediaserver role.
To add a storage selector, click the Database Backup Storage Selectors link at the bottom of the Configure page, click Add.

Oracle Enterprise Manager:
Now, let’s configure OEM for OSB usage. Connect to the database and go to the Availability tab in OEM. Click Backup Settings.
Click Configure to specify your OSB target, and on the Specify Oracle Secure Backup Target page, click the Add button and then enter the host:
Click Continue and enter the values shown here:
Name: OSB Server
Type:OSB
Home:/usr/local/oracle/backup
Hostname:
Monitor username:
Monitor password:

Click Return, and the OSB Server target is ready for backing up Oracle databases to tape.
The OSB administrative server is configured as an OEM target and can be managed by OEM.

It is not possible to perform Oracle database backup and restore using the OSB Web tool. Therefore, we recommend using OEM as a centralized interface to schedule backup and restore jobs for Oracle database and file system data.

Connect to the database, go to the Availability tab in OEM, and click Schedule Backup.




obtool
------
OSB provides a command line tool called obtool. You can invoke the command line version of the tool by typing:
$ obtool
which brings up the OSB prompt ob>. You can type "help" here to see the commands available.
ob > help
ob> help topics

logon to a specific user:
$ obtool -u apress_oracle
To verify the OSB user that you are logged in:
ob> id

To determine the rights of class admin, issue the lsclass command, as shown here:
ob> lsclass -l admin

In the following example, OSB user apress_oracle is created and assigned with oracle rights:
ob> mkuser --class oracle apress_oracle --preauth BLLNX3:oracle+cmdline+rman

The +cmdline attribute in the --preauth option grants the oracle OS user preauthorized access to
obtool utility, while the +rman attribute grants Oracle Database SBT backups via RMAN. If no +rman
preauthorization is defined for the server hosting the target database that you want to backup, then the
RMAN backup fails with ORA-19511 error.

If you want to view all OSB users:
ob> lsuser


mkuser:    To create an OSB user.
lsuser: To display information about OSB users.
renuser:To rename an OSB user.
chuser:    To modify the attributes of an OSB user.
rmuser: To delete an OSB user.

mkmf: To create a media family.
lsmf: To display information about media families.
renmf: To rename a media family.
chmf: To modify the attributes of a media family.
rmmf: To delete a media family.

mkssel: To create a database backup storage selector.
lsssel: To display information about database backup storage selectors.
renssel: To rename a database backup storage selector.
chssel: To modify the attributes of a database backup storage selector.
rmssel: To delete a database backup storage selector.




To create a time-managed media family, issue the mkmf command. In the following example, media family APRESS_OS has 7 days of write-period and 14 days of retention period. This means the volumes of media family APRESS_OS will expire and are ready for recycling after 21 days since the first backup piece is created on the tape volume:
ob> mkmf --writewindow 7days --retain 14days APRESS_OS

To create a content-managed media family, issue the mkmf, as shown here. Since the default volume expiration policy is content-managed, you can omit the --contentmanaged option.
ob> mkmf --contentmanaged APRESS_RMAN

In the following example, the database backup storage selector name is BLLNX3-DB11R2.ssel, which assigns the media family APRESS_RMAN for RMAN backups on Oracle database DB11R2 hosted on client server BLLNX3:
ob> mkssel --host BLLNX3 --dbname DB11R2 --family APRESS_RMAN BLLNX3-DB11R2.ssel

ob> exit|quit

Database Backup:
--------
The first option is to allocate an RMAN channel for SBT_TAPE inside the run{} block. In the following example, the media family APRESS_RMAN is passed as a parameter to the environment variable OB_MEDIA_FAMILY. The tape volumes will have a volume ID of APRESS_RMAN affixed with a six-digit sequence number generated by OSB.
RMAN> run {
allocate channel t1 type sbt_tape parms 'ENV=(OB_MEDIA_FAMILY=APRESS_RMAN)';
backup database;
}

You can also use the CONFIGURE command to set the RMAN channel for SBT_TAPE, as shown here:
RMAN> configure channel device type sbt_tape parms 'ENV=(OB_MEDIA_FAMILY=APRESS_RMAN)';
RMAN> backup device type sbt_tape database;

OB_MEDIA_FAMILY: To specify the media family that defines the characteristics of the tape volumes.
OB_DEVICE: To specify the tape drives to use during backup.
OB_RESOURCE_WAIT_TIME: To specify the wait time for resources to become available.
OB_ENCRYPTION: To specify the OSB encryption. If this is set, then OSB does not perform further encryption.
OB_RESTORE_DEVICE: To specify the tape drives to use during restore.

Database Restore
-----
For RMAN restore and recover, you have to allocate an RMAN channel for SBT_TAPE. In the following example, the RMAN channel for SBT_TAPE is allocated inside the run{} block:
RMAN> run {
allocate channel t1 type sbt_tape;
restore database;
recover database;
}

Another option is to run the CONFIGURE command. Unlike the previous example, you must include the PARMS clause in the CONFIGURE command (if you don't use the PARMS clause, a syntax error is returned):
RMAN> configure channel device type sbt_tape parms 'ENV=(OB_MEDIA_FAMILY=APRESS_RMAN)';
RMAN> restore device type sbt_tape database;
RMAN> recover device type sbt_tape database;

To make the RMAN repository (control file in this scenario) aware of backup pieces on tape, do the following:
1. Configure a channel for tape.
2. Make the RMAN repository aware of the backup piece via the CATALOG command.

Next, issue the CATALOG DEVICE TYPE SBT_TAPE BACKUPPIECE command, followed by the name of the backup piece. In this example, one backup piece is cataloged:
RMAN> catalog device type sbt_tape backuppiece 'silr06fk_1_1';

If you have multiple backup pieces that you want to catalog, you must issue the CATALOG DEVICE TYPE SBT_TAPE BACKUPPIECE command for each individual backup piece. The key in cataloging the RMAN backup pieces on tape is you must know the exact names of the backup pieces.

Note: For disk-based backups, you can easily make the RMAN repository aware of multiple backup pieces via the CATALOG START WITH command. However, this technique only works for disk-based backups and not tape backups.


File System Backup
------
catds To display the contents of a dataset file.
cdds To change the dataset directory.
chkds To check the syntax in a dataset file.
edds To modify a dataset file.
lsds To list the dataset file and dataset directory names.
mkds To create a dataset file or dataset directory.
pwdds To show the current directory in the dataset directory tree.
rends To rename a dataset file or dataset directory.
rmds To delete a dataset file or dataset directory.

Like any backup job, you need to define the three Ws and one H. What data to backup? When to run the
backup? Where to store the backup? How the backup runs? To accomplish these 3 Ws and 1 H using
OSB, you need to create a dataset file, as well configure a backup window, a schedule, and a trigger.

1. Creating Dataset Files:
Dataset files define the directories and files on the client hosts that you want to backup. In the following example, this dataset file specifies to include all files under the directory /home/oracle on the client hosts BLLNX1 except for files under the directory /home/oracle/temp and Oracle database-related files:
include host BLLNX1
include path /home/oracle {
exclude path /home/oracle/temp
exclude oracle database files
}

To create a dataset file named bllnx1_home-oracle.ds, perform the following steps using the obtool utility, as shown here:
a. Issue the mkds command and followed by the name of the dataset file.
ob> mkds bllnx1_home-oracle.ds
b. The vi editor is invoked, and a dataset template is displayed.
c. Comment out or remove all existing lines, and add the following lines:
include host BLLNX1
include path /home/oracle {
exclude oracle database files
exclude path /home/oracle/temp
}
d. Save the file by typing Esc key, : and wq!
e. The following prompt is displayed. Press the Enter key to confirm the changes.
Apply your changes, if any [yes]?
You just created a dataset file.

2. Configuring Backup Windows:
The backup window defines the range of time the scheduled backups are allowed to run. The default backup window is daily 00:00 to 24:00. If there is no backup window defined, the scheduled backups are not going to run at all.
For production servers, you may want the backups to run daily only between 1 a.m. and 5 a.m. when there is minimal database traffic. To define a range of time for your backup window, perform the following steps:
a. Remove the existing daily 00:00-24:00 backup window, since it overlaps the backup window you want to create by issuing the rmbw command:
ob> rmbw daily
2. Issue the lsbw command.
ob> lsbw

There are no backup windows.
This result indicates that the daily backup window is already removed.
3. To create the backup window, issue the addbw command. The following example defines the backup window daily from 01:00 to 0500:
ob> addbw --times '01:00-05:00' ,mon,tue,wed,thu,fri,sat,sun

addbw To add a backup window.
chkbw To check whether there is a backup window defined.
lsbw To list the backup windows.
rmbw To remove a backup window.
setbw To modify a backup window.


3. Configuring Backup Schedules and Triggers:
The backup schedule defines what data to backup, where to store the backup, and how the backup runs, while the triggers define when a backup is scheduled to run. For what data to backup, set the specific datasets. For where to store the backup, set the specific tape drives. If no specific tape drive is selected, then any available tape drive will be used. For how the backup runs, set the job priority and backup encryption options. The lower the value of the job priority number, the greater preference is assigned to the job by the scheduler. The default value of the job priority is 100 and no for the encryption option.

The following example uses the MKSCHED command to create a backup schedule named bllnx1_homeoracle.sched for dataset bllnx1_home-oracle.ds:
ob> mksched --dataset bllnx1_home-oracle.ds bllnx1_home-oracle.sched

After creating the backup schedule, create a trigger to define when to run the scheduled backup. The following example uses the CHSCHED command to define a trigger for schedule bllnx1_home-oracle.sched to run daily at 02:00 (2 a.m.). The -a option means the addtrigger, the –d option means day, the –t option means time, and the –f means media family.
ob> chsched -a -d daily -t 02:00 -f APRESS_OS bllnx1_home-oracle.sched

To display the information about the backup schedules:
ob> lssched -l bllnx1_home-oracle.sched

To remove a backup schedule, issue the rmsched command, as shown here:
ob> rmsched bllnx1_home-oracle.sched




Performing On-Demand File-System Backups
----------------------------------
To run a one-time backup on a specific client host use the backup command. In the following example, the dataset file is bllnx1_home-oracle.ds, which was created earlier:
ob> backup --dataset bllnx1_home-oracle.ds --go

If you omit the --go option, the backup request is still in the queue. You can issue the lsbackup command to display the backup requests that are queued, as shown here:
ob> lsbackup

To forward the backup request to the OSB scheduler, issue the following backup command with the GO option, as shown here:
ob> backup --go

To manually back up the OSB catalog of the admin server, issue the following backup command:
ob> backup --level 0 --dataset OSB-CATALOG-DS --go




File System Restore
---------------------
There are three options on how you can restore from a file-system backup:
• catalog-based restore
• raw restore
• obtar command

In a catalog-based restore, you provide the directory and file, which you can browse from the OSB catalog. In both the raw restore and the obtar command, you provide the volume ID and file number. The volume ID is the unique name (that contains the media family) assigned to a tape volume, and the file number is the number of the backup image on the tape volume. Both the catalog-based restore and raw restore are performed using the obtool utility, while the obtar commands are issued at the operating system prompt.

1. Performing Catalog-Based Restore:
------
For a catalog-based restore, you can browse the OSB catalog to determine and verify the files you want to restore. In the following example, you want to restore the file /home/oracle/scripts/rmanbkup.sh of the client host BLLNX1. To restore the files using the OSB catalog, perform the following steps:
a. Set the host variable to BLLNX1, which is the source host.
ob> set host BLLNX1
b. Issue the cd command to navigate to the directory.
ob> cd /home/oracle/scripts
c. Issue the ls command to verify the files in the directory.
ob> ls -l rmanbkup.sh
-rwxr-xr-x oracle.oinstall 782 2010/01/13.18:14 rmanbkup.sh (0)

d. Issue the restore command.
ob> restore '/home/oracle/scripts/rmanbkup.sh' --go


2. Performing a Raw Restore
--------
To restore a data using the raw restore, you must know the volume ID and file number where to extract the data from. However, you know that the backups are using a particular media family, which can make the search a bit easier.

In the following example, you are going to restore the file /home/oracle/scripts/rmanbkup.sh from a tape volume that has media family APRESS_OS.
a. Issue the lsvol command with --contents option to display the contents of the volumes associated to media family APRESS_OS:
ob> lsvol --contents --family APRESS_OS --nobarcode
VOID OOID Seq Volume ID Family Created Attributes
2845 2845 1 APRESS_OS-000001 APRESS_OS 10/21.04:41 open; closes 10/28.04:41
BSOID File Sect Level Host Size Created Attributes
31250 1 1 0 BLLNX1 208.6 MB 10/21.04:41
31258 2 1 0 BLLNX1 208.8 MB 10/21.06:04
31260 3 1 0 BLLNX1 210.1 MB 10/21.12:23
31261 4 1 0 BLLNX1 210.1 MB 10/21.12:34

b. According to the output shown above, you want to restore from a backup taken on 10/21.06:04 (i.e. October 21 at 6:04am). The corresponding file number is 2, and the volume ID is APRESS_OS-000001. Issue the following restore command, as shown here. The -R option indicates a raw restore operation and does not use an OSB catalog, while the –F option means the filenumber, and the –v option means the volume ID.
ob> restore -R -F 2 -v APRESS_OS-000001 /home/oracle/scripts/rmanbkup.sh --go

3. Performing an obtar Restore
---------
When you run the OSB restores, they are actually translated to obtar commands in the background. The obtar commands are issued at the operating system level. The obtar command is seldom used to perform restore operations, since you need to provide the volume ID and file number, which is not readily available especially if you have no access to the OSB catalog.
In the following example, you are going to restore the file /home/oracle/scripts/rmanbkup.sh from the tape that has volume ID APRESS_OS-000001 at file number 2.
a. Issue the loadvol command to manually load the tape that has volume ID APRESS_OS-000001 to an available tape drive. Here I used tape drive vdrive8.
ob> loadvol -D vdrive8 --volume APRESS_OS-000001

b. To check the contents of the tape, issue the obtar command with -t option.
$ obtar -t -f vdrive8

c. To perform the restore operation using the obtar command, issue the following command with the -x option. The -F option means the file number, and the -k option avoids overwriting the existing file.
$ obtar -F 2 -x -f vdrive8 -k /home/oracle/scripts/rmanbkup.sh

d. Since you restore using the obtar command, which is executed at the operating system level, you can’t monitor the restore job using the obtool utility. However, one way to verify whether the file is restored is to issue the ls OS command.
$ ls -l /home/oracle/scripts/rmanbkup.sh



OSB Job Monitoring
------------------
Listing Jobs:
To display the jobs that are still running, issue lsjob command with the --active or -a option. For other job states, use --complete or -c option for completed jobs, --pending or -p for pending jobs, --inputrequest or -i for jobs currently requesting input, and --all or -A to display all jobs regardless of the job state. For example, to list active jobs:
ob> lsjob --active
ob> lsjob -a -l -j -o -R -L -C

For RMAN jobs, use the --dbname or -d option to limit the output for a specific Oracle database. If you know the database ID, you can use the --dbid or -I option instead. This example uses the dbname parameter:
ob> lsjob --active --dbname DB11R2


For file-system jobs, use the --host or -h option to limit the output for a specific client host, as shown here:
ob> lsjob --active --host BLLNX1



Showing Job Transcripts:
ob> lsjob --active --subjobs




Using the Oracle Backup Web Interface Tool
------------------------------------------
$ ps –ef | grep observice
https:/localhost
username=admin
password=leave password blank

You can perform four major activities using the Oracle Backup Web Interface: configure, manage, backup, and restore operations.

Expert users can use the obtar command-line tool to work directly with tape drives, bypassing the
Oracle Backup’s scheduler.




Virtual Test Devices
----------------------
You may relate to the expression “experience is the best teacher.” You have read this chapter, and you want to try the OSB commands and examples yourself. However, you don’t have a physical tape device connected to any test servers in your environment. In this situation, where you are going to install and experiment with OSB? Well, you can configure a virtual test device solely for testing purposes.

To configure a virtual test device, perform the following steps. In this example, the hostname of the media server is BLLNX3.
1. Logon as the oracle OS user at your designated media server of the OSB administrative domain.
$ su - oracle
2. At the OSB media server, create a directory that hosts the virtual storage elements and virtual tape devices. Make sure you have enough disk space on the mount point where you are going to create the directory.
$ mkdir /osb_vdevices
3. Logon as admin user to the obtool utility, and provide the corresponding password.
$ obtool -u admin
Password:

4. Configure the virtual tape library by running the following mkdev command using the -t option to specify the device as a tape library and the -v option to specify as a virtual tape library. The -S option specifies the number of storage elements. The -I option specifies the number of export and import elements. The -o option specifies that the tape device is logically available to OSB. The -B option with the yes value specifies that the barcode reader is present. The -a option attaches the virtual library vlib1 to directory /osb_vdevices/vlib1 of
host BLLNX3.

ob> mkdev -t library -v -S20 -I2 -o -B yes -a BLLNX3:/osb_vdevices/vlib1 vlib1

5. Configure the virtual tape devices by running the following mkdev command using the -t option to specify the device as a tape device and the -v option to specify as a virtual tape device. The -o option specifies that the tape device is logically available to OSB. The -l option specifies the name of the associated tape library. The -d option specifies the data transfer element (DTE). The -a option attaches the virtual tape vdrive1 to directory /osb_vdevices/vdrive1 of host BLLNX3. To configure additional virtual tape devices, run the same mkdev
command. However, for the second virtual tape device, change the name vdrive1 and directory /osb_vdevices/vdrive1 to vdrive2 and directory
/osb_vdevices/vdrive2, respectively, and so on.
ob> mkdev -t tape -v -o -l vlib1 -d1 -a BLLNX3:/osb_vdevices/vdrive1 vdrive1

6. Run the insertvol command to manually insert a volume to the tape library. The -L option specifies the library name, which is vlib1. Since there are 20 storage elements defined when the virtual library is created, then issue unlabeled 1-20 to insert 20 new volumes.
ob> insertvol -L vlib1 unlabeled 1-20

7. Issue the lsvol command to display the volumes in the tape library vlib1.
ob> lsvol -l -L vlib1




OSB Software Upgrades
---------------------
You have an older version of the OSB installed and you want to upgrade to the current release. To
perform an OSB upgrade, perform steps similar to installing OSB. However, before performing the OSB
upgrade, make sure to backup the OSB catalog in the admin server and stop the OSB daemons and
services at all hosts in the administrative domain. Also, upgrade the admin server first, then the media
servers and client hosts.

OSB Service Shutdown and Startup Commands:
-------
Linux
 /etc/init.d/observiced stop|start
Solaris
/etc/init.d/OracleBackup stop|start
AIX
/etc/rc.d/init.d/OracleBackup stop|start
HP-UX
/sbin/init.d/OracleBackup stop|start
Windows
net stop|start observiced




References;


Configure using Oracle Enterprise Manager (OEM), RMAN Backups to tape via Oracle Secure Backup (OSB) (Doc ID 1460052.1)
How To Configure RMAN Backups To Tape via Oracle Enterprise Manager (Doc ID 735953.1)

www.oracle.com/database/secure-backup.html
http://docs.oracle.com/cd/B19306_01/install.102/b14235/toc.htm (Oracle Secure Backup Installation Guide Release 10.1)
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/11g/r1/prod/ha/osb10_2install/osb1.htm(Installing and Configuring Oracle Secure Backup 10.2)
http://docs.oracle.com/cd/E14812_01/doc/index.htm (Oracle Secure Backup Installation and Configuration Guide Release 10.3)

No comments:

Post a Comment