Thinking Out Loud

June 29, 2013

RMAN using Substitution Variable

Filed under: 11g,RMAN — mdinh @ 5:11 am

bkupinc.rman

&1 = incremental level

&2 = tag

spool log to bkupinc&1_&2..log
connect target;
# maxopenfiles: ASM/striped 1; else 8
# 1 channel per tape drive for tape backup
run {
set command id to "INC&1_&2";
set controlfile autobackup format for device type disk to '/oracle/backup/%d_%F';
allocate channel d1 device type disk format '/oracle/backup/%d_%I_%T_%U.inc&1_&2' maxopenfiles 1;
backup as compressed backupset
incremental level &1 check logical database
filesperset 1 tag="INC&1_&2"
include current controlfile
plus archivelog not backed up 1 times
filesperset 8 tag="INC&1_&2"
;
backup spfile tag="INC&1_&2";
}
exit

$ nohup rman @bkupinc.rman 0 `date '+%a'` > /dev/null 2>&1 &

[1] 2776
[oracle@lax:db01]/home/oracle
$ ls -l *.log
-rw-r--r-- 1 oracle oinstall 1268 Jun 28 22:01 bkupinc0_Fri.log
[oracle@lax:db01]/home/oracle
$
[1]+ Done nohup rman @bkupinc.rman 0 `date '+%a'` > /dev/null 2>&1
[oracle@lax:db01]/home/oracle
$

$ ls -l /oracle/backup/

total 169936
-rw-r----- 1 oracle oinstall 22029824 Jun 28 22:01 DB01_1439793859_20130628_tbodbp63_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall 12934144 Jun 28 22:01 DB01_1439793859_20130628_tcodbp6a_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  1236992 Jun 28 22:01 DB01_1439793859_20130628_tdodbp6d_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  6857728 Jun 28 22:01 DB01_1439793859_20130628_teodbp6f_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall 23293952 Jun 28 22:01 DB01_1439793859_20130628_tfodbp6i_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  1555456 Jun 28 22:01 DB01_1439793859_20130628_tgodbp6l_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  7286272 Jun 28 22:01 DB01_1439793859_20130628_thodbp6m_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  9636352 Jun 28 22:02 DB01_1439793859_20130628_tiodbp6p_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  1377280 Jun 28 22:02 DB01_1439793859_20130628_tjodbp6t_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  5707264 Jun 28 22:02 DB01_1439793859_20130628_tkodbp6u_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall 37765120 Jun 28 22:02 DB01_1439793859_20130628_tlodbp6v_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  4841472 Jun 28 22:02 DB01_1439793859_20130628_tmodbp7e_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall 20168704 Jun 28 22:02 DB01_1439793859_20130628_tnodbp7i_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  2678784 Jun 28 22:02 DB01_1439793859_20130628_toodbp8b_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  1073152 Jun 28 22:02 DB01_1439793859_20130628_tpodbp8i_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  1073152 Jun 28 22:02 DB01_1439793859_20130628_tqodbp8j_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  1073152 Jun 28 22:03 DB01_1439793859_20130628_trodbp8k_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  1073152 Jun 28 22:03 DB01_1439793859_20130628_tsodbp8l_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  1073152 Jun 28 22:03 DB01_1439793859_20130628_ttodbp8n_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  1277952 Jun 28 22:03 DB01_1439793859_20130628_tuodbp8o_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall    42496 Jun 28 22:03 DB01_1439793859_20130628_tvodbp8t_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall    98304 Jun 28 22:03 DB01_1439793859_20130628_u0odbp8u_1_1.inc0_Fri
-rw-r----- 1 oracle oinstall  9830400 Jun 28 22:03 DB01_c-1439793859-20130628-08
[oracle@lax:db01]/home/oracle
$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Jun 28 22:05:12 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DB01 (DBID=1439793859)

RMAN> list backup summary;

using target database control file instead of recovery catalog

