RMAN Command reference

===================================
R-M-A-N =
===================================
Connect:
$rman target /
$rman nocatalog target /
$rman nocatalog target sys/aziz@JKTDB2
$rman target sys/aziz@JKTDB2

RMAN> shutdown;
RMAN> shutdown immediate;

RMAN> startup mount; >>startup an instance and mounting database
RMAN> startup nomout; >>startup an instance without mounting database
RMAN> startup restrict; >>restricting access to an instance at startup
RMAN> ALTER SYSTEM DISABLE RESTRICTED SESSION; >>disable the restricted session
RMAN> STARTUP FORCE; >>forcing an instance to start
RMAN> STARTUP OPEN RECOVER >>Starting an Instance, Mounting a Database,
and Starting Complete Media Recovery
RMAN> connect target sys/aziz@jktdb2;
RMAN> startup mount;
RMAN> register database; >>register target database to recovery catalog
RMAN> reset database; >>create new database incarnation record in the

recovery catalog
RMAN> backup database;
RMAN> backup current controlfile;
RMAN> backup database plus archivelog;
RMAN> backup archivelog all;
RMAN> list backup; >>list all file that was backed up
RMAN> list backup summary;
RMAN> restore database;
RMAN> restore archivelog all;
RMAN> recover database;
RMAN> restore datafile ‘C:\ORACLE\ORADATA\JKTDB2\USERS01.DBF’;
RMAN> recover datafile ‘C:\ORACLE\ORADATA\JKTDB2\USERS01.DBF’;
RMAN> Recover database until cancel using backup controlfile;
RMAN> Alter database open resetlogs;
RMAN> allocate channel for maintenance type disk;
RMAN> crosscheck backup of database;
RMAN> delete expired backup of database;
RMAN> crosscheck backup of archivelog all;
RMAN> delete expired backup of archivelog all;
RMAN> change archivelog all crosscheck;
RMAN> resync catalog;
RMAN> crosscheck backup of archivelog all;
RMAN> sql ‘alter tablespace USERS offline immediate’;
RMAN> recover tablespace USERS;
RMAN> sql ‘alter tablespace USERS online’;

—————————————————————
configure =
—————————————————————
RMAN>configure default device type to ‘sbt_tape’; >>to tape
RMAN>configure default device type to DISK; >>to disk
rman>configure controlfile autobackup format for device type ‘sbt_tape’ to ‘%F’;
RMAN>configure controlfile autobackup on;
RMAN>CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

RMAN>CONFIGURE RETENTION POLICY TO REDUNDANCY 3; >>Retain three backups of each datafile:
RMAN> resync catalog;

—————————————————————
Restore & Recover The Whole Database=
—————————————————————
run {
shutdown immediate; # use abort if this fails
startup mount;
restore database;
recover database;
alter database open;
}
—————————————————————-
Restore & Recover A Subset Of The Database
A subset of the database can be restored in a similar fashion:
—————————————————————-
run {
sql ‘ALTER TABLESPACE users OFFLINE IMMEDIATE’;
restore tablespace users;
recover tablespace users;
sql ‘ALTER TABLESPACE users ONLINE’;
}
—————————————————————–
SAMPLE RMAN RUN BLOCK (as file:backup_full.rman)

run {
allocate channel d1 type disk;
backup full database format ’/export/rman/rman_%n_%T_%s_%p.bus’;
}

then run it :
$ rman nocatalog target / \
> cmdfile=’backup_full.rman’ log=’/export/rman/rman.log’
RMAN> 2> 3> 4> 5>
—————————————————————–
Crosscheck backupset:
RMAN> allocate channel for maintenance type ‘sbt_tape’;
RMAN> crosscheck backupset of database;

Delete expired backups:
RMAN> allocate channel for maintenance type ‘sbt_tape’;
RMAN> delete expired backupset of database;
—————————————————————–

#############################
===================================
S-Q-L P-L-U-S=
===================================
#################################
Connect:
$sqlplus /nolog >>start sqlplus withaut connecting to database
$sqlplus “/ as sysdba”
CONNECT username/password AS SYSDBA
CONNECT sys/password@jktdb2 AS SYSDBA
Enter username: sys/aziz as sysdba

SQL> alter database archivelog; >>turn on archivelog
SQL> alter database noarchivelog; >>turn off archivelog
SQL> alter database open;
SQL> select log_mode from v$database;
SQL> select DEST_NAME,STATUS,DESTINATION from V$ARCHIVE_DEST;
SQL> archive log list

