Oracle Database Experts

By Charles Kim

August 13th, 2007

Data Guard Broker Setup

Data Guard Broker Preparation

Repeat these steps on both the primary and standby databases:

SQL> alter system set dg_broker_config_file1=’+DATA/dba11g/dba11g.dat’ scope=both;

System altered.

 

SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE scope=both;

System altered.

 

Data Guard Broker Configuration

DBA11g > dgmgrl sys/oracle123

DGMGRL for Linux: Version 11.1.0.6.0 – Production

 

Copyright (c) 2000, 2005, Oracle. All rights reserved.

 

Welcome to DGMGRL, type “help” for information.

Connected.

DGMGRL> create configuration ‘DBA_DG’ as primary database is ‘DBA11g’ connect identifier is DBA11g.dbaexpert.com;

Configuration “DBA_DG” created with primary database “DBA11g”

DGMGRL> show configuration

 

Configuration

Name: DBA_DG

Enabled: NO

Protection Mode: MaxPerformance

Databases:

DBA11g – Primary database

 

Fast-Start Failover: DISABLED

 

Current status for “DBA_DG”:

DISABLED

 

DGMGRL> show configuration verbose;

 

Configuration

Name: DBA_DG

Enabled: NO

Protection Mode: MaxPerformance

Databases:

DBA11g – Primary database

 

Fast-Start Failover: DISABLED

 

Current status for “DBA_DG”:

DISABLED

DGMGRL> add database ‘DBA11gDR’ as connect identifier is DBA11gDR maintained as physical;

Database “DBA11gDR” added

DGMGRL> show configuration

 

Configuration

Name: DBA_DG

Enabled: NO

Protection Mode: MaxPerformance

Databases:

DBA11g – Primary database

DBA11gDR – Physical standby database

 

Fast-Start Failover: DISABLED

 

Current status for “DBA_DG”:

DISABLED

 

DGMGRL> show configuration verbose;

 

Configuration

Name: DBA_DG

Enabled: NO

Protection Mode: MaxPerformance

Databases:

DBA11g – Primary database

DBA11gDR – Physical standby database

 

Fast-Start Failover: DISABLED

 

Current status for “DBA_DG”:

DISABLED

 

DGMGRL> show configuration

 

Configuration

Name: DBA_DG

Enabled: NO

Protection Mode: MaxPerformance

Databases:

DBA11g – Primary database

DBA11gDR – Physical standby database

 

Fast-Start Failover: DISABLED

 

Current status for “DBA_DG”:

DISABLED

August 13th, 2007

Data Guard 11g Database Duplication Over Network Logfile

orapwd file=$ORACLE_HOME/dbs/orapwDBA11g entries=25 password=oracle123

DBA11gDR > ./dup.ksh

 

Recovery Manager: Release 11.1.0.6.0 – Production on Mon Aug 13 21:46:38 2007

 

Copyright (c) 1982, 2007, Oracle. All rights reserved.

 

RMAN>

connected to target database: DBA11G (DBID=231973368)

 

RMAN>

connected to auxiliary database: DBA11GDR (not mounted)

 

RMAN>

RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> 22> 23> 24> 25> 26> 27> 28> 29> 30> 31> 32>

using target database control file instead of recovery catalog

allocated channel: prmy1

channel prmy1: SID=110 device type=DISK

 

allocated channel: prmy2

channel prmy2: SID=132 device type=DISK

 

allocated channel: prmy3

channel prmy3: SID=111 device type=DISK

 

allocated channel: prmy4

channel prmy4: SID=109 device type=DISK

 

allocated channel: stby

channel stby: SID=98 device type=DISK

 

Starting Duplicate Db at 13-AUG-07

 

contents of Memory Script:

{

backup as copy reuse

file ‘/apps/oracle/product/11.1.0/DB/dbs/orapwDBA11g’ auxiliary format

‘/apps/oracle/product/11.1.0/DB/dbs/orapwDBA11gDR’ file

‘+DATA/dba11g/spfiledba11g.ora’ auxiliary format

‘/apps/oracle/product/11.1.0/DB/dbs/spfileDBA11gDR.ora’ ;

sql clone “alter system set spfile= ”/apps/oracle/product/11.1.0/DB/dbs/spfileDBA11gDR.ora””;

}

executing Memory Script

 

Starting backup at 13-AUG-07

Finished backup at 13-AUG-07

 

sql statement: alter system set spfile= ”/apps/oracle/product/11.1.0/DB/dbs/spfileDBA11gDR.ora”

 

contents of Memory Script:

{

sql clone “alter system set audit_file_dest =

”/apps/oracle/admin/DBA11gDR/adump” comment=

”” scope=spfile”;

sql clone “alter system set dispatchers =

”(PROTOCOL=TCP) (SERVICE=DBA11gDRXDB)” comment=

”” scope=spfile”;

sql clone “alter system set db_unique_name =

”DBA11gDR” comment=

”” scope=spfile”;

sql clone “alter system set db_file_name_convert =

”/DBA11g/”, ”/DBA11gDR/” comment=

”” scope=spfile”;

sql clone “alter system set log_file_name_convert =

”/DBA11g/”, ”/DBA11gDR/” comment=

”” scope=spfile”;

sql clone “alter system set control_files =

”/nfs02/oradata/DBA11gDR/control.ctl” comment=

”” scope=spfile”;

sql clone “alter system set log_archive_max_processes =

5 comment=

”” scope=spfile”;

sql clone “alter system set fal_client =

”DBA11gDR” comment=

”” scope=spfile”;

sql clone “alter system set fal_server =

”DBA11g” comment=

”” scope=spfile”;

sql clone “alter system set standby_file_management =

”AUTO” comment=

”” scope=spfile”;

sql clone “alter system set log_archive_config =

”dg_config=(DBA11g,DBA11gDR)” comment=

”” scope=spfile”;

sql clone “alter system set log_archive_dest_1 =

‘’service=DBA11g LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=DBA11g” comment=

”” scope=spfile”;

shutdown clone immediate;

startup clone nomount ;

}

executing Memory Script

 

sql statement: alter system set audit_file_dest = ”/apps/oracle/admin/DBA11gDR/adump” comment= ”” scope=spfile

 

sql statement: alter system set dispatchers = ”(PROTOCOL=TCP) (SERVICE=DBA11gDRXDB)” comment= ”” scope=spfile

 

sql statement: alter system set db_unique_name = ”DBA11gDR” comment= ”” scope=spfile

 

sql statement: alter system set db_file_name_convert = ”/DBA11g/”, ”/DBA11gDR/” comment= ”” scope=spfile

 

sql statement: alter system set log_file_name_convert = ”/DBA11g/”, ”/DBA11gDR/” comment= ”” scope=spfile

 

sql statement: alter system set control_files = ”/nfs02/oradata/DBA11gDR/control.ctl” comment= ”” scope=spfile

 

sql statement: alter system set log_archive_max_processes = 5 comment= ”” scope=spfile

 

sql statement: alter system set fal_client = ”DBA11gDR” comment= ”” scope=spfile

 

sql statement: alter system set fal_server = ”DBA11g” comment= ”” scope=spfile

 

sql statement: alter system set standby_file_management = ”AUTO” comment= ”” scope=spfile

 

sql statement: alter system set log_archive_config = ”dg_config=(DBA11g,DBA11gDR)” comment= ”” scope=spfile

 

sql statement: alter system set log_archive_dest_1 = ‘’service=DBA11g LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=DBA11g” comment= ”” scope=spfile

 

Oracle instance shut down

 

connected to auxiliary database (not started)

Oracle instance started

 

Total System Global Area 318054400 bytes

 

Fixed Size 1299624 bytes

Variable Size 96471896 bytes

Database Buffers 213909504 bytes

Redo Buffers 6373376 bytes

 

contents of Memory Script:

{

backup as copy current controlfile for standby auxiliary format ‘/nfs02/oradata/DBA11gDR/control.ctl’;

sql clone ‘alter database mount standby database’;

}

executing Memory Script

 

Starting backup at 13-AUG-07

channel prmy1: starting datafile copy

copying standby control file

output file name=/apps/oracle/product/11.1.0/DB/dbs/snapcf_DBA11g.f tag=TAG20070813T214752 RECID=3 STAMP=630539277

channel prmy1: datafile copy complete, elapsed time: 00:00:07

Finished backup at 13-AUG-07

 

sql statement: alter database mount standby database

RMAN-05529: WARNING: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.

 

contents of Memory Script:

{

set newname for tempfile 1 to

“+data”;

switch clone tempfile all;

set newname for datafile 1 to

“+data”;

set newname for datafile 2 to

“+data”;

set newname for datafile 3 to

“+data”;

set newname for datafile 4 to

“+data”;

set newname for datafile 5 to

“+data”;

set newname for datafile 6 to

“+data”;

backup as copy reuse

datafile 1 auxiliary format

“+data” datafile

2 auxiliary format

“+data” datafile

3 auxiliary format

“+data” datafile

4 auxiliary format

“+data” datafile

5 auxiliary format

“+data” datafile

6 auxiliary format

“+data” ;

sql ‘alter system archive log current’;

}