List of Backups
===============
Key     TY LV S Device Type Completion Time      #Pieces #Copies Compressed Tag
------- -- -- - ----------- -------------------- ------- ------- ---------- ---
855     B  A  A DISK        28-jun-2013 22:01:42 1       1       YES        INC0_FRI
856     B  A  A DISK        28-jun-2013 22:01:48 1       1       YES        INC0_FRI
857     B  A  A DISK        28-jun-2013 22:01:50 1       1       YES        INC0_FRI
858     B  A  A DISK        28-jun-2013 22:01:52 1       1       YES        INC0_FRI
859     B  A  A DISK        28-jun-2013 22:01:56 1       1       YES        INC0_FRI
860     B  A  A DISK        28-jun-2013 22:01:57 1       1       YES        INC0_FRI
861     B  A  A DISK        28-jun-2013 22:01:59 1       1       YES        INC0_FRI
862     B  A  A DISK        28-jun-2013 22:02:03 1       1       YES        INC0_FRI
863     B  A  A DISK        28-jun-2013 22:02:05 1       1       YES        INC0_FRI
864     B  A  A DISK        28-jun-2013 22:02:06 1       1       YES        INC0_FRI
865     B  0  A DISK        28-jun-2013 22:02:19 1       1       YES        INC0_FRI
866     B  0  A DISK        28-jun-2013 22:02:23 1       1       YES        INC0_FRI
867     B  0  A DISK        28-jun-2013 22:02:48 1       1       YES        INC0_FRI
868     B  0  A DISK        28-jun-2013 22:02:57 1       1       YES        INC0_FRI
869     B  0  A DISK        28-jun-2013 22:02:59 1       1       YES        INC0_FRI
870     B  0  A DISK        28-jun-2013 22:02:59 1       1       YES        INC0_FRI
871     B  0  A DISK        28-jun-2013 22:03:01 1       1       YES        INC0_FRI
872     B  0  A DISK        28-jun-2013 22:03:02 1       1       YES        INC0_FRI
873     B  0  A DISK        28-jun-2013 22:03:03 1       1       YES        INC0_FRI
874     B  0  A DISK        28-jun-2013 22:03:07 1       1       YES        INC0_FRI
875     B  A  A DISK        28-jun-2013 22:03:09 1       1       YES        INC0_FRI
876     B  F  A DISK        28-jun-2013 22:03:10 1       1       YES        INC0_FRI
877     B  F  A DISK        28-jun-2013 22:03:13 1       1       NO         TAG20130628T220311

RMAN> exit

Oracle® Database Backup and Recovery Reference 11g Release 1 (11.1)

June 24, 2013

Invoking RMAN scripts

Filed under: 11g,RMAN — mdinh @ 1:05 am

It’s been more than 4 years since I have had to work with RMAN backup. Previously, sysadmin has been managing database backup using split mirror technology.

Now looking at RMAN from a different angle, calling RMAN scripts from the command line, similar to SQL scripts.

nohup rman @bkupinc0.rman > /dev/null 2>&1 & — Important not to forget @

[oracle@lax:db01]/home/oracle
$ nohup rman @bkupinc0.rman > /dev/null 2>&1 &
[1] 5643
[oracle@lax:db01]/home/oracle
$
[1]+  Done                    nohup rman @bkupinc0.rman > /dev/null 2>&1
[oracle@lax:db01]/home/oracle
$ nohup rman @bkupinc1.rman > /dev/null 2>&1 &
[1] 5669
[oracle@lax:db01]/home/oracle
$
[1]+  Done                    nohup rman @bkupinc1.rman > /dev/null 2>&1
[oracle@lax:db01]/home/oracle

Script: bkupinc0.rman

$ cat bkupinc0.rman
spool log to bkupinc0.log
connect target;
show all;
# maxopenfiles: ASM/striped 1; else 8
# 1 channel per tape drive for tape backup
run {
set command id to "INC0";
set controlfile autobackup format for device type disk to '/oracle/backup/%d_%F';
allocate channel d1 device type disk format '/oracle/backup/%d_%I_%T_%U.inc0' maxopenfiles 1;
backup as compressed backupset
incremental level 0 check logical database
filesperset 1 tag="INC0"
include current controlfile
plus archivelog not backed up 1 times
filesperset 8 tag="INC0"
;
backup spfile tag="INC0";
}
exit

rman checksyntax @bad.rman — Must have @ sign

[oracle@lax:db01]/home/oracle
$ rman checksyntax @bad.rman

Recovery Manager: Release 11.2.0.3.0 - Production on Sun Jun 23 17:20:35 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

