Wednesday, June 2, 2010

create logical standby


TO STOP ARCHIVAL GAP

# Start the standby databases and listeners before starting the primary database.
# Shut down the primary database before shutting down the standby database

* Creation of Logical Standby database (oracle 10gr2)

PRIMARY --> STANDBY

***** Preparing the Primary Database for Standby Database Creation *****

1. Enable Forced Logging

SQL> ALTER DATABASE FORCE LOGGING;

2. Configure a Standby Redo Log

- Ensure log file sizes are identical on the primary and standby databases.
- Determine the appropriate number of standby redo log file groups.
- Verify related database parameters and settings.
- Create standby redo log file groups.
SQL> select MEMBER from v$logfile;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 5
('/oravl04/oradata/PRIMARY/redo_gE_m01.dbf',
'/oravl04/oradata/PRIMARY/redo_gE_m02.dbf') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 6
('/oravl04/oradata/PRIMARY/redo_gF_m01.dbf',
'/oravl04/oradata/PRIMARY/redo_gF_m02.dbf') SIZE 50M;

- Verify the standby redo log file groups were created.

SQL> SELECT GROUP#,THREAD#,SEQUENCE#,ARCHIVED,STATUS FROM V$STANDBY_LOG;

3. Set Primary Database Initialization Parameters

#############################################################################################################
# Instance configured as Primary database (Standby STANDBY )
#############################################################################################################


##########################################
# Standby Parameters #
##########################################

DB_UNIQUE_NAME = PRIMARY
LOG_ARCHIVE_CONFIG = 'DG_CONFIG=(PRIMARY,STANDBY)'
LOG_ARCHIVE_DEST_1 = 'LOCATION=/oravl01/oracle/adm/PRIMARY/arc/local_arc VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PRIMARY'
LOG_ARCHIVE_DEST_2 = 'SERVICE=STANDBY LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STANDBY'
LOG_ARCHIVE_DEST_STATE_1 = ENABLE
LOG_ARCHIVE_DEST_STATE_2 = ENABLE
REMOTE_LOGIN_PASSWORDFILE = EXCLUSIVE
LOG_ARCHIVE_FORMAT = archPRIMARY_%s_%t_%r.dbf
LOG_ARCHIVE_MAX_PROCESSES = 30

Note : Make sure that database is not in Shared server mode.

4. Enable Archiving / create password file / create control file for standby DB (Primary)

SQL> SHUTDOWN IMMEDIATE;
SQL> EXIT

* Create a Password File
orapwd file=$ORACLE_HOME/dbs/orapwPRIMARY PASSWORD=system ENTRIES=10 force=y


SQL> STARTUP MOUNT;
SQL> ALTER DATABASE ARCHIVELOG;

* Create a Control File for Standby Database
QL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/oravl01/oracle/STANDBY.ctl';

SQL> ALTER DATABASE OPEN;


* Check datafiles/logfiles status

SQL> select MEMBER from v$logfile;
SQL> select NAME from v$datafile;
SQL> select NAME from v$tempfile;


***** Step-by-Step Instructions for Creating a Physical Standby Database *****

5. Run Cre_OFA.sh to create OFA for new DB instance.

6. Create a Backup Copy of the Primary Database Datafiles ( Primary )

SQL> alter database begin backup;

<-- Copy All datafiles/redo log files/arch files/cnt file to new DB location -->

SQL> alter database end backup;
-- create new Archive locations

mkdir /oravl99/ORACLE/PRIMARY/arc/local_arc
mkdir /oravl99/ORACLE/PRIMARY/arc/standby_arc


7. Prepare an Initialization Parameter File for the Standby Database

##############################################################################
# Logical standby database instance for PRIMARY (Primary DB instance)
##############################################################################

##########################################
# Standby Parameters #
##########################################

DB_UNIQUE_NAME =STANDBY
LOG_ARCHIVE_CONFIG ='DG_CONFIG=(PRIMARY,STANDBY)'
DB_FILE_NAME_CONVERT ='PRIMARY','STANDBY'
LOG_FILE_NAME_CONVERT ='/oravl04/oradata/PRIMARY/','/oravl04/oradata/STANDBY/'
LOG_ARCHIVE_FORMAT =archPRIMARY_%s_%t_%r.dbf
LOG_ARCHIVE_DEST_1 ='LOCATION=/oravl01/oracle/adm/STANDBY/arc/local_arc VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=STANDBY'
LOG_ARCHIVE_DEST_2 ='SERVICE=PRIMARY LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLES) DB_UNIQUE_NAME=PRIMARY'
LOG_ARCHIVE_DEST_3 ='LOCATION=/oravl01/oracle/adm/STANDBY/arc/standby_arc VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLES) DB_UNIQUE_NAME=STANDBY'
LOG_ARCHIVE_DEST_STATE_1 =ENABLE
LOG_ARCHIVE_DEST_STATE_2 =ENABLE
LOG_ARCHIVE_DEST_STATE_3 =ENABLE

REMOTE_LOGIN_PASSWORDFILE =EXCLUSIVE
STANDBY_FILE_MANAGEMENT = AUTO
FAL_SERVER = PRIMARY
FAL_CLIENT = STANDBY

8. Set Up the Environment to Support the Standby Database
- Create a password file.
orapwd file=$ORACLE_HOME/dbs/orapwSTANDBY PASSWORD=system ENTRIES=10 force=y
- Configure listeners for the primary and standby databases.
% lsnrctl stop
% lsnrctl start


9. Start the Physical Standby Database
set db_name=PRIMARY in init file

SQL> STARTUP MOUNT;

- Rename file location in new Control file (If any)

* Check datafiles/logfiles status

SQL> select MEMBER from v$logfile;
SQL> select NAME from v$datafile;
SQL> select NAME from v$tempfile;
SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=MANUAL;

SQL> ALTER DATABASE RENAME FILE '/oravl04/oradata/STANDBY/system_1.dbf' to '/oravl02/oradata/STANDBY/system_1.dbf';
SQL> ALTER DATABASE RENAME FILE '/oravl04/oradata/STANDBY/undotbs_1.dbf' to '/oravl02/oradata/STANDBY/undotbs_1.dbf';
SQL> ALTER DATABASE RENAME FILE '/oravl04/oradata/STANDBY/sysaux_1.dbf' to '/oravl02/oradata/STANDBY/sysaux_1.dbf';
SQL> ALTER DATABASE RENAME FILE '/oravl04/oradata/STANDBY/users_1.dbf' to '/oravl02/oradata/STANDBY/users_1.dbf';
SQL> ALTER DATABASE RENAME FILE '/oravl04/oradata/STANDBY/pool_data_1.dbf' to '/oravl02/oradata/STANDBY/pool_data_1.dbf';
SQL> ALTER DATABASE RENAME FILE '/oravl04/oradata/STANDBY/pool_ix_1.dbf' to '/oravl02/oradata/STANDBY/pool_ix_1.dbf';
SQL> ALTER DATABASE RENAME FILE '/oravl04/oradata/STANDBY/tools_1.dbf' to '/oravl02/oradata/STANDBY/tools_1.dbf';
SQL> ALTER DATABASE RENAME FILE '/oravl04/oradata/STANDBY/temp_1.dbf' to '/oravl02/oradata/STANDBY/temp_1.dbf';

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;

- Start Redo Apply, On the standby database, issue the following command to start Redo Apply
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

11. Test archival operations to the physical standby database - run on primary database

SQL> ALTER SYSTEM SWITCH LOGFILE;

12. Verify the Physical Standby Database Is Performing Properly

- Identify the existing archived redo log files. - On the standby database
SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;


- Force a log switch to archive the current online redo log file - On the primary database
SQL> ALTER SYSTEM SWITCH LOGFILE;


* Set ENV time format
SQL> ALTER SESSION set nls_date_FORMAT = 'DD-MON-YY HH:MI:SS';


- Verify the new redo data was archived on the standby database. - On the standby database
SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;


- Verify new archived redo log files were applied. - On the standby database
SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;


*************************************************************************************************************************************************
PHYSICAL STANDBY DATABASE IS READY
*************************************************************************************************************************************************

* Creating a Logical Standby Database


13. Stop Redo Apply on the Physical Standby Database

- To stop Redo Apply, issue the following statement on the physical standby database
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;


14. Prepare the Primary Database to Support a Logical Standby Database


- Prepare the Primary Database for Role Transitions
update init file (include a LOG_ARCHIVE_DEST_3 destination on the primary database)

- Primary
alter system set LOG_ARCHIVE_DEST_3='LOCATION=/oravl01/oracle/adm/PRIMARY/arc/standby_arc VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=PRIMARY';

- Standby

alter system set LOG_ARCHIVE_DEST_3='LOCATION=/oravl01/oracle/adm/STANDBY/arc/standby_arc VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLES) DB_UNIQUE_NAME=STANDBY';

- Primary Init

LOG_ARCHIVE_DEST_3='LOCATION=/oravl01/oracle/adm/PRIMARY/arc/standby_arc VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=PRIMARY'
LOG_ARCHIVE_DEST_STATE_3 = ENABLE

15. Build a Dictionary in the Redo Data - on Primay database

SQL> EXECUTE DBMS_LOGSTDBY.BUILD;


