Logical Volume Manager

# Using the whole secondary-slave IDE hard disk for existing LVM volume group (called vg0 in my case) by creating the physical volume (PV):
# pvcreate /dev/sdb1 /dev/sdc1

A similar message of this will be shown upon successful execution of pvcreate command:
pvcreate — physical volume “/dev/hdd” successfully created

Creating volume group !
# vgcreate vg1 /dev/sdb1 /dev/sdc1 
 
Create the new logical volume (LV) at 400MB (not fully utilize the whole IDE hard disk) to host the new EXT3 file system in question:
# lvcreate -L 10G -n my_log_vol01 vg1
# lvcreate -L 10G -n my_log_vol02 vg1
lvcreate completed successfully, this similar message will be seen:

lvcreate — doing automatic backup of “vg1″
lvcreate — logical volume “/dev/vg0/lvol1″ successfully created
 
Now, create the new EXT3 file system on the new logical volume (LV) with 1% file system reserved block count:
# mkfs -t ext3 -m 1 -v /dev/vg1/my_log_vol01
# mkfs -t ext3 -m 1 -v /dev/vg1/my_log_vol02


Once the new EXT3 file system creation completed, you can examine the file system by executing

tune2fs -l /dev/vg1/my_log_vol02
 
# Create a mount point directory for the new EXT3 file system:
mkdir -p /opt/oracle
 
It’s now ready to mount the new EXT3 file system:
# mount -t ext3 /dev/vg1/my_log_vol01 /opt/oracle

To confirm that the new EXT3 file system has been mounted successful, type df -h

Register disk with fdisk command
# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305):
Using default value 1305

Command (m for help): p

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1305    10482381   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#

Step-by-step Cold Backup

STEP 1: while source db is online do the following:
 -create backup of controlfile to trace
 “alter database backup controlfile to trace”. 
 -create pfile from spfile
 SQL>create pfile from spfile
and push above two to target destination i.e. at $ORACLE_HOME/dbs directory.

STEP 2: Shutdown the source database


