===================================
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)
Hi Mr. Aziz,
I am happy to recieve ur RMAN reference all the commands from the net.
Thank You
Assalamualaikum,
Brother, i work Veritas Netbackup 6.5. I want to delete expired archivelog files so that it does not consume disk space in Unix. My question is how i could delete archive log older than 15 days? Do i have to delete from tape? How i could make sure that the deleted archivelog is backedup into tape? Please provide the steps involve to delete the archivelog.
wa’alaikum salam.
my advice; don’t delete expired archivelog manually from OS, cause the information of archivelog (that you manually deleted) still saved on control file, if so perform the crosscheck command:
crosscheck archivelog all;
delete expired archivelog all;
{to delete archivelog older than 15 days, run:
delete archivelog all completed before ‘sysdate-15’;
I think you don’t need to delete it from tape if your goal is just to make free disk space. run ‘list backup;’ to see the list of all file that was backed up.
more info, just read ‘Setting Up a Flash Recovery Area for RMAN‘
other link:
http://www.databasejournal.com/img/Oracle_10g_RMAN_Listing2.html
http://www.databasejournal.com/features/oracle/article.php/3446681
http://www.fadalti.com/oracle/database/rman_effective_use.htm
Hi, I need you help about RMAN backup problem from log below.
============oragentd_197_198.log=============
04/01 14:26:29(10240) – The Oracle Database SID to be backed up is [BILLARCH]
04/01 14:26:29(10240) – The backup job option is RECOVERY MANAGER
04/01 14:26:29(10240) – Backup ORACLE: to TAPE003 session 33
04/01 14:26:34(10240) – Backup of this DB Object finished successfully
04/01 14:26:34(10240) – Backup of Oracle DB backup piece 16jcnvka_1_1 is successful
04/01 14:27:04(10240) – getTapeFileName: Sending WATCH DOG message to server.
04/01 14:32:41(10240) – Backup ORACLE: to TAPE003 session 34
04/01 14:32:41(10240) – Backup of this DB Object finished successfully
04/01 14:32:41(10240) – Backup of Oracle DB backup piece 17jco001_1_1 is successful
04/01 14:33:11(10240) – getTapeFileName: Sending WATCH DOG message to server.
04/01 14:38:11(10240) – getTapeFileName: Sending WATCH DOG message to server.
04/01 14:38:39(10240) – getCurrentOracleVersion – return status = 0
04/01 14:39:19(10240) – Backup piece 16jcnvka_1_1 has not been registered by RMAN yet. No Oracle object to catalog for it at this point
04/01 14:39:59(10240) – Backup piece 17jco001_1_1 has not been registered by RMAN yet. No Oracle object to catalog for it at this point
04/01 14:39:59(10240) – The Database Object backup returned successfully
04/01 14:40:03(10240) – PAGSendEOJ() successfully sent the End of Job information
===========================
It is show me at 14:39:19 about ‘Backup piece xxx has not been registered by RMAN’ , How to fix it ?
This just my thought, Correct me if I wrong..
its seem your target database has not been registered. connect to database then run:
RMAN> REGISTER DATABASE;
Aziz,
Asalem elakhim
Thanks for the RMAN commands regarding archivelog.
I need to schedule the ‘crosscheck’ and ‘delete’ using OEM. I want OEM to do this task automatically instead of me do them manually.
But where do I specify RMAN commands in Enterprise Manager?
Shokran
Wa’alaikum salam Jeff
OEM has limitation, I think better for you to use OS Scheduler to execute your RMAN script like cron jobs in linux and Scheduled Tasks in Windows.
and you can also create batch file; here I copy-paste from forum:
—-
you can schedule your backup by writing one rman script(you should have recovery catalog in which script will be stored) and then create two file one is batch file(schedule batch file with Scheduler) needs to login on rman and execute another file(with .rcv extension )
Batch file may like this
rman target ‘userid/password@’ catalog ‘userid/password@’ cmdfile ‘D:\RMAN_BATCH\daily_backup.rcv’
.RCV example
run { execute script daily_full_backup;}
—-
Sorry I haven’t an Oracle box to try right now..check Oracle documentation for more details.
Azia! This is a good collection of RMAN commands. Only if you can add some sample scripts for backup and recovery, just a tought.
I have a question. We have an issue where RMAN seems to hang. Here is an example of the log.
Recovery Manager: Release 9.2.0.6.0
.
.
.
RMAN>
connected to recovery catalog database
RMAN>
connected to target database: TEST (DBID=4064894153)
RMAN> 2> 3> 4> 5> 6>…11>
……………………………………….
We are using CommVault. There error says: The instance of TEST not in MOUNTED mode before offline backup
Any ideas why it is not “MOUNTING”?
Thanks in advance for all your help.
I really like your site. It is sites like these I can appreciate because I know the person took the time to enter the info. Thanks
Hi,
I have a problem about RMAN backup by CA BrightStor was failed everyday with message below.
==============================
04/26 01:33:23(32485402) – A job has been received from BrightStor ARCserve Backup running on host 126.10.3.10
04/26 01:33:23(32485402) – Oracle Agent license is valid
04/26 01:33:23(32485402) – The Oracle Database SID to be backed up is [BRSPROD]
04/26 01:33:23(32485402) – Using shared memory mode to communicate with media
04/26 01:33:23(32485402) – The backup job option is RECOVERY MANAGER
04/26 01:33:23(32485402) – Backup ORACLE: to RMANDWPOOL_RMANC1 session 8
04/26 05:45:29(32485402) – Backup of this DB Object finished successfully
04/26 05:45:29(32485402) – Backup of Oracle DB backup piece d3kddb6k_1_1 is successful
04/26 05:45:59(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 05:46:23(32485402) – Backup ORACLE: to RMANDWPOOL_RMANC1 session 9
04/26 10:17:59(32485402) – Backup of this DB Object finished successfully
04/26 10:17:59(32485402) – Backup of Oracle DB backup piece d6kddq15_1_1 is successful
04/26 10:18:29(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 10:18:59(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 10:19:29(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 10:19:59(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 10:20:29(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 10:20:59(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 10:21:29(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 10:21:59(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 10:22:29(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 10:22:59(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 10:23:29(32485402) – getTapeFileName: Sending WATCH DOG message to server.
“oragentd_4301_431.log” [Read only] 262 lines, 11465 characters
04/26 11:14:59(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 11:15:29(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 11:15:59(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 11:16:29(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 11:16:59(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 11:17:29(32485402) – getTapeFileName: Sending WATCH DOG message to server.
04/26 11:17:59(32485402) – DSABackupRmanData() Failed getting RMAN object name : TIMEDOUT
04/26 11:17:59(32485402) – AE360085 RMAN has possibly exited after a time out. Please verify the SBT_TIMEOUT value in sbt.cfg
04/26 11:17:59(32485402) – AE360058 Job Aborted due to system error
04/26 11:17:59(32485402) – Job Aborted [OBKBackup_115]
04/26 11:17:59(32485402) – AE360074 The Oracle database backup failed. return code [-1]
04/26 11:17:59(32485402) – AW360078 Please refer to the Backup Agent log file
=========
I tried to set SBT_TIMEOUT with long (60-600),but it’s show me a same error, please help to recommend or how to fix it.