16. Transition to a Logical Standby Database

- Convert to a Logical Standby Database

SQL> ALTER DATABASE RECOVER TO LOGICAL STANDBY STANDBY;

* Note : Got following error which is not the error, you may refer alert log. DB must be renamed using NID utility.

*************************
ERROR at line 1:
ORA-16254: change db_name to STANDBY in the client-side parameter file (pfile)

ORA-16254: change db_name to string in the client-side parameter file (pfile)
Cause: An ALTER DATABASE RECOVER TO LOGICAL STANDBY new-dbname command was successfully executed without a server parameter file (spfile).
Action: The client-side parameter file must be edited so that db_name is set to the given name before mounting the database again
*************************
* Note : if command goes in indefinite mode then then run following command from another session,
(Optional)
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL
18. Adjust Initialization Parameters for the Logical Standby Database

SQL> SHUTDOWN;

- Create a New Password File

orapwd file=$ORACLE_HOME/dbs/orapwSTANDBY_NEW PASSWORD=sys4get ENTRIES=10 force=y

DB_NAME = STANDBY
LOG_ARCHIVE_DEST_1 = 'LOCATION=/oravl01/oracle/adm/STANDBY/arc VALID_FOR=(ONLINE_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=STANDBY'
LOG_ARCHIVE_DEST_2 = 'SERVICE=PRIMARY LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PRIMARY'
LOG_ARCHIVE_DEST_3 = 'LOCATION=/oravl01/oracle/adm/STANDBY/arc/standby_arc VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=STANDBY'
LOG_ARCHIVE_DEST_STATE_1 = ENABLE
LOG_ARCHIVE_DEST_STATE_2 = ENABLE
LOG_ARCHIVE_DEST_STATE_3 = ENABLE

SQL> STARTUP MOUNT;

19. Open the Logical Standby Database


SQL> ALTER DATABASE OPEN RESETLOGS;


20. Issue the following statement to begin applying redo data to the logical standby database

SQL> ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;

Verify Logical database
SQL> desc dba_logstdby_progress
SQL> select APPLIED_SCN,READ_SCN,NEWEST_SCN from dba_logstdby_progress;

* Optional steps -->


21. Verify the Logical Standby Database Is Performing Properly

- Monitoring Log File Archival Information

a. Determine the status of redo log files.- on primary database

SQL> SELECT THREAD#, SEQUENCE#, ARCHIVED, STATUS FROM V$LOG;

b. Determine the most recent archived redo log file. - on primay database

SQL> SELECT MAX(SEQUENCE#), THREAD# FROM V$ARCHIVED_LOG GROUP BY THREAD#;

c. Determine the most recent archived redo log file at each destination.- on primary database

SQL> SELECT DESTINATION, STATUS, ARCHIVED_THREAD#, ARCHIVED_SEQ# FROM V$ARCHIVE_DEST_STATUS WHERE STATUS <> 'DEFERRED' AND STATUS <> 'INACTIVE';

d. Find out if archived redo log files have been received. - on primary database
SQL> SELECT LOCAL.THREAD#, LOCAL.SEQUENCE# FROM (SELECT THREAD#, SEQUENCE# FROM V$ARCHIVED_LOG WHERE DEST_ID=1)
LOCAL WHERE LOCAL.SEQUENCE# NOT IN (SELECT SEQUENCE# FROM V$ARCHIVED_LOG WHERE DEST_ID=2 AND THREAD# = LOCAL.THREAD#);


22. Applying Redo Data to Logical Standby Databases


- Starting SQL Apply
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY;


To start redo apply immediate
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;


- Stopping SQL Apply on a Logical Standby Database

SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY;

To stop immediate redo apply
SQL> ALTER DATABASE ABORT LOGICAL STANDBY APPLY;
*************************************************************************************************************************************************
LOGICAL STANDBY DATABASE IS READY
*************************************************************************************************************************************************


select APPLIED_SCN,READ_SCN,NEWEST_SCN from dba_logstdby_progress;

select SEQUENCE#,FIRST_CHANGE#,NEXT_CHANGE#,DICT_BEGIN,DICT_END from DBA_LOGSTDBY_LOG;

select * from DBA_LOGSTDBY_PROGRESS;

Alter database register logical logfile '/oravl99/ORACLE/STANDBY/arc/standby_arc/archSTANDBY_49_1_654631187.dbf';



-------------------------------


column Archive_dest format a50
column Error format a10

set linesize 100
set pagesize 10000



desc dba_logstdby_log;

*std by

select SEQUENCE#,FIRST_CHANGE#,NEXT_CHANGE# from dba_logstdby_log;

* primary

select SEQUENCE#,FIRST_CHANGE#,NEXT_CHANGE# from v$archived_log;

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

FORCE LOGGING Option

The database or tablespaces in the database should be put into FORCE LOGGING mode before creating the backup for the standby database. Either a database or all of its tablespaces should be put into this mode but not both.

The following statement will put a tablespace in FORCE LOGGING mode:

ALTER TABLESPACE FORCE LOGGING;

The FORCE LOGGING mode can be cancelled at the database level using the following statement:

ALTER DATABASE NO FORCE LOGGING;

The FORCE LOGGING mode can be cancelled at the tablespace level using the following statement:

ALTER TABLESPACE NO FORCE LOGGING;

Temporary tablespaces and temporary segments have no effect during FORCE LOGGING mode because these objects do not generate any redo. Undo tablespaces are in FORCE LOGGING mode by default, so they cannot be put into FORCE LOGGING mode. Oracle will generate an error if an attempt is made to put a temporary tablespace or undo tablespace into FORCE LOGGING mode.
==========================================
trouble shooting
==========================================

Check the alert logs on both sides.

1. run on primary to detect failures :-

select destination, status, fail_date, valid_now
from v$archive_dest
where dest_name in ('LOG_ARCHIVE_DEST_1','LOG_ARCHIVE_DEST_2','LOG_ARCHIVE_DEST_3','LOG_ARCHIVE_DEST_4')
and (status 'VALID' or VALID_NOW 'YES');

2. run on standby to get exact position of rollforward :-

select thread#, to_char(snapshot_time,'dd-mon-yyyy:hh24:mi'),
to_char(applied_time,'dd-mon-yyyy:hh24:mi'),
to_char(newest_time,'dd-mon-yyyy:hh24:mi') from V$STANDBY_APPLY_SNAPSHOT;

====================================================================================
DATA GUARD
====================================================================================

SYS@dg AS SYSDBA> ALTER SYSTEM SET DG_BROKER_START=TRUE;

System altered.

ON PRIMARY

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/sys
Connected.
DGMGRL> CREATE CONFIGURATION 'FAILOVER' AS PRIMARY DATABASE IS 'BG' CONNECT IDENTIFIER IS 'BG';
Configuration "NAME" created with primary database "DG"
DGMGRL>

DGMGRL> ADD DATABASE 'BG' AS CONNECT IDENTIFIER IS 'BG' MAINTAINED AS PHYSICAL;
Database "BG" added

====================================================================================
SWITCH OVER
====================================================================================
http://www.orafaq.com/node/2078
http://www.fadalti.com/oracle/database/How%20to%20create%20a%20%20logical_standby_database.htm
primary

1)
KILL ALL SESSION;
ALTER SYSTEM SWITCH LOGFILE;
SYS@dg AS SYSDBA> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;

2)ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

IMMIDEATLY ISSUE ON PRIMARY

3)
SYS@dg AS SYSDBA> shutdown immediate;
SYS@dg AS SYSDBA> startup mount;

4) ON STANDBY AFTER STEP TO 2 COMPLETE

SYS@bg AS SYSDBA> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SYS@bg AS SYSDBA> startup

5)SWITCH LOGFILE ON FORMER STANDBY MEANS CURRENT PRIMARY

ALTERY SYSTEM SWITCH LOGFILE;

6) VARIFY BY

ARCHIVE LOG LIST ON BOTH DATABASES

7) ON FORMER PRIMARY MEANS CURRENT STANDBY

SYS@dg AS SYSDBA> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

----------------------------------references-----------------------------------------------

http://www.orafaq.com/node/2078
http://www.fadalti.com/oracle/database/How%20to%20create%20a%20%20logical_standby_database.htm

RMAN commands.


CREATE USER RMAN IDENTIFIED BY RMAN
DEFAULT TABLESPACE XYX
TEMPORARY TABLESPACE TEMP;

INCREASE TEMP ,UNDO TBS
GRANT RECOVERY_CATALOG_OWNER TO RMAN;

----------------CONFIGURE ARCHIVE MODE----------------
ALTER SYSTEM SET log_archive_start=TRUE SCOPE=spfile;
ALTER SYSTEM SET log_archive_dest_1='location=/u01/oradata/MYSID/archive/' SCOPE=spfile;
ALTER SYSTEM SET log_archive_format='arch_%t_%s.arc' SCOPE=spfile;

===========================================
RMAN
===========================================

-----------ENTER INTO RMAN------------------

Connect to a target database without using a recovery catalog:
% rman TARGET SYS/pwd@target_str