STEP 3: Copy all data files into the new directories on the new server. 
You may change the file names if you want, but you must edit the controlfile to reflect the new data files 
names on the new server.

    scp /u01/oradata/trgtdb/* newhost:/u01/oradata/dupdb
    scp /u01/oradata/trgtdb/* newhost:/u01/oradata/dupdb
    scp /u03/oradata/trgtdb/* newhost:/u03/oradata/dupdb
    scp /u04/oradata/trgtdb/* newhost:/u04/oradata/dupdb


STEP 4: start the source db:
STEP 5: Copy and Edit the Control file – Using the output syntax from STEP 1, modify the controlfile 
creation script by changing the following:
This will put the create database syntax in the trace file directory. 
The trace keyword tells oracle to generate a script containing a create controlfile command and 
store it in the trace directory identified in the user_dump_dest parameter of the init.ora file. 
It will look something like this:

STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "PROD" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/PROD/redo01.log'  SIZE 50M,
  GROUP 2 '/u01/app/oracle/oradata/PROD/redo02.log'  SIZE 50M,
  GROUP 3 '/u01/app/oracle/oradata/PROD/redo03.log'  SIZE 50M
-- STANDBY LOGFILE
DATAFILE
  '/u01/app/oracle/oradata/PROD/system01.dbf',
  '/u01/app/oracle/oradata/PROD/undotbs01.dbf',
  '/u01/app/oracle/oradata/PROD/sysaux01.dbf',
  '/u01/app/oracle/oradata/PROD/users01.dbf',
  '/u01/app/oracle/oradata/PROD/example01.dbf',
  '/u01/app/oracle/oradata/PROD/testtbs.dbf',
  '/u01/app/oracle/oradata/PROD/test02.dbf'
CHARACTER SET AL32UTF8
;


Old:

    CREATE CONTROLFILE REUSE DATABASE "PROD" NORESETLOGS

New:

    CREATE CONTROLFILE SET DATABASE "DUPDB" RESETLOGS


     

STEP 6: Re-names of the data files names that have changed.



CREATE CONTROLFILE SET DATABASE "DUPDB" RESETLOGS  NOARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/u01/app/oracle/oradata/DUPDB/redo01.log'  SIZE 50M,
  GROUP 2 '/u01/app/oracle/oradata/DUPDB/redo02.log'  SIZE 50M,
  GROUP 3 '/u01/app/oracle/oradata/DUPDB/redo03.log'  SIZE 50M
-- STANDBY LOGFILE
DATAFILE
  '/u01/app/oracle/oradata/DUPDB/system01.dbf',
  '/u01/app/oracle/oradata/DUPDB/undotbs01.dbf',
  '/u01/app/oracle/oradata/DUPDB/sysaux01.dbf',
  '/u01/app/oracle/oradata/DUPDB/users01.dbf',
  '/u01/app/oracle/oradata/DUPDB/example01.dbf',
  '/u01/app/oracle/oradata/DUPDB/testtbs.dbf',
  '/u01/app/oracle/oradata/DUPDB/test02.dbf'
CHARACTER SET AL32UTF8
;

Save as db_create_controlfile.sql.

STEP 7: Create the bdump, udump and cdump directories

    cd $ORACLE_BASE/admin
    mkdir newlsq
    cd newlsq
    mkdir bdump
    mkdir udump
    mkdir cdump
    mkdir $ORACLE_BASE/oradata/dupdb
    


STEP 8: Copy-over the old init.ora file
 from the source db
 SQL>create pfile from spfile;

    scp $ORACLE_HOME/dbs/pfile newhost:$ORACLE_HOME/dbs/pfile
SETP 9: Edit init.ora file to reflect the duplicate database
 -controlfile path
 -dump file path
 -db_name

STEP 10: Start the target database with nomount option
 SQL>startup nomount pfile=' ';

     SQL>@db_create_controlfile.sql

STEP 11: Place the new database in archivelog mode.
STEP 12: Open the database with restlogs.

Useful GoldenGate Commands

How to start goldenGate:
$ cd $GGATE
$ ./ggsci
GGSCI (goldengate2.localdomain) 4> dblogin userid ggate
Password:
Successfully logged into database.
---------display information---------
gg>info all
gg>START MANAGER


How to view current log
GGSCI (goldengate2.localdomain) 20>view ggsevt
GGSCI (goldengate2.localdomain) 20>view report ext1


See information of EXTRACT and REPLICAT
GGSCI (goldengate2.localdomain) 20>info extract ext1
GGSCI (goldengate2.localdomain) 20>info replicat rep1

Deleting Extract group
--------------------------------------
$ ./ggsci
>dblogin userid ggate
>ggate

delete extract ext1
delete replicat rep1

View Stats:
GGSCI (goldengate1.localdomain) 4> stats EXT1
GGSCI (goldengate *** Total statistics since 2010-10-06 16:14:53 ***
        Total inserts                                1.00
        Total updates                              0.00
        Total deletes                                0.00
        Total discards                              0.00
        Total operations                          1.00 



Editing parameters:

edit param EXT1

RMAN

Step-by-step creating rman catalog database
Step-by-step creating recovery catalog
Step-by-step RMAN Duplicate Database
Step-by-step RMAN Cloning with ASM

Step-by-step RMAN Duplicate Database !

How Recovery Manager Duplicates a Database
To prepare for database duplication, first create an auxiliary instance as described in "Preparing the RMAN DUPLICATE Auxiliary Instance: Basic Steps". For the duplication to work, you must connect RMAN to both the target (primary) database and an auxiliary instance started in NOMOUNT mode.
Allocate at least one auxiliary channel on the auxiliary instance. The principal work of the duplication is performed by the auxiliary channel, which starts a server session on the duplicate host. This channel then restores the necessary backups of the primary database, uses them to create the duplicate database, and initiates recovery.
So long as RMAN is able to connect to the primary and auxiliary instances, the RMAN client can run on any host. All backups and archived redo logs used for creating and recovering the duplicate database, however, must be accessible by the server session on the duplicate host. If the duplicate host is not the same as the target host, then you must make backups on disk on the target host available to the duplicate host with the same full path name as in the primary database
Use NFS or shared disks and make sure that the same path is accessible in the remote host. For example, the NFS mount point for both hosts could be /home/file_server.

As part of the duplicating operation, RMAN automates the following steps:
• Creates a control file for the duplicate database.
• Restores the target datafiles to the duplicate database and performs incomplete recovery by using all available incremental backups and archived redo logs.
• Shuts down and starts the auxiliary instance.
• Opens the duplicate database with the RESETLOGS option after incomplete recovery to create the online redo logs.
• Generates a new, unique DBID for the duplicate database.


RMAN DUPLICATE DATABASE: Options
When duplicating a database, you have the following options:
• You can run the DUPLICATE command with or without a recovery catalog.
• You can skip read-only tablespaces with the SKIP READONLY clause. Read-only tablespaces are included by default. If you omit them, then you can add them later.
• You can exclude tablespaces from the duplicate database with the SKIP TABLESPACE clause. You can exclude any tablespace except the SYSTEM tablespace or tablespaces containing rollback or undo segments.
• You can create the duplicate database in a new host. If the directory structure is the same on the new host, then you can specify the NOFILENAMECHECK option and reuse the target datafile filenames for the duplicate datafiles.
• By default, the DUPLICATE command creates the duplicate database from the most recent backups of the target database and then performs recovery to the most recent consistent point contained in the archived redo logs. 
• In some cases, you can set the duplicate database DB_NAME differently from the target database DB_NAME.

Renaming Database Files/Controlfiles/Redo logs/Temp files in RMAN Duplicate Database

• Renaming Control Files in RMAN DUPLICATE DATABASE
When choosing names for the duplicate control files, make sure you set the parameters in the initialization parameter file of the auxiliary database correctly; otherwise, you could overwrite the control files of the target database.
• Renaming Online Logs in RMAN DUPLICATE DATABASE
RMAN needs new names for the online redo log files of the duplicate database. Either you can specify the names explicitly in the DUPLICATE command, or you can let RMAN generate them according to the rules listed below:
Order Method Result
1 Specify the LOGFILE clause of DUPLICATE command. Creates online redo logs as specified.
2 Set LOG_FILE_NAME_CONVERT initialization parameter. Transforms target filenames, for example, from log_* to duplog_*. Note that you can specify multiple conversion pairs.

3 Set one of the Oracle Managed Files initialization parameters DB_CREATE_FILE_DEST, DB_CREATE_ONLINE_DEST_n, or DB_RECOVERY_FILE_DEST. Transforms target filenames based on the parameters set. The rules of precedence among these parameters are the same used by the SQL statement ALTER DATABASE ADD LOGFILE.
4 Do none of the preceding steps. Makes the duplicate filenames the same as the filenames from the target. You must specify the NOFILENAMECHECK option when using this method, and the duplicate database should be in a different host so that the online logs of the duplicate do not conflict with the originals.

• Renaming Datafiles in RMAN DUPLICATE DATABASE
There are several means of specifying new names to be used for the datafiles of your duplicate database. Listed in order of precedence, they are:
• Use the RMAN command SET NEWNAME FOR DATAFILE within a RUN block that encloses both the SET NEWNAME commands and the DUPLICATE command.
• Specify the DB_FILE_NAME_CONVERT parameter on the DUPLICATE command to specify a rule for converting filenames for any datafiles not renamed with SET NEWNAME or CONFIGURE AUXNAME.
Note:
The DB_FILE_NAME_CONVERT clause of the DUPLICATE command cannot be used to control generation of new names for files at the duplicate instance which are Oracle Managed Files (OMF) at the target instance. 

• Set the DB_CREATE_FILE_DEST initialization parameter to create Oracle Managed Files datafiles at the specified location.

If you do not use any of the preceding options, then the duplicate database reuses the original datafile locations from the target database.
It is possible for SET NEWNAME, or DB_FILE_NAME_CONVERT to generate a name that is already in use in the target database. In this case, specify NOFILENAMECHECK on the DUPLICATE command to avoid an error message.

Renaming Tempfiles in RMAN DUPLICATE DATABASE
RMAN re-creates datafiles for temporary tablespaces as part of the process of duplicating a database. There are several means of specifying locations for duplicate database tempfiles. Listed in order of precedence, they are:
• Use the SET NEWNAME FOR TEMPFILE command within a RUN block that encloses both the SET NEWNAME commands and the DUPLICATE command.

Preparing the RMAN DUPLICATE Auxiliary Instance: Basic Steps
To prepare the auxiliary instance used in RMAN DUPLICATE DATABASE, carry out the following tasks:
Task 1: Create an Oracle Password File for the Auxiliary Instance
orapwd file=orapwDUPDB password=oracle entries=5 force=yes
Task 2: Establish Oracle Net Connectivity to the Auxiliary Instance
The auxiliary instance must be accessible through Oracle Net. Before proceeding, start SQL*Plus to ensure that you can establish a connection to the auxiliary instance. Note that you must connect to the auxiliary instance with SYSDBA privileges, so a password file must exist.
Listener file:



# listener.ora Network Configuration File:
/u01/app/oracle/product/10.2.0/db_1/network/admin/listener.
ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = GGATE1)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME = GGATE1)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = DUPDB)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME = DUPDB)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.65)(PORT = 1521))
    )
  )


Tnsnames file:

PRODDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.140)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = PRODDB)
    )
  )

DUPDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.65)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = DUPDB)
    )
  )
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

Task 3: Create an Initialization Parameter File for the Auxiliary Instance Create pfile from the source db and send it to Auxiliary location such as $ORACLE_HOME/dbs Make sure to change DB_NAME to reflect axiliary DB_NAME Change controlfile directory structure to reflect axiliary location and create directory at axiliary location. Change adump,bdump,cdump,udump directory structure to reflect axiliary directory and also create directory at axiliary location. Set other initialization parameters, including the parameters that allow you to connect as SYSDBA through Oracle Net, as needed. i.e *.remote_login_passwordfile='EXCLUSIVE' If you mention following parameter, then you don’t need to specify set newname when creating duplicate database. DB_FILE_NAME_CONVERT=(/u01/app/oracle/oradata/PROD/,/u01/app/oracle/oradata/DUPDB/) LOG_FILE_NAME_CONVERT=(/u01/app/oracle/oradata/PROD/redo, /u01/app/oracle/oradata/DUPDB/redo) After you create the client-side initialization parameter file, you can run the CREATE SPFILE command from SQL*Plus to create a server-side initialization parameter file at the Axiliary instance. SQL>CONNECT SYS/oracle@DUPDB AS SYSDBA SQL>startup NOMOUNT; SQL>CREATE SPFILE FROM PFILE='$ORACLE_HOME/dbs/initDUPDB.ora'; SQL>shutdown immediate; A server-side parameter file in the default location is an advantage when duplicating a database because you do not need to specify the PFILE parameter on the DUPLICATE command Task 4: Start the Auxiliary Instance Before beginning RMAN duplication, use SQL*Plus to connect to the auxiliary instance and start it in NOMOUNT mode (specifying a client-side parameter file if necessary). In this example, oracle is the password for the user with SYSDBA authority and DUPDB is the net service name for the auxiliary instance: Add a new entry to oratab, and source the environment Edit the /etc/oratab (or /opt/oracle/oratab) and add an entry for the new database. Source the new environment with '. oraenv' and verify that it has worked by issuing the following command: Echo $ORACLE_SID CONNECT SYS/oracle@DUPE AS SYSDBA -- start instance with the server parameter file SQL>STARTUP FORCE NOMOUNT; Because the auxiliary instance does not yet have a control file, you can only start the instance in NOMOUNT mode. Do not create a control file or try to mount or open the auxiliary instance. RMAN shuts down and restarts the auxiliary instance as part of the duplication. Hence, it is a good idea to create a server-side initialization parameter file for the auxiliary instance in the default location. If you do not have a server-side initialization parameter file for the auxiliary instance in the default location, then you must specify the client-side initialization parameter file with the PFILE parameter on the DUPLICATE command. The client-side parameter file for the auxiliary instance must reside on the same host as the RMAN client used to perform the duplication. Task 5: Mount or Open the Target Database Before beginning RMAN duplication, connect SQL*Plus to the target database and mount or open it if it is not already mounted or open. For example, enter: -- connect to target database SQL> CONNECT SYS/oracle@PROD AS SYSDBA; -- mount or open target database STARTUP MOUNT; Task 6: Make Sure You Have the Necessary Backups and Archived Redo Logs Make sure backups of all target datafiles and archived redo logs are accessible on the duplicate host. If you do not have backups of everything, then the duplicate operation fails. The database backup does not have to be a whole database backup: you can use a mix of full and incremental backups of individual datafiles. If you run rman from duplicate host, copy backup of datafile and archived log files to exactly same path to duplicate location i.e. if the backups are in /dsk1/bkp on the target host, then you might transfer them to /dsk1/bkp on the duplicate host. The new path—in this example, /dsk2/dup—must be accessible from both the target and duplicate hosts. Run the CATALOG command to add these copies to the RMAN repository at the duplicate host. Task 7: Allocate Auxiliary Channels if Automatic Channels Are Not Configured Start RMAN with a connection to the target database, the auxiliary instance, and, if applicable, the recovery catalog database. You can start the RMAN client on any host so long as it can connect to all the instances. In this example, a connection is established to three instances, all through the use of net service names: $ rman TARGET SYS/oracle@trgt CATALOG rman/cat@catdb AUXILIARY SYS/oracle@aux If you do not have automatic channels configured, then before issuing the DUPLICATE command, manually allocate at least one auxiliary channel within the same RUN command. The channel type (DISK or sbt) must match the media where the backups of the target database are located. If the backups reside on disk, then the more channels you allocate, the faster the duplication will be. For tape backups, limit the number of channels to the number of devices available. RUN { # SET NEWNAME If log_file_name_convert and \ db_file_name_convert is not already specified in init parameter SET NEWNAME FOR DATAFILE 1 TO '/u01/app/oracle/oradata/dupdb/system01.dbf'; # to manually allocate a channel of type sbt issue: ALLOCATE AUXILIARY CHANNEL ch1 DEVICE TYPE sbt; # to manually allocate three auxiliary channels for disk ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK; ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK; ALLOCATE AUXILIARY CHANNEL aux3 DEVICE TYPE DISK; DUPLICATE TARGET DATABASE TO DUPDB LOGFILE '/u01/app/oracle/oradata/ggate1/redo01.log' SIZE 50M, '/u01/app/oracle/oradata/ggate1/redo02.log' SIZE 50M, '/u01/app/oracle/oradata/ggate1/redo03.log' SIZE 50M; SKIP TABLESPACE tools; }

run {
SET NEWNAME FOR DATAFILE 1 TO '/u01/app/oracle/oradata/dupdb/system01.dbf';
SET NEWNAME FOR DATAFILE 2 TO '/u01/app/oracle/oradata/dupdb/undotbs01.dbf';
SET NEWNAME FOR DATAFILE 3 TO '/u01/app/oracle/oradata/dupdb/sysaux01.dbf';
SET NEWNAME FOR DATAFILE 4 TO '/u01/app/oracle/oradata/dupdb/users01.dbf';
SET NEWNAME FOR DATAFILE 5 TO '/u01/app/oracle/oradata/dupdb/example01.dbf';
SET NEWNAME FOR DATAFILE 6 TO '/u01/app/oracle/oradata/dupdb/testtbs.dbf';
SET NEWNAME FOR TEMPFILE 1 TO '/u01/app/oracle/oradata/dupdb/temp01.dbf';
ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux3 DEVICE TYPE DISK;
DUPLICATE TARGET DATABASE TO DUPDB
LOGFILE
'/u01/app/oracle/oradata/dupdb/redo01.log' SIZE 50M,
'/u01/app/oracle/oradata/dupdb/redo02.log' SIZE 50M,
'/u01/app/oracle/oradata/dupdb/redo03.log' SIZE 50M;
}


OTN Discussion Forums: Message List - Database - General

Ask Tom HOT ARTICLES

 
© Copyright 2008 - 2011. All rights reserved to dba-sansar.blogspot.com.
All other blogs, posts and entries are the property of their respective authors.
Please email us for your comments and suggessions Click Here