Documente Academic
Documente Profesional
Documente Cultură
RMAN connect target / crosscheck archivelog all; delete expired archivelog all; Scenarij 1: Napravio kopiju baze sa RMAN-om(compressed), obrisao sve file-ove RMAN je napravio 3 file-a: /oradata2/RMAN_Test/04ivesdp_1_1 - datafileovi /oradata2/RMAN_Test/05ivesgf_1_1 - control file, sfile /oradata2/RMAN_Test/06ivesgi_1_1 - archive logovi Obrisao sve vezano uz bazu. Napravio nakakav initTest.ora samo za poetak. rman> rman> rman> rman> rman> rman> rman> rman> rman> rman> connect target startup nomount; restore spfile from '/oradata2/RMAN_Test/05ivesgf_1_1'; vraa spfile s kojim emo podii bazu shutdown immediate startup nomount - diemo bazu sa restoranim spfile-om restore controlfile from '/oradata2/RMAN_Test/05ivesgf_1_1'; vraam contolfile koji ima podatke o backup-u startup mount (moda najprije sruiti bazu) restore database; recover database; alter database open resetlogs;
*RMAN ne kui arhivu Napravio rman online backup. Nakon toga napravio rman backup archive log fileova. Izbrisao bazu. Napravio restore controlfile-a, restore database. Recovery ne moe nai archivelog fileove. Napravio skriptu rman.txt za uvrtenje archivelog fileova u catalog: for i in `ls *` do print CATLOG ARCHIVELOG \'/oradata2/RMAN_Test/$i\'\; >> rman.txt done Izveo skriptu iz RMAN> @rman.txt i nakon toga recovery proe! * korisnik mora imati sysdba dozvolu (po default je ima samo sys). grant sysdba to rman_user; Spajanje na rman rman nocatalog target system/manager rman target sys/sys_pwd@db1 catalog rman_db1/rman_db1@catdb batch: rman target / catalog rm_db1/rm_db1@cat @tbsbk.rcv log tbs.log
rman:> startup nomount; iz rman backupa-a vratio spfile i control file. Iz spfile-a kreirao pfile i u njemu promijenio path-ove za dump-ove, control file i sl. shutdown pa mount baze. Potebno je preimenovati file-ove koje dobijemo iz restore-a. Sa list backup vidi se koji file-ovi su u backupu. Napravi se: run { set newname for datafile '/oradata2/Test/system01.dbf' to '/oraarh/Test/system01.dbf'; set newname for datafile '/oradata2/Test/undotbs01.dbf' to '/oraarh/Test/undotbs01.dbf'; set newname for datafile '/oradata2/Test/sysaux01.dbf' to '/oraarh/Test/sysaux01.dbf'; set newname for datafile '/oradata2/Test/users01.dbf' to '/oraarh/Test/users01.dbf'; set newname for datafile '/oradata2/Test/podaci01.dbf' to '/oraarh/Test/podaci01.dbf'; set newname for datafile '/oradata2/Test/indeksi01.dbf' to '/oraarh/Test/indeksi01.dbf'; set newname for datafile '/oradata2/Test/orabpel.dbf' to '/oraarh/Test/orabpel.dbf'; restore database; (revover noredo;) nije potrebno switch datafile all; } nakon toga iz sqlplus-a se pokrene recovery: recover database until cancel using backup controlfile; i nakon toga: alter database open resetlogs; i to je to.
v$rman_output backup database plus archivelog; - radi sve, proces najprije radi log switch (koristei alter system archivelog current;). Zatim uzima backup postojeih archive log fileova, potom i baze.Ponovno se napravi log switch i backup-iraju se preostali archive log file-ovi (koristei backup archivelog all naredbu). ---Uzeo backup sa backup database plus archivelog; Napravio restore spfile-a, control file-a (u nomountu), mountao bazu, restore database, recover database i alter database open resetlogs. Sve radi.
S naredbom list backup vidimo sadraj backup-a, odnosno lokacije datafile-ova koje moramo promijeniti. RMAN> list backup; Sad napravimo skriptu za oporavak s promjenom imena fileova: RMAN > run {
set newname for datafile '/oradata1/Dips/undotbs01.dbf' to '/oradata3/Dips/undotbs01.dbf'; set newname for datafile '/oradata1/Dips/system01.dbf' to '/oradata3/Dips/system01.dbf'; set newname for datafile '/oradata1/Dips/indeksi01.dbf' to '/oradata3/Dips/indeksi01.dbf'; set newname for datafile '/oradata1/Dips/sysaux01.dbf' to '/oradata3/Dips/sysaux01.dbf'; set newname for datafile '/oradata1/Dips/users01.dbf' to '/oradata3/Dips/users01.dbf'; set newname for datafile '/oradata1/Dips/example01.dbf' to '/oradata3/Dips/example01.dbf'; set newname for datafile '/oradata1/Dips/podaci01.dbf' to '/oradata3/Dips/podaci01.dbf'; set newname for datafile '/oradata1/Dips/podaci02.dbf' to '/oradata3/Dips/podaci02.dbf'; set newname for datafile '/oradata1/Dips/pod_arh01.dbf' to '/oradata3/Dips/pod_arh01.dbf'; set newname for datafile '/oradata1/Dips/mp2data01.dbf' to '/oradata3/Dips/mp2data01.dbf'; set newname for datafile '/oradata1/Dips/mp2index01.dbf' to '/oradata3/Dips/mp2index01.dbf';
set newname for datafile '/oradata1/Dips/gemmstbl01.dbf' to '/oradata3/Dips/gemmstbl01.dbf'; set newname for datafile '/oradata1/Dips/gemmsind01.dbf' to '/oradata3/Dips/gemmsind01.dbf'; set newname for datafile '/oradata1/Dips/mp2proc01.dbf' to '/oradata3/Dips/mp2proc01.dbf'; set newname for datafile '/oradata1/Dips/mp2proc01.dbf' to '/oradata3/Dips/mp2proc01.dbf'; set newname for datafile '/oradata1/Dips/undo2.dbf' to '/oradata3/Dips/undo2.dbf'; restore database; switch datafile all; }
*Ako ne bi eljeli primjeniti archive log file-ove napravili bi: restore database; i alter database open resetlogs;. Ja sam otvorio sql i pokrenuo opravak uz primjenu archive log file-ova. SQL> recover database until cancel using backup controlfile; Prebacimo potrebne archive log file-ove s backupa ili s originalne lokacije na nau archive log destinaciju (moemo je i promijeniti s alter system...) Kad dosadi ili kad doemo do kraja CANCEL. SQL> alter database open resetlogs; Digresija: Zaboravio sam primjeniti switch datafile all; na kraju restore-a. Ponovno sam pokrenuo RMAN i izveo cijeli set naredbi ali bez restore database;).
RMAN Commands RMAN uses two types of commands: stand-alone and job commands. Generally stand-alone commands are self-contained. Following are some of the standalone commands: Change Connect Create Catalog, Resync Catalog Create Script, Delete Script, Replace Script The job commands are usually grouped and RMAN executes the job commands inside of a run command block sequentially. If any command within the block fails, RMAN ceases processingno further commands within the block are executed.
RMAN> startup mount pfile=/u01/oracle/db01/pfile/initdb01.ora RMAN> shutdown immediate
To List the Current Configuration of the Target Database Use the REPORT command to get the configuration of the database.
RMAN> report schema;
REPORT NEED BACKUP Command Lists all data files requiring a backup Assumes most recent backup used during a
restore. Three options are available: Incremental Days Redundancy
report need backup days 3; report need backup days 3; report need backup incremental 3; report need backup incremental 3; report need backup redundancy 3; report need backup redundancy 3;
Before using the LIST command, you must connect to RMAN specifying both the target database and the recovery catalog:
RMAN> target sys/oracle@DB00 \ 2> rcvcat rman/rman@RCVCAT
Stored Scripts A recovery manager script is a set of commands that: Specify frequently used backup, recover, and restore operations Are created using the CREATE SCRIPT command Are stored in the recovery catalog Can be called only within the RUN command Enables you to plan, develop, and test a set of commands for backing up, restoring, and recovering the database Minimize the potential for operator errors.
RMAN> create script Level0Backup { allocate channel d1 type disk; backup incremental level 0 format /u01/db01/backup/%d_%s_%p fileperset 5 (database include current controlfile); sql alter database archive log current; release channel d1;}
RMAN > run {execute script Level0Backup;}
RUN Command
To run an operating system command: RMAN > run { host ls -l; } To run a SQL command: RMAN > run { sql alter system switch logfile;} RMAN > run { sql alter system switch logfile;} To run a stored script: RMAN > run { execute script NightlyBackup;}
How to Create a Recovery Catalog To create the recovery catalog, perform the following steps: 1 Connect to the catalog database and create a tablespace for the catalog:
SQL > create tablespace rman_ts datafile <directory>/<name> > size 20M default storage (initial 100K next 100K pctincrease 0);
2> default tablespace rman_ts 3> temporary tablespace temp 4> quota unlimited on rman_ts;
3 Grant the roles and privileges to this user to maintain the recovery catalog and
command interpreter and create the catalog. Use of the MSGLOG (or LOG in Oracle8i) option enables RMAN to output messages and commands to a file.
% rman catalog rman_db1/rman_db1@catdb msglog = catalog.log create catalog tablespace rman_ts; exit;
7 Connect using the RMAN executable on the server containing the target database.
You should log in as a user with SYSDBA privileges on the target database to perform all the backup and recovery operations.
% rman target sys/oracle@db1 Recovery Manager: Release 8.1.5.0.0 - Production RMAN-06005: connected to target database: DB1 (DBID=472633597) RMAN> connect catalog rman_db1/rman_db1@catdb RMAN-06008: connected to recovery catalog database
8 Register the target database in the catalog. If the target database is not registered in
the recovery catalog, the catalog may not be used to store information about the database. Recovery Manager uses the internal database identifier (DBID), which is calculated when the database is first created, as a unique identifier for the database. If you attempt to register a new database that has been created by copying an existing database and then changing the db_name, the register will fail. To back up a copied database, create a new recovery catalog owner, and create the catalog in the new account
RMAN> register database; RMAN-03022: compiling command: register RMAN-03023: executing command: register RMAN-08006: database registered in recovery catalog RMAN-03023: executing command: full resync RMAN-08002: starting full resync of recovery catalog RMAN-08004: full resync complete RMAN> Resync the catalog with target: Add or drop a tablespace Add or drop a data file Add or drop a rollback segment Relocate any database file $ rman target scott/tiger@db01 catalog rman/rman@catdb RMAN > resync catalog;
Catalog command
Use the CATALOG command to add information to the catalog When backup is taken using OS When backup is taken without recovery catalog The CATALOG command stores: Archived logs, data file copies, and control file copies
that belong to the target database Only files with the same database incarnation number RMAN > catalog datafilecopy /u01/db1/backup/system01.bak 2 > tag = SYSTBS0429; RMAN > catalog archivelog 2>/u01/db1/ARCHIVE/arch_267.log;