RMAN TARGET / CATALOG RMAN/RMAN@TEST
######connect to both the target database and the recovery catalog:#####
rman TARGET SYS/system@test CATALOG x/x@test
RMAN> CONNECT target sys/oracle@target
CREATE CATALOG;
REGISTER DATABASE;

RMAN> CONNECT TARGET SYS/oracle@trgt
RMAN> CONNECT CATALOG rman/cat@catdb
----connect to target,auxiliary,and recovery catalog databases, launch the RMAN client--------

% rman TARGET SYS/oracle@trgt AUXILIARY SYS/aux@auxdb CATALOG rman/cat@catdb
RMAN> CONNECT AUXILIARY SYS/aux@auxdb

-----------CONFIGURATION----------------------
show all;
CONFIGURE CHANNEL DEVICE TYPE sbt CLEAR;
CONFIGURE RETENTION POLICY CLEAR;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT CLEAR;

The following command configures RMAN to write disk backups to the
/tmp directory:

CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/tmp/%U';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/mybackupdir/cf%F';


------------------RMAN COMMAND--------------------
RMAN> BACKUP ARCHIVELOG COMPLETION TIME BETWEEN
’SYSDATE-31’ AND ’SYSDATE-7’;

RMAN> BACKUP TABLESPACE system, users, tools;
RMAN> BACKUP AS BACKUPSET DATAFILE
’ORACLE_HOME/oradata/trgt/users01.dbf’,
’ORACLE_HOME/oradata/trgt/tools01.dbf’;
RMAN> BACKUP CURRENT CONTROLFILE TO ’/backup/curr_cf.copy’;

RMAN> BACKUP SPFILE;
RMAN> BACKUP BACKUPSET ALL;
RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL;

----------DELETE BACKUP------------------

RMAN> delete noprompt ARCHIVELOG ALL;
RMAN> delete noprompt backup of database;
RMAN> delete noprompt copy of database;
-----------------------DATABASE---------------------

Recovering the Whole Database
Use the RESTORE DATABASE and RECOVER
STARTUP FORCE MOUNT;
run
{
allocate channel c1 type to disk;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN;
}

----------------------TABLESPACE--------------------
Recovering Current Tablespaces
RMAN> SQL 'ALTER TABLESPACE users OFFLINE';
RMAN> RESTORE TABLESPACE users;
RMAN> RECOVER TABLESPACE users;
RMAN> SQL 'ALTER TABLESPACE users ONLINE';

====================================================
---------------------DATAFILE-----------------------\
====================================================

RMAN> SQL 'ALTER DATABASE DATAFILE 7 OFFLINE';
RMAN> RESTORE DATAFILE 7;
RMAN> RECOVER DATAFILE 7;
RMAN> SQL 'ALTER DATABASE DATAFILE 7 ONLINE';

-------USER-MANAGED
SQLPLUS / AS SYSDBA
COPY DATAFILE FROM BACKUP LOCATION
SET NLS_DATE_FORMATE=DD-MON-YYYY HH24:MI:SS
STARTUP MOUNT
RECOVER DATABASE UNTIL TIME ' ';
APPLY THE LOGS
ALTER DATABASE OPEN RESETLOGS;

------------------BLOCK------------------------------
Recovering Individual Data Blocks RMAN can recover individual corrupted
datafile blocks. When RMAN performs a complete scan of a file for a
backup, any corrupted blocks are listed in V$DATABASE_BLOCK_
CORRUPTION. Corruption is usually reported in alert logs, trace files or
results of SQL queries. Use BLOCKRECOVER to repair all corrupted blocks:
RMAN> BLOCKRECOVER CORRUPTION LIST;
You can also recover individual blocks, as shown in this example:
RMAN> BLOCKRECOVER DATAFILE 7 BLOCK 233, 235 DATAFILE 4 BLOCK 101;

-------------------VALIDATE------------------------------
Validating Restores You can run a RESTORE... VALIDATE operation to
confirm that a restore operation can be performed successfully. RMAN
decides which backup sets, datafile copies, and archived logs are needed for
the operation, and scans them to verify that they are usable. For example:
RMAN> RESTORE DATABASE VALIDATE;

----------------------LIST---------------------------
Listing Backups Run the LIST BACKUP and LIST COPY commands to
display information about backups and datafile copies listed in the
repository. You can display specific objects, as in the following examples:

LIST BACKUP; # lists backup sets, image copies, and proxy copies
LIST BACKUPSET; # lists only backup sets and proxy copies
LIST COPY; # lists only disk copies

LIST BACKUP BY FILE; # shows backup sets, proxy copies, and image copies
LIST COPY BY FILE; # shows only disk copies

LIST EXPIRED BACKUP;

LIST EXPIRED BACKUP BY FILE;

LIST BACKUP SUMMARY; # lists backup sets, proxy copies, and disk copies

LIST EXPIRED BACKUP SUMMARY;
RMAN> LIST BACKUP OF DATABASE;
RMAN> LIST COPY OF DATAFILE 1, 2, 3;
RMAN> LIST BACKUP OF ARCHIVELOG FROM SEQUENCE 1437;
RMAN> LIST CONTROLFILECOPY "/tmp/cf.cpy";
RMAN> LIST BACKUPSET OF DATAFILE 1;
For backups, you can control the format of LIST output with these options:
# lists backups of all files in database
LIST BACKUP OF DATABASE;
# lists copy of specified datafile
LIST COPY OF DATAFILE 'ora_home/oradata/trgt/system01.dbf';
# lists specified backup set
LIST BACKUPSET 213;
# lists datafile copy
LIST DATAFILECOPY '/tmp/tools01.dbf';

# specify a backup set by tag
LIST BACKUPSET TAG 'weekly_full_db_backup';
# specify a backup or copy by device type
LIST COPY OF DATAFILE 'ora_home/oradata/trgt/system01.dbf' DEVICE TYPE sbt;
# specify a backup by directory or path
LIST BACKUP LIKE '/tmp/%';
# specify a backup or copy by a range of completion dates
LIST COPY OF DATAFILE 2 COMPLETED BETWEEN '10-DEC-2002' AND '17-DEC-2002';
# specify logs backed up at least twice to tape
LIST ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE sbt;
-------------------------------------------------------------
Parameter Example Explanation
-------------------------------------------------------------
BY BACKUP LIST BACKUP OF BY BACKUP LIST BACKUP OF
For both backups and copies you have the following additional options:
Reporting on Database Files and Backups The REPORT command performsmore
complex analysis than LIST. Some of the main options are:
Monitoring RMAN Through V$ Views Status information for jobs in progress and
completed jobs is stored in V$RMAN_STATUS. V$RMAN_OUTPUT contains
the text ouptut of all RMAN jobs.
BY FILE LIST BACKUP BY FILE Lists the backups according to which
file was backed up.
SUMMARY LIST BACKUP
SUMMARY
Displays reduced output. By default,
the output is VERBOSE.
Parameter Example Explanation
EXPIRED LIST EXPIRED COPY Displays files inaccessible based
on the CROSSCHECK command.
RECOVERABLE LIST BACKUP RECOVERABLE Specifies datafile backups or
copies that are available and that
can be restored and recovered in
the current database incarnation--------

-----------------DELETE INPUT----------------------
With DELETE INPUT,
RMAN only deletes the specific copy of the archived redo log chosen for the backup set.
With DELETE ALL INPUT,
RMAN will delete each backed-up archived redo log file from all log archiving destinations.

For example, assume that you archive to /arc_dest1, /arc_dest2, and /arc_
dest3, and you run the following command:
BACKUP DEVICE TYPE sbt
ARCHIVELOG ALL
DELETE ALL INPUT;
In this case RMAN backs up only one copy of each log sequence number in these
directories, and then deletes all copies of any log that it backed up from the
archiving destinations.
If you had specified DELETE INPUT rather than DELETE ALL INPUT,
then RMAN would only delete the specific archived redo log files that it backed up

================================================
SCENARIO
================================================

----------------------COMPRESS PARALLEL BACKUP--------------------
configure device type disk parallelism 3;
configure default device type to disk;
configure channel 1 device type disk format '/u01/backup/%U';
configure channel 2 device type disk format '/u02/backup/%U';
CONFIGURE CHANNEL 3 DEVICE TYPE DISK FORMAT '/u03/backup/%U';
backup as compressed backupset database plus archivelog;

----------ONLINE BACKUP-------------------------
1. Runs the ALTER SYSTEM ARCHIVE LOG CURRENT command.
2. Runs BACKUP ARCHIVELOG ALL. Note that if backup optimization is enabled,
then RMAN skips logs that it has already backed up to the specified device.
3. Backs up the rest of the files specified in BACKUP command.
4. Runs the ALTER SYSTEM ARCHIVE LOG CURRENT command.
5. Backs up any remaining archived logs generated during the backup.
This guarantees that datafile backups taken during the command are recoverable to
a consistent state.
---------LOST OF CONTROL FILE-------------------
SQLPLUS /NOLOG
SQLPLUS > CONNECT / AS SYSDBA
STARTUP NOMOUNT

RMAN> CONNECT TARGET /
SET DBID
RESTORE CONTROLFILE FROM BACKUP;
ALTER DATABASE MOUNT;
RECOVER DATABASE;
ALTER DATABASE OPEN RESETLOGS;

-------------RECREATE CONTROLFILE------------------

