четверг, 19 февраля 2009 г.

NetBackup robtest

mt -f /dev/rmt/0cbn status
mt -f /dev/rmt/1cbn status
mt -f /dev/rmt/2cbn status

/usr/openv/volmgr/bin/robtest

s d
unload d2
m d2 s2
m s2 d2
q




BACKUP DATABASE:


Level 0 incremental = Full backup

$ export ORACLE_SID=TESTDB
$ rman catalog rman/pwd@catdb target /

RMAN> run {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
SEND 'NB_ORA_SERV=nbsrv,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=MONTHLY';

BACKUP INCREMENTAL LEVEL=0
FORMAT 'orabk_%d_%T_%s_%p_%t'
DATABASE
INCLUDE CURRENT CONTROLFILE;

sql "alter system archive log current";

BACKUP
FORMAT 'orabk_arc_%d_%T_%s_%p_%t'
ARCHIVELOG ALL;

CROSSCHECK BACKUP;
DELETE NOPROMPT EXPIRED BACKUP;
CROSSCHECK ARCHIVELOG ALL;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
DELETE NOPROMPT ARCHIVELOG ALL BACKED UP 1 TIMES TO DEVICE TYPE sbt COMPLETED BEFORE 'sysdate-7';

RELEASE CHANNEL ch00;
}

RMAN>
RMAN> list backup;
RMAN> exit

$

Вы также можете запустить команду netbackup bplist, чтобы отобразить все файлы,
забэкапленные с определенного хоста
(Тип = 4 - Файлы типа Oracle)

$ bplist -C omega01 -t 4 -l -R  /




Incremental Cumulative Backup:

SEND 'NB_ORA_SERV=nbsrv,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=DAILY';

BACKUP INCREMENTAL LEVEL=1 CUMULATIVE
FORMAT 'orabkIC_%d_%T_%s_%p_%t'
DATABASE
INCLUDE CURRENT CONTROLFILE;



Backup Archive Logs:
RMAN> run {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
SEND 'NB_ORA_SERV=nbsrv,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=DAILY';

sql "alter system archive log current";
BACKUP
FORMAT 'orabk_arc_%d_%T_%s_%p_%t'
ARCHIVELOG ALL;

RELEASE CHANNEL ch00;
}



RESTORE DATABASE:




Restore TESTDB database on TESTDB01 instance
- Shutdown database on TESTDB instance (no files are removed)
- Startup TESTDB database instance in Mount state
- Restore TESTDB database on TESTDB01 instance using RMAN

As we have control file intact, redologs intact, we have a clean recovery and the database is open as normal post recovery;
Поскольку у нас доступны и не повреждены:

-текущий controlfile 
-online redologs

то у нас будет полное восстановление

$ sqlplus / as sysdba

SQL> shutdown immediate;
SQL> startup mount;
SQL> exit

$

$ export $ORACLE_SID=TESTDB01

$ rman catalog rman/pwd@catdb target /

RMAN>

RMAN> run {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE'
SEND 'NB_ORA_SERV=nbsrv,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=MONTHLY';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE'
SEND 'NB_ORA_SERV=nbsrv,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=DAILY';

RESTORE DATABASE;
RECOVER DATABASE;

RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
}


RMAN> ALTER DATABASE OPEN;

database opened

RMAN> list incarnation of database TESTDB;
RMAN> exit
$





Restore TESTDB database on TESTDB01 instance point-in-time using using SCN

For this restore, delete control file, redologs and all datafiles:
- Shutdown TESTDB01 database instance
- Remove all files(datafiles/redologs/controlfiles)
- Startup TESTDB01 database instance in nomount state
- Restore TESTDB database on TESTDB01 instance using RMAN
-- List the DB files to remove

SQL> shutdown immediate;
SQL> exit

$

-- Remove all DB files