executing Memory Script

 

executing command: SET NEWNAME

 

renamed tempfile 1 to +data in control file

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

Starting backup at 13-AUG-07

channel prmy1: starting datafile copy

input datafile file number=00001 name=+DATA/dba11g/datafile/system.270.630497885

channel prmy2: starting datafile copy

input datafile file number=00002 name=+DATA/dba11g/datafile/sysaux.276.630497887

channel prmy3: starting datafile copy

input datafile file number=00005 name=+DATA/dba11g/datafile/example.268.630498257

channel prmy4: starting datafile copy

input datafile file number=00006 name=+DATA/dba11g/datafile/tools.280.630536173

output file name=+DATA/dba11gdr/datafile/example.259.630539237 tag=TAG20070813T214807 RECID=0 STAMP=0

channel prmy3: datafile copy complete, elapsed time: 00:00:46

channel prmy3: starting datafile copy

input datafile file number=00003 name=+DATA/dba11g/datafile/undotbs1.274.630497891

output file name=+DATA/dba11gdr/datafile/tools.258.630539237 tag=TAG20070813T214807 RECID=0 STAMP=0

channel prmy4: datafile copy complete, elapsed time: 00:00:47

channel prmy4: starting datafile copy

input datafile file number=00004 name=+DATA/dba11g/datafile/users.273.630497891

output file name=+DATA/dba11gdr/datafile/users.256.630539283 tag=TAG20070813T214807 RECID=0 STAMP=0

channel prmy4: datafile copy complete, elapsed time: 00:00:07

output file name=+DATA/dba11gdr/datafile/undotbs1.257.630539281 tag=TAG20070813T214807 RECID=0 STAMP=0

channel prmy3: datafile copy complete, elapsed time: 00:00:17

output file name=+DATA/dba11gdr/datafile/sysaux.260.630539237 tag=TAG20070813T214807 RECID=0 STAMP=0

channel prmy2: datafile copy complete, elapsed time: 00:02:25

output file name=+DATA/dba11gdr/datafile/system.261.630539237 tag=TAG20070813T214807 RECID=0 STAMP=0

channel prmy1: datafile copy complete, elapsed time: 00:02:35

Finished backup at 13-AUG-07

 

sql statement: alter system archive log current

 

contents of Memory Script:

{

switch clone datafile all;

}

executing Memory Script

 

datafile 1 switched to datafile copy

input datafile copy RECID=3 STAMP=630539391 file name=+DATA/dba11gdr/datafile/system.261.630539237

datafile 2 switched to datafile copy

input datafile copy RECID=4 STAMP=630539391 file name=+DATA/dba11gdr/datafile/sysaux.260.630539237

datafile 3 switched to datafile copy

input datafile copy RECID=5 STAMP=630539391 file name=+DATA/dba11gdr/datafile/undotbs1.257.630539281

datafile 4 switched to datafile copy

input datafile copy RECID=6 STAMP=630539391 file name=+DATA/dba11gdr/datafile/users.256.630539283

datafile 5 switched to datafile copy

input datafile copy RECID=7 STAMP=630539391 file name=+DATA/dba11gdr/datafile/example.259.630539237

datafile 6 switched to datafile copy

input datafile copy RECID=8 STAMP=630539391 file name=+DATA/dba11gdr/datafile/tools.258.630539237

Finished Duplicate Db at 13-AUG-07

 

sql statement: alter system set log_archive_config=”dg_config=(DBA11g,DBA11gDR)”

 

sql statement: alter system set log_archive_dest_1=’’service=DBA11gDR LGWR ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=DBA11gDR”

 

sql statement: alter system set log_archive_max_processes=5

 

sql statement: alter system set fal_client=DBA11g

 

sql statement: alter system set fal_server=DBA11gDR

 

sql statement: alter system set standby_file_management=AUTO

 

sql statement: alter system set log_archive_dest_state_1=enable

 

sql statement: alter system archive log current

 

allocated channel: stby

channel stby: SID=146 device type=DISK

 

sql statement: alter database recover managed standby database using current logfile disconnect

released channel: prmy1

released channel: prmy2

released channel: prmy3

released channel: prmy4

released channel: stby

August 13th, 2007

Script to export Discoverer Workbook from the Discoverer Repository

 

 

set serveroutput on size unlimited

set lines 32767 trims on pages 0 feed off head off ver off