SQLPLUS /NOLOG
CONNECT / AS SYSDBA
ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
EDIT TRACE FILE
COPY PASTE NORESETLOG PART.(TAKE FULL UPTO ALTER DATABASE OPEN)

STARTUP NOMOUNT
RUN COMMAND TO CREATE CONTROLFILE
IF SOMETHING ASKED APPLY LOGS
OR REDO-LOGS ALSO

------USING CANCEL OPTION


SQLPLUS /NOLOG
CONNECT / AS SYSDBA
ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
EDIT TRACE FILE (TAKE UPTO CHARACTERSET OR END OF STATMENT OF CREATE CONTROLFILE)
COPY PASTE RESETLOG PART.*

STARTUP NOMOUNT
RUN COMMAND TO CREATE CONTROLFILE
IF SOMETHING ASKED
CANCEL
ALTER DATABASE OPEN RESETLOGS;

----if backup fails last night--------------
if backup fails
backup database not backed up since time 'sysdate-1';

--------recover deleted records------------------

1 option
INSERT INTO EMPLOYEE_TEMP (SELECT * FROM EMPLOYEE AS OF TIMESTAMP ('13-SEP-04 8:50:58','DD-MON-YY HH24: MI: SS'))
2.option
SQL> select DBMS_FLASHBACK. GET_SYSTEM_CHANGE_NUMBER from dual;
SQL> INSERT INTO EMPLOYEE_TEMP(SELECT * FROM EMPLOYEE AS OF SCN 10280403339);
3.option
SELECT NAME,FIRST_TIME,NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY first_time DESC;
I will chose the appropriate arcive log.

EXECUTE DBMS_LOGMNR.ADD_LOGFILE(logfilename=>'/home/oracle/ARCHIVE_LOG/1_20_650546031.dbf',options=>DBMS_LOGMNR.NEW);
EXECUTE DBMS_LOGMNR.start_logmnr(options=>DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);

SELECT username,OPERATION,sql_undo,sql_redo
FROM v$logmnr_contents
4.option
conn system/pwd
execute dbms_flashback.enable_at_time(sysdate-10/1440);
select the records now and see 10 minutes old data
execute dbms_flashback.disable;

-------recover table after drop-------------------
FLASHBACK TABLE EMPLOYEE TO BEFORE DROP;

-------recover database to back in time--------------
1.option
SQL> Flashback database to timestamp sysdate-(1/24);
SQL> ALTER DATABASE OPEN RESETLOGS;

------------ restore datafile to different location ------------------------

----------WITH SHUTDOWN DB-----------------------

RMAN> connect target /
RMAN> startup mount;
RMAN> run{
2> set newname for datafile 4 to '/ora01/BRDSTN/data_ts01.dbf';
3> set newname for datafile 5 to '/ora01/BRDSTN/data_ts02.dbf';
4> restore tablespace data_ts;
5> switch datafile all; # Updates repository with new datafile location.
6> recover tablespace data_ts;
7> alter database open;
8> }

place the datafiles offline and then set their new names for restore and recovery:

-------------WITH OPEN DB------------------------------

RMAN> run{
2> sql 'alter database datafile 4, 5 offline';
3> set newname for datafile 4 to '/ora01/BRDSTN/data_ts01.dbf';
4> set newname for datafile 5 to '/ora01/BRDSTN/data_ts02.dbf';
5> restore datafile 4, 5;
5> switch datafile all; # Updates repository with new datafile location.
6> recover datafile 4, 5;
7> sql 'alter database datafile 4, 5 online';
8> }

=====================================================
-------------INCOMPLETE RECOVERY---------------------
=====================================================
----BY TIME

STARTUP MOUNT

SET NLS_DATE_FORMATE=DD-MON-YYYY HH24:MI:SS

....FROM RMAN

RUN
{
SET UNTIL TIME '06-SEP-2010 11:22:20';
RESTORE DATABASE;
RECOVER DATABASE;
}
ALTER DATABASE OPEN RESETLOGS;

----BY REDO

SELECT * FROM V$LOG_HISTORY;
STARTUP MOUNT;

FROM RMAN
RUN
{
SET UNTIL SEQUENCE 3 THREAD 1;
RESTORE DATABASE;
RECOVER DATABASE;
}
ALTER DATABASE OPEN RESETLOGS;

-----------------------------------------------------
KNOWLEDGEBASE
=====================================================

By default, a backup set consists of one backup piece.
For example, you can back up ten datafiles into a single backupset containing a single backup piece

-----------------------WHOLE-------------------------
A WHOLE backup is which is a backup of all datafiles and the current control file
whole database backups with the database mounted or open.To perform a whole database backup

----procedure for taking a whole database backup

RMAN> BACKUP DATABASE; # uses automatic channels to make backup
RMAN> SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT'; # switches logs and archives all
logs
By archiving the logs immediately after the backup, you ensure that you have a full set
of archived logs through the time of the backup. This guarantees that you can perform
media recovery after restoring this backup.
----------------------PARTIAL------------------------

----------------------FULL ---------------------------
A full datafile backup is a backup that includes every used data block in the file.

--------------------INCREMANTEL----------------------
RMAN incremental backups back up only datafile blocks that have changed since a
specified previous backup. You can make incremental backups of databases,
individual tablespaces or datafiles.

Incremental backups are differential by default.

incremental backup can be either of the following types:
________________________________________________________________________________
# A differential backup, which backs up all blocks changed after the most recent
incremental backup at level 1 or 0
________________________________________
level0 level1 level2 level3
1/2/09 1/3/09 1/4/09 1/5/09
-------------------------------------------
*
-------------->
------------>
----------->
BACKUP INCREMENTAL LEVEL 1 DATABASE;
#BACKUP INCREMENTAL LEVEL 0 DATABASE;
#BACKUP INCREMENTAL LEVEL 1
TABLESPACE SYSTEM
DATAFILE 'ora_home/oradata/trgt/tools01.dbf';
________________________________________________________________________________
# A cumulative backup, which backs up all blocks changed after the most recent
incremental backup at level 0
____________________________________________
level0 level1 level2 level3
1/2/09 1/3/09 1/4/09 1/5/09
---------------------------------------------
*
--------------->
---------------------------->
---------------------------------------->

BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;
BACKUP INCREMENTAL LEVEL = 1 CUMULATIVE TABLESPACE users;
____________________________________________________

Incremental backups are differential by default.

You can make incremental backups of databases, individual tablespaces or datafiles.

in ARCHIVELOG mode, you can make incremental backups if the database is open;
in NOARCHIVELOG mode, then you can only make incremental backups when the database is closed.

------------Incrementally Updated Backups: Rolling Forward Image Copy Backups-----------------
At the beginning of a backup strategy, RMAN creates an image copy backup of the datafile.
Then, at regular intervals, such as daily, level 1 incremental backups are taken,
and applied to the image copy backup, rolling it forward to the point in time when the
level 1 incremental was created.

RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_update'; #apply the increment backup to copy(refresh backup)
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update'
DATABASE; (take backup of incremental 1 if its not there it takes the backup from level 1)
}

RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_update'
UNTIL TIME 'SYSDATE - 7';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update'
DATABASE;
}
# On the first night the RECOVER COPY... UNTIL TIME statement has no effect,
and the BACKUP INCREMENTAL... FOR RECOVER OF COPY statement creates
the incremental level 0 copy.
# On the eighth and all subsequent nights night, the RECOVER COPY... UNTIL
TIME statement applies the level 1 incremental from seven days ago to the copy of
the database. The BACKUP INCREMENTAL... FOR RECOVER OF COPY
statement creates an incremental backup containing the changes for the previous
day

====================================================
RMAN WITH RAC
====================================================
By default, channels will be allocated from one node.
To split the load across all the nodes in the cluster,
individual channels need special configuration.

So in two-node cluster, we can equally distribute the load as
RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 4;

CONFIGURE CHANNEL 1 DEVICE TYPE DISK CONNECT 'sys/passwd@inst1';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK CONNECT 'sys/passwd@inst1';
CONFIGURE CHANNEL 3 DEVICE TYPE DISK CONNECT 'sys/passwd@inst2';
CONFIGURE CHANNEL 4 DEVICE TYPE DISK CONNECT 'sys/passwd@inst2';

Caution: Compressed Backup is CPU bound, so number of channels should be carefully used.

=========================================================================
PARALLELISM
=========================================================================
Note: that if you configure specific channels with numbers higher than the parallelism setting,
RMAN will not use these channels.

In this example, you want to send disk backups to two different disks. Configure disk channels as follows:

CONFIGURE DEFAULT DEVICE TYPE TO disk; # backup goes to disk
CONFIGURE DEVICE TYPE disk PARALLELISM 2; # two channels used in in parallel
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/disk1/%U' # 1st channel to disk1
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/disk2/%U' # 2nd channel to disk2
BACKUP DATABASE; # backup - first channel goes to disk1 and second to disk2

===========================================================================
QUERY
===========================================================================
SELECT * FROM V$RECOVERY_FILE_DEST; FOR SIZE OF RECOVERY AREA
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST='' SCOPE=BTOTH SID="*";

The following query displays
the number of blocks written to a backup set for each datafile with at least 50% of its
blocks backed up:

SELECT FILE#, INCREMENTAL_LEVEL, COMPLETION_TIME, BLOCKS, DATAFILE_BLOCKS
FROM V$BACKUP_DATAFILE
WHERE INCREMENTAL_LEVEL > 0
AND BLOCKS / DATAFILE_BLOCKS > .5
ORDER BY COMPLETION_TIME;

===============================================
REFERANCE
===============================================
http://www.oracle-base.com/articles/9i/ArchivelogModeOnRAC9i.php ARCHIVE MODE ON RAC

COPY FROM RMAN QUICK START PAGE NO 11 COMMAND LIST


==================================================================
DUPLICATE DATABASE WITH RMAN
==================================================================
1.CREATE PASSWORD FILE FOR DUPLICATE INSTANCE

orapwd file=/u01/app/oracle/product/9.2.0.1.0/dbs/orapwDUP password=password entries=10

2. ADD TNS ENTRIES

# Added to the listener.ora SID_LIST
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/9.2.0.1.0)
(SID_NAME = DUP)
)

# Added to the tnsnames.ora
DUP =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = server1.tshcomputing.com)(PORT = 1521))
)
(CONNECT_DATA =
(ORACLE_SID = DUP)
)
)

# Reload listener
lsnrctl reload

3. Next create an init.ora file for the duplicate database. Since we are duplicating the database onto the same server as
the original we must convert the file names so there is no conflict:
# Minimum Requirement.
DB_NAME=DUP
CONTROL_FILES=(/u02/oradata/DUP/control01.ctl,
/u02/oradata/DUP/control02.ctl,
/u02/oradata/DUP/control03.ctl)

# Convert file names to allow for different directory structure.
DB_FILE_NAME_CONVERT=(/u02/oradata/TSH1/,/u02/oradata/DUP/)
LOG_FILE_NAME_CONVERT=(/u01/oradata/TSH1/,/u01/oradata/DUP/)

# make sure block_size and compatible parameters
# match if you are not using the default.
DB_BLOCK_SIZE=8192
COMPATIBLE=9.2.0.0.0

4.Next we connect to the duplicate instance:
ORACLE_SID=DUP; export ORACLE_SID
sqlplus /nolog
conn / as sysdba

5. CREATE SPFILE
CREATE SPFILE FROM PFILE='/u01/app/oracle/admin/DUP/pfile/init.ora';

6.Next we start the database in NOMOUNT mode:
STARTUP FORCE NOMOUNT;
7.With the duplicate database started we can now connect to it from RMAN.
For the duplication to work we must connect to the original database (TARGET),
the recovery catalog (CATALOG) and our duplicate database (AUXILIARY):

ORACLE_SID=DUP; export ORACLE_SID
rman TARGET sys/password@tsh1 CATALOG rman/rman@tshadm AUXILIARY /

8. DUPLICATE DB
# Duplicate database to TARGET's current state.

RUN
{
SET NEWNAME FOR DATAFILE 1 TO /oracle/data/file2.f; # rename datafile 1 as file2.f
SET NEWNAME FOR DATAFILE 2 TO /oracle/data/file1.f; # rename datafile 2 as file1.f
DUPLICATE TARGET DATABASE TO newdb;
}

OR

RUN
{
# set new filenames for the datafiles
SET NEWNAME FOR DATAFILE 1 TO '/dup/oracle/oradata/trgt/system01.dbf';
SET NEWNAME FOR DATAFILE 2 TO '/dup/oracle/oradata/trgt/undotbs01.dbf';
. . .
# issue the duplicate command
DUPLICATE TARGET DATABASE TO dupdb
# create at least two online redo log groups
LOGFILE
GROUP1
(
'/dup/oracle/oradata/trgt/redo01a.log',
'/dup/oracle/oradata/trgt/redo01b.log',
'/dup/oracle/oradata/trgt/redo01c.log';
) SIZE 200K,
GROUP2
(
'/dup/oracle/oradata/trgt/redo02a.log',
'/dup/oracle/oradata/trgt/redo02b.log',
'/dup/oracle/oradata/trgt/redo02c.log';
) SIZE 200K,
GROUP3
(
'/dup/oracle/oradata/trgt/redo03a.log',
'/dup/oracle/oradata/trgt/redo03b.log',
'/dup/oracle/oradata/trgt/redo03c.log';
) SIZE 200K;
}

# Duplicate database to TARGET's state 4 days ago.
DUPLICATE TARGET DATABASE TO DUP UNTIL TIME 'SYSDATE-4';

http://download.oracle.com/docs/cd/B10501_01/server.920/a96566/rcmdupdb.htm#441876
==============================================================
==============================================================

92 from bkp_concept
732 912 1064 bipinbahai
732 912 1499 aka
236 c cinder road edison

Example
——–
Restore RMAN backup from CRM production server on us01ap17 to test server on test_us01ap17

The example assumes:

- the target database is on us01ap17
- the database is to be restored onto test_us01ap17
- the RMAN catalog is installed on us01ap19.
- the directory structure of test_us01ap17 is the same as us01ap17
- the ORACLE_SID will not change for the restored database
- a recovery catalog is being used
- the backups were carried out to disk (for illustrative purposes, and to disassociate from any media manager specific issues)

The following steps are required:

- backup the target on us01ap17
- list the datafile locations on us01ap17
- make the backup available to test_us01ap17
- make a copy of the init.ora available to test_us01ap17
- if directory structure is different, edit the init.ora to reflect directory structure changes
- configure SQL*Net connectivity from host to the recovery catalog and duplicated database
- set up a password file for the duplicated database
- startup nomount the duplicated database
- RMAN restore the controlfile(s)
- mount the database
- restore and rename the datafiles
- recover and open the database

These steps are expanded further below.

1.0 Create Database on test_us01ap17
1.1 Install Oracle database using CD or downloaded files from Oracle
1.2 Ceate Oracle service
oradim -new -sid CRM -intpwd change_on_install -maxusers 20 -startmode auto

1.3 Check to see if password file was created, if not, create using the following command

orapwd file=C:\oracle\ora92\database\PWDCRM.ora password=change_on_install entries=30

1.4 Create spfile

sqlplus /nolog
connect sys/change_on_install@CRM as sysdba
shutdown immediate;
create spfile from pfile=’C:\oracle\admin92\CRM\pfile\initCRM.ora’;
exit;

2.0 Backup the Production database on us01ap17
———————————————-

The target database needs to be backed up using RMAN.
The following is one example of RMAN doing an online database backup. In this example, the backup sets (full hot backup) are written to disk.

First, create a windows batch file, fullbackup.bat

rman catalog rmanager/rmanager@rman target sys/change_on_install@CRM cmdfile=C:\Oracle\job\rman_scripts\rman_full_backup.txt log=C:\Oracle\job\rman_logs\%date:~10,4%_%date:~4,2%_%date:~7,2%_log.txt

Then, create a RMAN script file rman_full_backup.txt

run
{
resync catalog;
allocate channel ch1 device type disk format ‘H:\Rman_backup\%d_%u_%s_%p’;
allocate channel ch2 device type disk format ‘H:\Rman_backup\%d_%u_%s_%p’;
allocate channel ch3 device type disk format ‘H:\Rman_backup\%d_%u_%s_%p’;
#BACKUP INCREMENTAL LEVEL 0 tag = ‘weekly full backup’ database filesperset 1 include current controlfile;
backup incremental level 0 tag = ‘full_hot_backup’ ( database setsize 8192000 filesperset 1 include current controlfile );
sql ‘alter system switch logfile’;
sql ‘alter system archive log current’;
BACKUP filesperset 1 archivelog all delete input;
release channel ch1;
release channel ch2;
release channel ch3;
}

Run the batch script and you will find backup files in H:\Rman_backup

2.1 Export RMAN catalog schema

exp rmanager/rmanager@rman file=P:\Rman\exp\rman_CRM_exp_%date:~0,3%.dmp

this will create an export dump file, e.g., rman_Thu.dmp

2.2 List Datafile Locations on us01ap17
————————————-

If you still have access to us01ap17, meaning it is still running (thank God it is!), you should find out each datafile’s number and location.


SQL> select file#, name from v$datafile;

FILE# NAME
———- ————————————–
1 H:\ORADATA\CRM\SYSTEM01.DBF
2 H:\ORADATA\CRM\UNDOTBS01.DBF
3 H:\ORADATA\CRM\CRM_DATA01.DBF
4 H:\ORADATA\CRM\CRM_DATA02.DBF
5 H:\ORADATA\CRM\CRM_DRSYS01.DBF
6 H:\ORADATA\CRM\CRM_INDX01.DBF
7 H:\ORADATA\CRM\CRM_INDX02.DBF
8 H:\ORADATA\CRM\CRM_TOOLS01.DBF
9 H:\ORADATA\CRM\CRM_USERS01.DBF
10 H:\ORADATA\CRM\CRM_XDB01.DBF
11 H:\ORADATA\I3FP\VERITAS_I3_ORCL.DBF
12 H:\ORADATA\CRM\CRM_DATA03.DBF

The log file names should also be recorded.

SQL> select group#, member from v$logfile;