$
$ rm /u02/oracle/TESTDB01/data/temp01.dbf
$ rm /u02/oracle/TESTDB01/data/users01.dbf
$ rm /u02/oracle/TESTDB01/data/undotbs01.dbf
$ rm /u02/oracle/TESTDB01/data/sysaux01.dbf
$ rm /u02/oracle/TESTDB01/data/system01.dbf
$ rm /u02/oracle/TESTDB01/data/ora_control1
$ rm /u02/oracle/TESTDB01/data/ora_control2
$ rm /u02/oracle/TESTDB01/data/redoA01.log
$ rm /u02/oracle/TESTDB01/data/redoB01.log
$ rm /u02/oracle/TESTDB01/data/redoA02.log
$ rm /u02/oracle/TESTDB01/data/redoB02.log
$

-- Startup Database instance in NOMOUNT state

$
$ export ORACLE_SID=TESTDB01

$ sqlplus / as sysdba
SQL> startup nomount ;
SQL>
SQL> exit
$

-- List archivelogs to grab SCN #

$ rman catalog rman/pwd@catdb target /

RMAN> list backup of archivelog all;

Archived Logs

in backup set 1842

Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
---- ------- ---------- --------- ---------- ---------
1    5       230871     11-APR-17 262878     11-APR-17
1    6       262878     11-APR-17 262897     11-APR-17
1    7       262897     11-APR-17 264000     11-APR-17
1    8       264000     11-APR-17 264019     11-APR-17
1    9       264019     11-APR-17 264636     11-APR-17
1    10      264636     11-APR-17 264655     11-APR-17

RMAN>
RMAN>


Perfrom Point-in-time recovery

RMAN>

RMAN> run {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE'
SEND 'NB_ORA_SERV=nbsrv,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=MONTHLY';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE'
SEND 'NB_ORA_SERV=nbsrv,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=DAILY';

# Set the RESTOR SCN
SET UNTIL SCN 264655;

# Set the RESTOR time 6:30pm
# SET UNTIL TIME "to_date('2017-04-11:18:30:00', 'yyyy-mm-dd:hh24:mi:ss')";


RESTORE CONTROLFILE;
ALTER DATABASE MOUNT;

RESTORE DATABASE;
RECOVER DATABASE;

RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
}

RMAN>
RMAN> ALTER DATABASE OPEN RESETLOGS;

RMAN>
RMAN> list incarnation of database TESTDB;

RMAN> exit




Restore ORADB database using RMAN to different Unix Host

Для восстановления базы данных из Netbackup на другой хост нам необходимо следующее:

ALTERNATE CLIENT SETUP:

NetBackup позволяет восстановить базу данных для клиента, отличного от того, который первоначально выполнял резервное копирование.
Это называется called alternate client restore.

Администратор Netbackup должен включить эту функцию, добавив client names в файл на Netbackup Master Server:
/usr/openv/netbackup/db/altnames/< client_name >

Например, резервное копирование производится с хоста omega01 и для его восстановления на хост omega02, тогда нужно

1) создать файл /usr/openv/netbackup/db/altnames/omega02
2) добавить запись omega01 в этот файл

RMAN CLIENT PARAMETER: при запуске RMAN вам нужно будет использовать NB_ORA_CLIENT = omega01 в команде SEND.

Это позволяет главному серверу Netbackup искать резервные копии на соответствующем носителе, где он был скопирован.


$ rman catalog rman/pwd@catdb
RMAN>
RMAN> LIST DB_UNIQUE_NAME ALL;

List of Databases
DB Key  DB Name  DB ID            Database Role    Db_unique_name
------- ------- ----------------- ---------------  ------------------
1702    TESTDB   2565746290       PRIMARY          TESTDB

RMAN>
RMAN> exit
$

-- Create dummy pfile with DB_NAME = TESTDB

$
$ cat $ORACLE_HOME/dbs/initTESTDB.ora
*.audit_file_dest='/u01/apps/oracle/admin/adump'
*.db_block_size=8192
*.db_name='TESTDB'
*.diagnostic_dest='/u01/apps/oracle'
*.memory_max_target=1000M
$


-- Start instance in NOMOUNT state

$
$ export ORACLE_SID=TESTDB
$



$ sqlplus / as sysdba
SQL> startup nomount;
SQL> exit
$

-- Launch RMAN and restore SPFILE for ORADB database