SQL> startup nomount;
SQL> alter database mount;
SQL> select * from all_users;
SQL> select status from v$instance;
SQL> alter database open;
SQL> select * from DBA_ROLE_PRIVS;
SQL> ALTER USER “BENR” IDENTIFIED BY “passwd”; >>change password user benr
SQL> select * from DBA_ROLE_PRIVS where grantee = ’BEN’;
SQL> grant resource to ben;
SQL> revoke resource from ben;
SQL> select FILE#,STATUS,ENABLED,NAME from v$datafile;
SQL> SELECT LOG_MODE FROM SYS.V$DATABASE;
SQL> select FILE#,STATUS,ENABLED,NAME from v$datafile;
{jika ada yang offline, online dengan command:}
SQL> alter database datafile ’/u02/oradata/cuddle/users01.dbf’ online;
SQL> alter tablespace USERS online;

SQL> startup pfile=/u01/app/oracle/product/10.1.0/db_1/dbs/spfiletesting.ora
SQL> alter database open resetlogs;

————————
this used for FLASHBACK:
SQL> alter system set DB_FLASHBACK_RETENTION_TARGET=4320; >>Retention 4320 minutes (or 72 hours)
SQL> alter system set DB_RECOVERY_FILE_DEST_SIZE=536870912; >>a recovery file size of 512MB
SQL> alter system set DB_RECOVERY_FILE_DEST=’/u02/fra’; >>location for the file recovery area

(FRA)
SQL> alter database flashback on;
SQL> alter database open;
————————

RESTORE CONTROLFILE
===================================
sqlplus “/ as sysdba”
SQL>startup nomout;

RMAN>set DBID=2231352083
RMAN>CONNECT TARGET
RMAN>run
2>{
3>set controlfile autobackup format for device type ‘sbt_tape’ to ‘%F’;
4>allocate channel t1 device type ‘sbt_tape’;
5>restore controlfile from autobackup MAXSEQ 5 MAXDAYS 9;
6> mount database;
7> } [enter]

executing command: SET CONTROLFILE AUTOBACKUP FORMAT

allocated channel: t1
channel t1: sid=10 devtype=SBT_TAPE
channel t1: VERITAS NetBackup for Oracle – Release 5.0GA (2002111220)

Starting restore at 25-JAN-07

channel t1, looking for controlfile autobackup on day: 20070125
channel t1, controlfile autobackup found: c-2231352083-20070125-01
channel t1, controlfile autobackup restore complete
replicating controlfile
input filename=C:\ORACLE\ORADATA\JKTDB2\CONTROL01.CTL
output filename=C:\ORACLE\ORADATA\JKTDB2\CONTROL02.CTL
output filename=C:\ORACLE\ORADATA\JKTDB2\CONTROL03.CTL
Finished restore at 25-JAN-07

database mounted
released channel: t1

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

ORACLE COMMAND FOR UNIX
———————–
./emca > run Oracle Enterprise Manager
./dbca > run database configuration assistant
./dbstart > start database
. ./dev.env > script buat link $ORACLE_HOME
. ./oraenv > script buat link $ORACLE_HOME
./lsnrctl <stop|start> > start and stop the listener control utility
./cmctl <stop|start> > the Oracle connection manager utility
./netca > Oracle Net configuration Assistant GUI
./netmgr > Oracle net Manager
./odma > Oracle Data Migration Assistant
./owm > Oracle Wallet Manager
agentctl stop > stop Agent Configuration Assistan
./oemapp console > run Oracle Enterprise Manager Console

bash-2.05# /usr/sbin/./prtconf | grep size >>cek RAM

TESTING COMMAND:
================

RMAN> show all;

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO ‘SBT_TAPE’;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE ‘SBT_TAPE’ TO ‘%F’;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘%F’; # default
CONFIGURE DEVICE TYPE SBT_TAPE PARALLELISM 1; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘C:\ORACLE\ORA90\DATABASE\SNCFJKTDB2.ORA’
; # default

RMAN>

STEP BACKUP
=============
DATAFILE
ARCHIVELOG
CONTROLFILE

STEP RESTORE
==============
CONTROLFILE
ARCHIVELOG
DATAFILE

connected to target database: JKTDB2 (DBID=2231352083)