GROUP# MEMBER
——- ——————————————
1 J:\ORADATA\CRM\REDO01.LOG
2 J:\ORADATA\CRM\REDO02.LOG
3 J:\ORADATA\CRM\REDO03.LOG
4 J:\ORADATA\CRM\CRM_SRL0.F
5 J:\ORADATA\CRM\CRM_SRL1.F

3.0 Make the Backups Available to test_us01ap17
———————————————–

3.1 Disk Backups

During restore, RMAN will expect the backup sets to be located in the same directory as written to during the backup. For disk backups, the DBA can accomplish this in many ways:

- create the same directory structure on us01ap17 and test_us01ap17
- copy RMAN backup files to test_us01ap17
Use Windows explorer to copy RMAN backup files from H:\rman_backup on us01ap17 to test_us01ap17

Also copy RMAN catalog export file to test_us01ap19

4.0 init.ora on test_us01ap17
—————————–

The “init.ora”, e.g., C:\oracle\admin92\CRM\pfile\initCRM.ora needs to be made available on test_us01ap17. Any location specific parameters must be ammended. For example,
- ifile
- *_dump_dest
- log_archive_dest*
- control_files

5.0 SQL*Net configuration
————————-

If running rman from us01ap17:

a. connectivity to the catalog remains unchanged
b. configure tnsnames.ora on us01ap17 to connect to duplicated database on test_us01ap17 configure listener.ora on test_us01ap17 to accept connections for duplicated database

If running rman from test_us01ap17:

a. configure tnsnames.ora on test_us01ap17 to connect to catalog
listener.ora on catalog host remains unchanged

b. configure tnsnames.ora on test_us01ap17 to connect to duplicated db on test_us01ap17 configure listener.ora on test_us01ap17 to accept connections for duplicated database

If running rman from test_us01ap19 (ie, neither us01ap17 or test_us01ap17):

a. connectivity to the catalog remains unchanged
b. configure tnsnames.ora on test_us01ap19 to connect to duplicated db on test_us01ap17
configure listener.ora on test_us01ap17 to accept connections for duplicated database

In this example, RMAN catalog database is installed on test_us01ap19 on test_us01ap17, the tnsnames.ora has the following lines for RMAN


RMAN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(Host = test_us01ap19)(Port = 1521))
)
(CONNECT_DATA =
(SID = rman)
(SERVER = DEDICATED)
)
)

5.1 Create RMAN catalog schema.
Run this script to create a new RMAN catalog schema

sqlplus /nolog
connect sys/change_on_install@rman as sysdba
rem create tablespace rmancatalog datafile ‘P:\Rman\oradata\rmancatalog.dbf’ size 50m;
drop user rmanunan cascade;
create user rmanunan identified by rman4CRM
temporary tablespace temp
default tablespace rmancatalog
quota unlimited on rmancatalog;
grant recovery_catalog_owner, connect, resource to rmanunan;
exit;

5.2 Import RMAN catalog export into rmanunan schema

imp userid=rmanunan/rman4CRM@rman file=rman_Sun.dmp fromuser=rmanager touser=rmanunan

6.0 Connect to RMAN catalog and check backup

rman catalog rmanunan/rman4CRM@rman target sys/change_on_install@CRM log=C:\Oracle\job\rman_logs\%date:~10,4%_%date:~4,2%_%date:~7,2%_log.txt

6.1 Check available backup with this command

list backup

7.0 Recover Duplicated Database
——————————-

7.1 startup nomount the database using SQLPLUS

SQL> startup nomount pfile=C:\oracle\admin92\CRM\pfile\initCRM.ora

7.2 restore the controlfile(s) (RMAN)

connect to RMAN

run{
allocate channel c1 type disk;
restore controlfile to ‘J:\Oradata\CRM\control04.ctl’;
}

Use OS command, copy J:\Oradata\CRM\control04.ctl to control01.ctl, control02.ctl, control03.ctl

copy J:\Oradata\CRM\control04.ctl J:\Oradata\CRM\control01.ctl
copy J:\Oradata\CRM\control04.ctl J:\Oradata\CRM\control02.ctl
copy J:\Oradata\CRM\control04.ctl J:\Oradata\CRM\control03.ctl

7.2 Mount the database

RMAN> alter database mount;

7.3 rename and restore the datafiles, and perform database recovery

RMAN can be used to change the location of the datafiles from the location on us01ap17 to the new location on test_us01ap17.

Use windows explorer, copy temporary tablespace datafiles to H:\ORADATA\CRM directory. Then run this command

run {
allocate channel c1 type disk;
restore database;
recover database;
}

7.4 restore archive log files (optional)

RMAN> restore archivelog all;

7.5 Recover using SQLPLUS

sqlplus /nolog
SQL>connect sys/change_on_install@CRM as sysdba
SQL>recover automatic database using backup controlfile until cancel;
cancel;
SQL>alter database open resetlogs;
SQL> connect CRM/DBA@CRM;

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

/////////////((Creating a Duplicate Database on the Same Host with backup)/////////////////

PROD1 = TARGET
TEST1 = AUXILARY

1. Back up the target database as follows:
2. ADD TEST1 to listener.ora
3. Add TEST1 to tnsnames.ora
4. Create the init.ora file for the new duplicate database, test1.
5. Start the new auxiliary database (duplicate database) instance. in nomount
6. Start RMAN, and connect to the target database ORACLE_SID=prod1.Note that the target database can be mounted or open.
7. Connect to the duplicate database using the keyword auxiliary through a SQL*Net
8. Issue the duplicate target database command to start the database duplication


RMAN> connect target /
RMAN> backup database plus archivelog;

2. Use a dedicated listener configuration for RMAN by making the following additions to
your listener.ora file:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = prod1)
(ORACLE_HOME = /u01/app/oracle/product/11g/)
(SID_NAME =prod1)
)
(SID_DESC =
(GLOBAL_DBNAME = test1)
(ORACLE_HOME = /u01/app/oracle/product/11g/)
(SID_NAME =test1)
)
)
3. Add the following information to the tnsnames.ora file, located in the
$ORACLE_HOME/network/admin directory:
test1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = prod1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test1)
)
)

4. Create the init.ora file for the new duplicate database, test1.

db_name = test1
db_block_size = 8192
compatible = 11.1.0.1.0
remote_login_passwordfile = exclusive
control_files = ('/u01/app/oracle/test1/control01.ctl',
'/u01/app/oracle/test1/control02.ctl')
db_file_name_convert = ('/u01/app/oracle/oradata/prod1',
'/u05/app/oracle/oradata/test1')
log_file_name_convert = ('/u01/app/oracle/oradata/prod1',
'/u05/app/oracle/oradata/test1')

5. Start the new auxiliary database (duplicate database) instance. in nomount

$ export ORACLE_SID=test1
$ sqlplus /nolog
SQL> connect / as sysdba
Connected to an idle instance
SQL> startup nomount pfile=$ORACLE_HOME/dbs/inittest1.ora
Oracle Instance started.
Total System Global Area 113246208 bytes
Fixed Size 1218004 bytes
Variable Size 58722860 bytes
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
SQL> exit

6. Start RMAN, and connect to the target database
ORACLE_SID=prod1. Note that the target database can be mounted or open.

$ rman
Recovery Manager: Release 11.1.0.1.0 - Beta on Sat Jun 9 14:03:42 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> connect target
connected to target database: prod1 (DBID=2561840016)

7. Connect to the duplicate database using the keyword auxiliary through a SQL*Net
connection:

RMAN> connect auxiliary sys/@test1
connected to auxiliary database: test1 (not mounted)
RMAN>

8. Issue the duplicate target database command to start the database duplication
process:

RMAN> duplicate target database to test1;


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

/////////////////Duplicating a Database Without Any RMAN Backups//////////////////////////

1. ADD dedicated listener.ora file:
2. Add tnsnames.ora file
3. CRATE INIT.ORA FILE FROM SPFILE (CHANGE DB_NAME=TEST1)
4. CREATE PASSWORD FILE FOR
5. START THE AUX INSTANCE IN NO MOUNT MODE
6. Start up RMAN, and connect to the target database
7.Connect to the duplicate database auxiliary through a SQL*Net
8. Issue the duplicate target database command to start the database duplication
process:


1. Use a dedicated listener configuration for RMAN by making the following additions to
your listener.ora file:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = prod1)
(ORACLE_HOME = /u01/app/oracle/product/11g/)
(SID_NAME =prod1)
)
(SID_DESC =
(GLOBAL_DBNAME = test1)
(ORACLE_HOME = /u01/app/oracle/product/11g/)
(SID_NAME =test1)
)
)

2. Add tnsnames.ora file,
test1=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = prod1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test1)
)
)

3. CRATE INIT.ORA FILE FROM SPFILE (CHANGE DB_NAME=TEST1)
4. CREATE PASSWORD FILE FOR
5. START THE AUX INSTANCE IN NO MOUNT MODE

$ export ORACLE_SID=test1
$ sqlplus /nolog
SQL> connect / as sysdba

SQL> startup nomount
SQL> exit


6. Start up RMAN, and connect to the target database
$rman target sys/sammyy1@eleven

7.Connect to the duplicate database auxiliary through a SQL*Net

RMAN> connect auxiliary sys/sammyy1@auxdb
connected to auxiliary database: AUXDB (not mounted)