$
$ rman catalog rman/pwd@catdb target /

RMAN>
RMAN> run {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE'
SEND 'NB_ORA_SERV=nbsrv,NB_ORA_CLIENT=omega01,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=MONTHLY';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE'
SEND 'NB_ORA_SERV=nbsrv,NB_ORA_CLIENT=omega01,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=DAILY';

# Run Restore command
RESTORE SPFILE TO '/u01/apps/oracle/product/11.2.0/dbhome_1/dbs/testdb01_restored_spfile.ora' ;
}

RMAN> exit
$

-- verify the spfile is > 0 bytes

$ ls -ltr /u01/apps/oracle/product/11.2.0/dbhome_1/dbs/testdb01_restored_spfile.ora
-rw-r-----   1 oracle    dba        3584 Apr 17 22:42 /u01/apps/oracle/product/11.2.0/dbhome_1/dbs/testdb01_restored_spfile.ora
$


-- Create PFILE from RESTORED SPFILE

$ strings $ORACLE_HOME/dbs/testdb01_restored_spfile.ora

Note, values for audit_file_dest,
      control_files,
      diagnostic_dest,
      log_archive_dest
      db_name,
      service_name,
      instance_name

1) Create the initial directory structure with values noted above.
2) Set the ORACLE_SID to the instance_name noted above
3) Create init${ORACLE_SID}.ora pfile with the values from testdb01_restored_spfile.ora


-- Start oracle instance in NOMOUNT state with new pfile

$
$ export ORACLE_SID=TESTDB01

$ sqlplus / as sysdba
SQL> startup nomount ;
SQL> exit
$

-- Restore Control file now

$
$ rman catalog rman/pwd@catdb target /


RMAN> list backup ;


Handle: orabkIC_ORADB_20130411_5_1_812488789

   Media: XXX
  SPFILE Included: Modification time: 17-APR-17
  SPFILE db_unique_name: OTESTDB


RMAN>
RMAN>
RMAN>

RMAN> run {
# Restoring control file (NB_ORA_CLIENT is set to original host)

ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE'
SEND 'NB_ORA_SERV=nbsrv,NB_ORA_CLIENT=omega01,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=MONTHLY';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE'
SEND 'NB_ORA_SERV=nbsrv,NB_ORA_CLIENT=omega01,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=DAILY';

restore controlfile from  'orabkIC_ORADB_20130411_5_1_812488789';

}

RMAN> exit
$


$
$ mkdir -p /u02/oracle/DB01/data/
$ mkdir -p /u05/oracle/DB01/data/
$ mkdir -p /u03/oracle/DB01/data/
$ mkdir -p /u03/oracle/DB01/data/arch/
$
$

-- From archivelog backup, get the latest SCN number
-- RESTORE DATABASE until SCN Nubmer


$
$ rman catalog rman/pwd@catdb target /

RMAN>
RMAN> list backup of archivelog all ;

Archived Logs

 in backup set 1842
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    5       230871     11-APR-17 262878     11-APR-17
  1    6       262878     11-APR-17 262897     11-APR-17
  1    7       262897     11-APR-17 264000     11-APR-17
  1    8       264000     11-APR-17 264019     11-APR-17
  1    9       264019     11-APR-17 264636     11-APR-17
  1    10      264636     11-APR-17 264655     11-APR-17



RMAN>
RMAN>
RMAN>
RMAN> run {

ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE'
SEND 'NB_ORA_SERV=nbsrv,NB_ORA_CLIENT=omega01,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=MONTHLY';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE'
SEND 'NB_ORA_SERV=nbsrv,NB_ORA_CLIENT=omega01,NB_ORA_POLICY=POL_ORADBBackup,NB_ORA_SCHED=DAILY';

# Set the RESTOR SCN
SET UNTIL SCN 264655;
# Restore Database
RESTORE DATABASE;
RECOVER DATABASE;

# Release Channel
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
}

RMAN>
RMAN> ALTER DATABASE OPEN RESETLOGS;
RMAN>
RMAN> exit
$
$



















Комментариев нет:

Отправить комментарий