RMAN> spool log to bad.log
2> connect target;
3> run {
4> set controlfile autobackup format for device type disk to '/oracle/backup/%d_%F';
5> allocate channel d1 device type disk format '/oracle/backup/%d_%I_%T_%U.bkil0' maxopenfiles 1;
6> backup as compressed backupset
7> incremental level 0 check logical database
8> include controlfile
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "controlfile": expecting one of: "current"
RMAN-01007: at line 8 column 9 file: bad.rman

Can also check spool for results.

[oracle@lax:db01]/home/oracle
$ rman checksyntax @bkupinc0.rman

Recovery Manager: Release 11.2.0.3.0 - Production on Sun Jun 23 17:20:46 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

RMAN> spool log to bkupinc0.log
2> connect target;
3> show all;
4> # maxopenfiles: ASM/striped 1; else 8
5> # 1 channel per tape drive for tape backup
6> run {
7> set command id to "INC0";
8> set controlfile autobackup format for device type disk to '/oracle/backup/%d_%F';
9> allocate channel d1 device type disk format '/oracle/backup/%d_%I_%T_%U.inc0' maxopenfiles 1;
10> backup as compressed backupset
11> incremental level 0 check logical database
12> filesperset 1 tag="INC0"
13> include current controlfile
14> plus archivelog not backed up 1 times
15> filesperset 8 tag="INC0"
16> ;
17> backup spfile tag="INC0";
18> }
19> exit
[oracle@lax:db01]/home/oracle
$ cat bkupinc0.log

The cmdfile has no syntax errors

Recovery Manager complete.
[oracle@lax:db01]/home/oracle
$

I like grouping all backup process into one tag and might get some disagreement on this since I have seen implementation having separate tag for DB, ARC, CF, etc…
If you look at LV column, A=archivelog, 0=incremental level #, F=file backup.

RMAN> list backup summary;

using target database control file instead of recovery catalog

List of Backups
===============
Key     TY LV S Device Type Completion Time      #Pieces #Copies Compressed Tag
------- -- -- - ----------- -------------------- ------- ------- ---------- ---
683     B  A  A DISK        23-jun-2013 16:20:19 1       1       YES        INC0
684     B  A  A DISK        23-jun-2013 16:20:21 1       1       YES        INC0
685     B  A  A DISK        23-jun-2013 16:20:23 1       1       YES        INC0
686     B  A  A DISK        23-jun-2013 16:20:25 1       1       YES        INC0
687     B  A  A DISK        23-jun-2013 16:20:31 1       1       YES        INC0
688     B  A  A DISK        23-jun-2013 16:20:35 1       1       YES        INC0
689     B  A  A DISK        23-jun-2013 16:20:37 1       1       YES        INC0
690     B  0  A DISK        23-jun-2013 16:20:46 1       1       YES        INC0
691     B  0  A DISK        23-jun-2013 16:20:56 1       1       YES        INC0
692     B  0  A DISK        23-jun-2013 16:21:02 1       1       YES        INC0
693     B  0  A DISK        23-jun-2013 16:21:05 1       1       YES        INC0
694     B  0  A DISK        23-jun-2013 16:21:06 1       1       YES        INC0
695     B  0  A DISK        23-jun-2013 16:21:07 1       1       YES        INC0
696     B  0  A DISK        23-jun-2013 16:21:09 1       1       YES        INC0
697     B  0  A DISK        23-jun-2013 16:21:10 1       1       YES        INC0
698     B  0  A DISK        23-jun-2013 16:21:11 1       1       YES        INC0
699     B  0  A DISK        23-jun-2013 16:21:15 1       1       YES        INC0
700     B  A  A DISK        23-jun-2013 16:21:18 1       1       YES        INC0
701     B  F  A DISK        23-jun-2013 16:21:19 1       1       YES        INC0
702     B  F  A DISK        23-jun-2013 16:21:23 1       1       NO         TAG20130623T162120
703     B  A  A DISK        23-jun-2013 16:35:18 1       1       YES        INC1
704     B  1  A DISK        23-jun-2013 16:35:19 1       1       YES        INC1
705     B  1  A DISK        23-jun-2013 16:35:21 1       1       YES        INC1
706     B  1  A DISK        23-jun-2013 16:35:22 1       1       YES        INC1
707     B  1  A DISK        23-jun-2013 16:35:23 1       1       YES        INC1
708     B  1  A DISK        23-jun-2013 16:35:24 1       1       YES        INC1
709     B  1  A DISK        23-jun-2013 16:35:25 1       1       YES        INC1
710     B  1  A DISK        23-jun-2013 16:35:27 1       1       YES        INC1
711     B  1  A DISK        23-jun-2013 16:35:31 1       1       YES        INC1
712     B  A  A DISK        23-jun-2013 16:35:33 1       1       YES        INC1
713     B  F  A DISK        23-jun-2013 16:35:34 1       1       YES        INC1
714     B  F  A DISK        23-jun-2013 16:35:38 1       1       NO         TAG20130623T163536

list backup by file tag inc1;

RMAN> list backup by file tag inc1;

List of Datafile Backups
========================

File Key     TY LV S Ckp SCN    Ckp Time             #Pieces #Copies Compressed Tag
---- ------- -  -- - ---------- -------------------- ------- ------- ---------- ---
1    704     B  1  A 1398232    23-jun-2013 16:35:19 1       1       YES        INC1
2    706     B  1  A 1398235    23-jun-2013 16:35:22 1       1       YES        INC1
3    707     B  1  A 1398236    23-jun-2013 16:35:23 1       1       YES        INC1
4    705     B  1  A 1398233    23-jun-2013 16:35:20 1       1       YES        INC1
5    708     B  1  A 1398238    23-jun-2013 16:35:24 1       1       YES        INC1
8    709     B  1  A 1398239    23-jun-2013 16:35:25 1       1       YES        INC1
9    710     B  1  A 1398240    23-jun-2013 16:35:26 1       1       YES        INC1

List of Archived Log Backups
============================

Thrd Seq     Low SCN    Low Time             BS Key  S #Pieces #Copies Compressed Tag
---- ------- ---------- -------------------- ------- - ------- ------- ---------- ---
1    112     1397853    23-jun-2013 16:21:16 703     A 1       1       YES        INC1
1    113     1398226    23-jun-2013 16:35:17 712     A 1       1       YES        INC1

List of Control File Backups
============================

CF Ckp SCN Ckp Time             BS Key  S #Pieces #Copies Compressed Tag
---------- -------------------- ------- - ------- ------- ---------- ---
1398241    23-jun-2013 16:35:27 711     A 1       1       YES        INC1
List of SPFILE Backups
======================

Modification Time    BS Key  S #Pieces #Copies Compressed Tag
-------------------- ------- - ------- ------- ---------- ---
23-jun-2013 06:00:59 713     A 1       1       YES        INC1

Other RMAN scripts

$ cat restore_preview.rman
connect target;
restore database preview;
restore database preview until time 'TRUNC(sysdate)';
[oracle@lax:db01]/home/oracle
$ cat validate.rman
connect target;
backup validate check logical database;
restore validate database;
restore validate archivelog from time 'sysdate-7';
[oracle@lax:db01]/home/oracle
$

June 21, 2013

Baby is “A” Player !!!

Filed under: Uncategorized — mdinh @ 2:55 am

Disneyland here we come.
20130620_182626

June 7, 2013

Migrating Windows PuTTY registry to Linux

Filed under: linux — mdinh @ 4:14 am

I have over 100+ saved sessions in PuTTY running on Windows and was looking for a way to move those session to Linux.

Here’s a demo on how to move those PuTTY sessions.

First, download pwin2lin.pl on Linux from https://code.google.com/p/pwin2lin/

Next, install PuTTY on Linux from http://pkgs.repoforge.org/putty/

Export Window’s registry containing PuTTY sessions.

E:\Linux>dir /b
database
deinstall
examples
grid
OEL6.3
ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
oracleasmlib-2.0.4-1.el6.x86_64.rpm
p10404530_112030_Linux-x86-64_1of7.zip
p10404530_112030_Linux-x86-64_2of7.zip
p10404530_112030_Linux-x86-64_3of7.zip
p10404530_112030_Linux-x86-64_6of7.zip
p10404530_112030_Linux-x86-64_7of7.zip
putty-0.62-1.el6.rf.x86_64.rpm
pwin2lin.pl
raccheck.zip

E:\Linux>regedit /e "E:\Linux\putty.reg" "HKEY_CURRENT_USER\Software\SimonTatham\PuTTY"

E:\Linux>dir /b
database
deinstall
examples
grid
OEL6.3
ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip
oracleasmlib-2.0.4-1.el6.x86_64.rpm
p10404530_112030_Linux-x86-64_1of7.zip
p10404530_112030_Linux-x86-64_2of7.zip
p10404530_112030_Linux-x86-64_3of7.zip
p10404530_112030_Linux-x86-64_6of7.zip
p10404530_112030_Linux-x86-64_7of7.zip
putty-0.62-1.el6.rf.x86_64.rpm
putty.reg
pwin2lin.pl
raccheck.zip

E:\Linux>

Import to Linux

[oracle@rac01 ~]$ cp /media/sf_Linux/putty.reg .
[oracle@rac01 ~]$ ll putty.reg
-rwxr-x--- 1 oracle dba 15376 Jun  6 21:05 putty.reg
[oracle@rac01 ~]$ ./pwin2lin.pl ./putty.reg ~/.putty
mkdir /home/oracle/.putty
mkdir /home/oracle/.putty/sessions
[oracle@rac01 ~]$ cd .putty/sessions/
[oracle@rac01 sessions]$ ll
total 8
-rw-r--r-- 1 oracle dba 4257 Jun  6 21:06 rac01
[oracle@rac01 sessions]$h

PuTTY

Blog at WordPress.com.