8. Issue the duplicate target database command to start the database duplication
process:
RMAN> duplicate target database
2> to auxdb
3> from active database
4> spfile
5> parameter_value_convert =
'/u01/app/oracle/eleven/eleven','/u01/app/oracle/eleven/auxdb'
6> set log_file_name_convert =
'/u05/app/oracle/eleven/eleven','/u05/app/oracle/eleven/auxdb'
7> db_file_name_convert =
'/u05/app/oracle/eleven/eleven','/u05/app/oracle/eleven/auxdb';

NOTE: DUPLICATE ON DIFF HOST WITH SAME DIRECTORY STRUCTURE , THE METHOD WILL BE SAME UPTO 8 STEP
COMMAND 9 WILL BE DIFFRENT.
RMAN> duplicate database
to newdb
from active database
spfile
nofilenamecheck;

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

///////////Creating a Duplicate Database on a Remote Host with the Same File Structure/////////

PRIMARY DB = PROD
DUPLICATE DB = AUX


1. Back up the primary database. You must take a full backup and include all the archive
logs as well as the control file.
2. Create directories, init file for the duplicate database.
3. Start up the auxiliary instance in nomount mode:
4. connect to rman and aux and duplicate db.


1. Back up the primary database. You must take a full backup and include all the archive
logs as well as the control file.


[oracle@linux] rman target=/ catalog rman/rman@catdb
RMAN> run {
allocate channel d1 type disk;
backup format '/backups/PROD/df_t%t_s%s_p%p' database;
backup format '/backups/PROD/al_t%t_s%s_p%p' archivelog all;
release channel d1;
}

2. Create directories, init file for the duplicate database.

audit_file_dest =/oradata/AUX/adump
background_dump_dest =/oradata/AUX/bdump
core_dump_dest =/oradata/AUX/cdump
user_dump_dest =/oradata/AUX/udump
db_name ="AUX"
instance_name =AUX
control_files =('/oradata/AUX/control01.ctl',
'/oradata/AUX/control02.ctl','/oradata/AUX/control03.ctl')
#the following sets the source and target location for data files
db_file_name_convert =("/oradata/PROD/", "/oradata/AUX/")
#the following sets the source and target location for redo log files
log_file_name_convert =("/oradata/PROD/", "/oradata/AUX/")
#the following lines must be the same as those on the target instance
undo_management =AUTO
undo_retention =10800
undo_tablespace =UNDOTBS1
db_block_size = 8192
compatible = 11.1.0.1.0

3. Start up the auxiliary instance in nomount mode:
$ export ORACLE_SID=AUX
$ sqlplus '/as sysdba'
SQL> startup nomount;

4. connect to rman and aux and duplicate db.

$ export ORACLE_SID=AUX
$ rman target sys/sys@PROD catalog rman/rman@catdb auxiliary /
RMAN> duplicate target database to AUX
nofilenamecheck;

NOTE: IF YOU WANT TO DUPLICATE WITH YOU OWN CUSTOM DIRECTORY STRUCTURE