spool /tmp/workbook.log

DECLARE

cursor c1 is

SELECT ‘/workbook “‘||docs.doc_name ||’”‘ wk

FROM EUL5_DOCUMENTS docs, EUL5_EUL_USERS users

WHERE users.eu_id = docs.doc_eu_id ;

v_text varchar(32000) :=  null;

v_text1 varchar(32000) := null;

v_text2 varchar(32000) := null;

v_text3 varchar(32000) := null;

v_text4 varchar(32000) := null;

v_text5 varchar(32000) := null;

v_text6 varchar(32000) := null;

v_text7 varchar(32000) := null;

v_text8 varchar(32000) := null;

v_text9 varchar(32000) := null;

v_counter number := 0;

 

v_max_length number := 8000;

v_command varchar2(1000) := ‘c:\oracle\BI\bin\dis51adm /connect d4osys/ea1sh2an3di4@sony /eul D4OSYS /export c:\temp\workbook’;

 

BEGIN

for r1 in c1 loop

– dbms_output.put_line(r1.wk);

v_text := v_text ||’ ‘|| r1.wk;

 

if length(v_text) > v_max_length then

  if v_counter = 0 then

    v_text1 := v_text;

    dbms_output.put_line(v_command||v_counter||’.eex’||v_text1);

  elsif v_counter = 1 then

    v_text2 := v_text;

    dbms_output.put_line(v_command||v_counter||’.eex’||v_text2);

  elsif v_counter = 2 then

    v_text3 := v_text;

    dbms_output.put_line(v_command||v_counter||’.eex’||v_text3);

  elsif v_counter = 3 then

    v_text4 := v_text;

    dbms_output.put_line(v_command||v_counter||’.eex’||v_text4);

  elsif v_counter = 4 then

    v_text5 := v_text;

    dbms_output.put_line(v_command||v_counter||’.eex’||v_text5);

  elsif v_counter = 5 then

    v_text6 := v_text;

    dbms_output.put_line(v_command||v_counter||’.eex’||v_text6);

  elsif v_counter = 6 then

    v_text7 := v_text;

    dbms_output.put_line(v_command||v_counter||’.eex’||v_text7);

  elsif v_counter = 7 then

    v_text8 := v_text;

    dbms_output.put_line(v_command||v_counter||’.eex’||v_text8);

  elsif v_counter = 8 then

    v_text9 := v_text;

    dbms_output.put_line(v_command||v_counter||’.eex’||v_text9);

  end if;

  v_text := NULL;

  v_counter := v_counter + 1;

end if;

 

end loop;

/*

dbms_output.put_line(‘Length v_text: ‘||length(v_text));

dbms_output.put_line(‘Length v_text1: ‘||length(v_text1));

dbms_output.put_line(‘Length v_text2: ‘||length(v_text2));

dbms_output.put_line(‘Length v_text3: ‘||length(v_text3));

dbms_output.put_line(‘Length v_text4: ‘||length(v_text4));

dbms_output.put_line(‘Length v_text5: ‘||length(v_text5));

dbms_output.put_line(‘Length v_text6: ‘||length(v_text6));

dbms_output.put_line(‘Length v_text7: ‘||length(v_text7));

dbms_output.put_line(‘Length v_text8: ‘||length(v_text8));

dbms_output.put_line(‘Length v_text9: ‘||length(v_text9));

*/

 

dbms_output.put_line(‘c:\oracle\BI\bin\dis51adm /connect d4osys/ea1sh2an3di4@sony /eul D4OSYS /export c:\temp\workbook.eex ‘||v_text);

 

end;

/

spool off

 

Documented By:

Charles

Oracle Database Administration

Oracle RAC DBA

http://www.dbaexpert.com

August 13th, 2007

ASM for non-RAC

In Oracle 10g, this is the output:

cd $ORACLE_HOME/bin

[root@rac103 ASM]# cd bin
[root@rac103 bin]# localconfig add
-bash: localconfig: command not found
[root@rac103 bin]# ls -lt *local*
-rwxr-xr-x 1 oracle oinstall 21991 Aug 12 16:21 localconfig
[root@rac103 bin]# ./localconfig add
/etc/oracle does not exist. Creating it now.
Successfully accumulated necessary OCR keys.
Creating OCR keys for user ‘root’, privgrp ‘root’..
Operation successful.
Configuration for local CSS has been initialized

Adding to inittab
Startup will be queued to init within 90 seconds.
Checking the status of new Oracle init process…
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
rac103
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)

Now, let’s configure ASM:

|