RMAN> run
{set newname for datafile 1 to '/u01/app/oracle/testdata/system01.dbf';
set newname for datafile 2 to '/u01/app/oracle/testdata/sysaux01.dbf';
set newname for datafile 3 to '/u01/app/oracle/testdata/data01.dbf';
set newname for datafile 4 to '/u01/app/oracle/testdata/index01.dbf';
set newname for datafile 5 to '/u01/app/oracle/testdata/undotbs01.dbf';
duplicate target database to newdb
logfile
group 1 ('/u01/app/oracle/testdata/logs/redo01a.log',
('/u01/app/oracle/testdata/logs/redo01b.log') size 10m reuse,
group 2 ('/u01/app/oracle/testdata/logs/redo02a.log',
('/u01/app/oracle/testdata/logs/redo02b.log') size 10m reuse;
}

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

/////////////////.Duplicating a Database with Several Directories//////////////////////

ASM commands

===============================================
CREATE
===============================================
---CREATE DISKGROUP

CREATE DISKGROUP disk_group_1 NORMAL REDUNDANCY
FAILGROUP failure_group_1 DISK
'/devices/diska1' NAME diska1,
'/devices/diska2' NAME diska2,
FAILGROUP failure_group_2 DISK
'/devices/diskb1' NAME diskb1,
'/devices/diskb2' NAME diskb2;

---create tablespace
CREATE TABLESPACE DATA1 DATAFILE '+' SIZE 100M AUTOEXTEND ON;

•NORMAL REDUNDANCY - Two-way mirroring, requiring two failure groups.
•HIGH REDUNDANCY - Three-way mirroring, requiring three failure groups.
•EXTERNAL REDUNDANCY - No mirroring for disks that are already protected using hardware mirroring or RAID.

-- Add disks.
ALTER DISKGROUP disk_group_1 ADD DISK
'/devices/disk*3',
'/devices/disk*4';

SQL> alter diskgroup DATA1 add directory '+DATA1/oradata/orcl;
#Now create the alias
SQL> alter diskgroup DATA1 add alias '+DATA1/oradata/orcl/nitin01.dbf' for
+DATA1/orcl/datafile/nitin.263.3;

-- Create a directory.
ALTER DISKGROUP disk_group_1 ADD DIRECTORY '+disk_group_1/my_dir';

-- Rename a directory.
ALTER DISKGROUP disk_group_1 RENAME DIRECTORY '+disk_group_1/my_dir' TO '+disk_group_1/my_dir_2';

-- Delete a directory and all its contents.
ALTER DISKGROUP disk_group_1 DROP DIRECTORY '+disk_group_1/my_dir_2' FORCE;

==============================================
DROP
==============================================
DROP DISKGROUP disk_group_1 INCLUDING CONTENTS;
-- Drop a disk.
ALTER DISKGROUP disk_group_1 DROP DISK diska2;

-- Drop file using an alias.
ALTER DISKGROUP disk_group_1 DROP FILE '+disk_group_1/my_dir/my_file.dbf';

-- Drop file using a numeric form filename.
ALTER DISKGROUP disk_group_1 DROP FILE '+disk_group_1.342.3';

-- Drop file using a fully qualified filename.
ALTER DISKGROUP disk_group_1 DROP FILE '+disk_group_1/mydb/datafile/my_ts.342.3';

==============================================
RESIZE
==============================================
-- Resize a specific disk.
ALTER DISKGROUP disk_group_1
RESIZE DISK diska1 SIZE 100G;

-- Resize all disks in a failure group.
ALTER DISKGROUP disk_group_1
RESIZE DISKS IN FAILGROUP failure_group_1 SIZE 100G;

-- Resize all disks in a disk group.
ALTER DISKGROUP disk_group_1
RESIZE ALL SIZE 100G;
ALTER DISKGROUP disk_group_1 REBALANCE POWER 5;
ALTER DISKGROUP ALL DISMOUNT;
ALTER DISKGROUP ALL MOUNT;
ALTER DISKGROUP disk_group_1 DISMOUNT;
ALTER DISKGROUP disk_group_1 MOUNT;

-- Check metadata for a specific file.
ALTER DISKGROUP disk_group_1 CHECK FILE '+disk_group_1/my_dir/my_file.dbf'

-- Check metadata for a specific failure group in the disk group.
ALTER DISKGROUP disk_group_1 CHECK FAILGROUP failure_group_1;

==============================================================================
MIGRATION TO ASM USING RMAN
===============================================================================

1> Disable change tracking (only available in Enterprise Edition) if it is currently being used.

SQL> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;•Shutdown the database.

SQL> SHUTDOWN IMMEDIATE

2>•Modify the parameter file of the target database as follows:

set the DB_CREATE_FILE_DEST and DB_CREATE_ONLINE_LOG_DEST_n parameters to the relevant ASM disk groups.
Remove the CONTROL_FILES parameter from the spfile so the control files will be moved to the DB_CREATE_* destination and the spfile gets updated automatically.
If you are using a pfile the CONTROL_FILES parameter must be set to the appropriate ASM files or aliases.

3>•Start the database in nomount mode.

RMAN> STARTUP NOMOUNT

4>Restore the controlfile into the new location from the old location.

RMAN> RESTORE CONTROLFILE FROM 'old_control_file_name';

5>Mount the database.

RMAN> ALTER DATABASE MOUNT;

6>Copy the database into the ASM disk group.

RMAN> BACKUP AS COPY DATABASE FORMAT '+disk_group';

7>Switch all datafile to the new ASM location.

RMAN> SWITCH DATABASE TO COPY;

8>Open the database.

RMAN> ALTER DATABASE OPEN;

9>Create new redo logs in ASM and delete the old ones.

10>Enable change tracking if it was being used.

SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;



=================================================================
11g NEW FEATURE
=================================================================
Oracle 11g ASM includes two new compatibility attributes that determine the version of the ASM
and database software that can use specific disk groups:

--------------------------------------------------------------------
The compatibility versions of a disk group can only be */increased/*

•COMPATIBLE.ASM - The minimum version of the ASM software that can access the disk group.
In 11g, the default setting is 10.1.
•COMPATIBLE.RDBMS - The minimum COMPATIBLE database initialization parameter setting for any database
instance that uses the disk group. In 11g, the default setting is 10.1.

CREATE DISKGROUP DATA1 DISK '/dev/raw/*'
ATTRIBUTE 'compatible.asm' = '11.1';
CREATE DISKGROUP DATA1 DISK '/dev/raw/*'
ATTRIBUTE 'compatible.rdbms' = '11.1', 'compatible.asm' = '11.1';

ALTER DISKGROUP DATA1 SET ATTRIBUTE 'compatible.asm' = '11.1';
ALTER DISKGROUP DATA1 SET ATTRIBUTE 'compatible.rdbms' = '11.1';
---------------------------------------------------------------------
Fast Mirror Resync
ASM keeps track of the changed extents that need to be applied to the offline disk.
*/Once the disk is available, only the changed extents are written to resynchronize the disk, /*
rather than overwriting the contents of the entire disk.
This can speed up the resynchronization process considerably

-- Set using the hours unit of time.
ALTER DISKGROUP disk_group_1 SET ATTRIBUTE 'disk_repair_time' = '4.5h';

-- Set using the minutes unit of time.
ALTER DISKGROUP disk_group_1 SET ATTRIBUTE 'disk_repair_time' = '300m';
---------------------------------------------------------------------
ROLLING MIGRATION

ALTER SYSTEM START ROLLING MIGRATION TO 11.2.0.0.0;

-----CAN BE DONE ONLY
•Mount and dismount of the disk groups.
•Open, close, resize, and delete of database files.
•Access to local fixed views and fixed packages

-----CURRENT STATUS
SELECT SYS_CONTEXT('sys_cluster_properties', 'cluster_state') FROM dual;
If a disk goes offline during a rolling upgrade, the timer is not started until after the rolling upgrade is complete.
--------------------------------------------------------------------------------
UPGRADE
Clustered ASM instances for 11g onwards can be upgraded using a rolling upgrade.
The ASM cluster is placed in rolling upgrade mode by
issuing the following command from one of the nodes.

ALTER SYSTEM START ROLLING MIGRATION TO 11.2.0.0.0;

Once the cluster is in rolling upgrade mode each node in turn can be shutdown, upgraded and started.
The cluster runs in a mixed version environment until the upgrade is complete.
In this state, the cluster is limited to the following operations:

•Mount and dismount of the disk groups.
•Open, close, resize, and delete of database files.
•Access to local fixed views and fixed packages.
The current status of the ASM cluster can be determined using the following query.

SELECT SYS_CONTEXT('sys_cluster_properties', 'cluster_state') FROM dual;

Once the last node is upgraded, the rolling upgrade is stopped by issuing the following command,
which checks all ASM instances are at the appropriate version,
turns off rolling upgrade mode and restarts any pending rebalance operations.

ALTER SYSTEM STOP ROLLING MIGRATION;

Restrictions and miscellaneous points about the rolling upgrade process include:

•The Oracle clusterware must be fully patched before an ASM rolling upgrade is started.
•Rolling upgrades are only available from 11g onwards,
so this method is not suitable for 10g to 11g upgrades.
•This method can be used to rollback to the previous version if the rolling upgrade fails before completion.
•If the upgrade fails, any rebalancing operations must complete before a new upgrade can be attempted.
•New instances joining the cluster during a rolling upgrade are automatically placed in rolling upgrade mode.
•If all instances in a cluster are stopped during a rolling upgrade,
once the instances restart they will no longer be in rolling upgrade mode. The upgrade must be initiated as if it were a new process.

The "ALTER DISKGROUP ... MOUNT" statement allows disk groups to be mounted in restricted mode.

======================================================================
ALLOCATION_UNIT AU_SIZE
======================================================================
When the disk group compatibility attributes are set to 11.1 or higher,
the extent size will automatically grow as the file grows.
The first 20,000 extents match the allocation unit size (1*AU).
The next 20,000 extents are made up of 8 allocation units (8*AU).
Beyond that point, the extent size becomes 64 allocation units (64*AU).

CREATE DISKGROUP disk_group_2
EXTERNAL REDUNDANCY
DISK '/dev/sde1'
ATRRIBUTE 'au_size' = '32M';

----------------------------------------------------------------------------
SYSASM Privilege and OSASM OS Group
$ sqlplus / as sysasm

---------------------------END OF 11G FEATURE--------------------------------
=============================================================================
V$VIEWS
=============================================================================

View ASM Instance DB Instance
V$ASM_ALIAS Displays a row for each alias present in every disk group mounted by the ASM instance.
Returns no rows
V$ASM_CLIENT Displays a row for each database instance using a disk group managed by the ASM instance.
Displays a row for the ASM instance if the database has open ASM files.
V$ASM_DISK Displays a row for each disk discovered by the ASM instance, including disks which are not part of any disk group.
Displays a row for each disk in disk groups in use by the database instance.
V$ASM_DISKGROUP Displays a row for each disk group discovered by the ASM instance. Displays a row for each disk group mounted by the local ASM instance.
V$ASM_FILE Displays a row for each file for each disk group mounted by the ASM instance.
Displays no rows.
V$ASM_OPERATION Displays a row for each file for each long running operation executing in the ASM instance. Displays no rows.
V$ASM_TEMPLATE Displays a row for each template present in each disk group mounted by the ASM instance. Displays a row for each template present in each disk group mounted by the ASM instance with which the database instance communicates.

select name, state, type, total_mb, free_mb from v$asm_diskgroup;

NAME STATE TYPE TOTAL_MB FREE_MB
------------------------------ ----------- ------ ---------- ----------
DATA1 MOUNTED EXTERN 34512 34101

select name, path, mode_status, state, disk_number from v$asm_disk

NAME PATH MODE_ST STATE DISK_NUMBER
------------ ---------------------- ------- -------- -----------
DATA_0000 /dev/rdsk/c3t19d5s4 ONLINE NORMAL 0
DATA_0001 /dev/rdsk/c3t19d16s4 ONLINE NORMAL 1
DATA_0002 /dev/rdsk/c3t19d17s4 ONLINE NORMAL 2
DATA_0003 /dev/rdsk/c3t19d18s4 ONLINE NORMAL 3

SQL> select INSTANCE,NAME,STATUS,SOFTWARE_VERSION,COMPATIBLE_VERSION from v$asm_client;

------- ------------ ------------ ------------
cubs1 CONNECTED 10.2.0.1.0 10.2.0.1.0

FROM +ASM (ASM instance)
select file_number , sum(bytes)/(1024*1024) from v$asm_file group by
file_number


FROM ORCL (database instance)
SQL> select name from v$datafile
NAME
----------------------------------------
+DATA1/orcl/datafile/sysaux.256.3

SQL> select member from v$logfile;
MEMBER
-------------------------------------------------------------------------------
-
+DATA1/orcl/onlinelog/group_3.264.3

To show the hierarchical tree of files stored in the diskgroup

SELECT concat('+'||gname, sys_connect_by_path(aname, '/')) full_alias_path FROM
(SELECT g.name gname, a.parent_index pindex, a.name aname,
a.reference_index rindex FROM v$asm_alias a, v$asm_diskgroup g
WHERE a.group_number = g.group_number)
START WITH (mod(pindex, power(2, 24))) = 0
CONNECT BY PRIOR rindex = pindex;



==============================================================
ASMCMD
==============================================================

he lsdsk command lists information about ASM disks from the V$ASM_DISK_STAT and V$ASM_DISK views
lsdsk [-ksptcgHI] [-d ] [pattern]

cp [-ifr] <[\@connect_identifier:]src> <[\@connect_identifier:]tgt>

md_restore -b [-li]
[-t (full)|nodg|newdg] [-f ]
[-g ',,...']
[-o ':,...']


lsdg dgroup2 Lists all disk groups and their attributes.
lsct dgroup1 LIST ABOUT CLIENTS ACCESS
lsdsk -kspt '/dev/sdb6'


===============================================================
INIT+ASM.ORA
===============================================================
SQL> select instance_name from v$instance
INSTANCE_NAME
----------------
+ASM
ASM init.ora parameters
*.background_dump_dest='/opt/app/admin/+ASM/bdump'
*.core_dump_dest='/opt/app/admin/+ASM/cdump'
*.instance_type=asm
*.asm_diskgroups=+DATA1
*.large_pool_size=12M
*.asm_diskstring='/dev/rdsk/c3t19d*s4'
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/opt/app/admin/+ASM/udump'

==================================================================
KNOWLEDGEBASE
==================================================================
ASMLIB
Oracle has developed a storage management interface called the ASMLIB API. ASMLIB is not required to
run ASM; it is simply an add-on module that simplifies the management and discovery of ASM disks. The
ASMLIB provides an alternative, to the standard operating system interface, for ASM to identify and
access block devices. The ASMLIB API provides storage and operating system vendors the opportunity to
supply extended storage-related features and exploit the capabilities and strengths of vendors‘ storage
array.
The ASMLIB API provides two major feature enhancements over standard interfaces:
• Disk discovery | Providing more information about the storage attributes to the Database and the DBA
• I/O processing | To enable more efficient I/O
Oracle is providing an ASMLIB, called the Oracle ASMLIB, for the Linux platform (current version as of
this writing is 2.0).