Showing posts with label Steps. Show all posts
Showing posts with label Steps. Show all posts

Thursday, November 01, 2012

Creating Hard link and Soft Links in Unix

 

Hard Link Soft Link / symbolic  Link
If the inode entries are the same and if the count is 2 then they are hard linked.

if you see filename --> linked_directory
Then its a symbolic link.

la –lia ls -a
ln <source> <target file> (without the option –s which stands for soft link). ln  -s <source> <target file> (with the option –s which stands for soft link).
It is essentially create identical copies, No matter  which one you update,  both of them will get updated  
both links must reside on the same filesystem,
the source file must exist
that are not applicable to softlinks (source and target can be on seperate file systems, source does not have to exist, etc.)
additional I/O necessary to complete file access, additional storage taken up by softlink file's data
  A "soft" link does not increase the inode count for the referenced file, a "hard" link does.

If the count = 1, it's a soft link. If the count is > 1, it's a hard link.

Example of Viewing existing Hard link

ls –lia

1. Same iNode number  : 245787
2.  After permission column it lists 2

oracle@test:/app/oracle/product/11.2.0.3/grid/network/admin $ ls -lia
total 120
153544 drwxr-xr-x   4 oracle     dba           1024 Sep 12 04:27 ./
153543 drwxr-xr-x  11 oracle     dba           1024 Aug 27 17:39 ../
250089 drwxr-xr-x   2 oracle     dba           1024 Oct 17 12:58 OLD/
167535 -rw-r--r--   1 oracle     dba           1580 Sep  4 05:01 listener.old
153001 -rw-r--r--   1 oracle     dba           4524 Oct 17 13:01 listener.ora
159439 -rw-r--r--   1 oracle     dba            205 May 11  2011 shrept.lst
167531 -rw-r--r--   1 oracle     dba            881 Aug 27 18:17 sqlnet.ora
245787 -rw-r--r--   2 oracle     dba          43224 Sep 25 01:38 tnsnames.ora

oracle@test:/app/oracle/product/11.2.0.3/grid/network/admin $ cd $TNS_ADMIN

oracle@test:/app/oracle/product/11.2.0.3/db/network/admin $ ls -lia
total 102
168564 drwxr-xr-x   4 oracle     dba           1024 Sep  7 00:29 ./
168563 drwxr-xr-x  11 oracle     dba           1024 Aug 27 18:11 ../
158839 drwxr-xr-x   2 oracle     dba           1024 Sep 25 01:35 OLD/
164004 -rw-r--r--   1 oracle     dba           2690 Sep  7 00:29 listener.ora
168565 drwxr-xr-x   2 oracle     dba             96 Aug 27 18:00 samples/
178592 -rw-r--r--   1 oracle     dba            205 May 11  2011 shrept.lst
245790 -rw-r--r--   1 oracle     dba            881 Aug 27 18:17 sqlnet.ora
245787 -rw-r--r--   2 oracle     dba          43224 Sep 25 01:38 tnsnames.ora

Example of viewing SoftLink

oracle@test1:/app/grid/product/11.2.0.3/network/admin $ ls -lia
total 82
   343 drwxr-xr-x   4 oracle     dba           1024 Aug 24 17:01 ./
   342 drwxr-xr-x  11 oracle     dba           1024 Aug  9 09:55 ../
16349 drwxr-xr-x   2 oracle     dba           1024 Sep  7 12:43 OLD/
12489 -rw-r--r--   1 oracle     dba            186 Aug  9 10:26 endpoints_listener.ora
12165 -rw-r--r--   1 oracle     dba           1568 Sep  7 12:46 listener.ora
12488 -rw-r--r--   1 oracle     dba            534 Aug  9 10:26 listener.ora.bak.usfspfd1
12477 -rw-r--r--   1 oracle     dba            368 Aug  9 10:26 listener12080910AM2605.bak
   344 drwxr-xr-x   2 oracle     dba             96 Aug  9 09:49 samples/
  5108 -rw-r--r--   1 oracle     dba            205 May 11  2011 shrept.lst
22677 -rw-r--r--   1 oracle     dba            561 Aug 13 18:33 sqlnet.ora
12487 -rw-r--r--   1 oracle     dba            646 Aug  9 10:26 sqlnet.ora_temp
22674 -rw-r--r--   1 oracle     dba          29904 Aug 23 16:09 tnsnames.old
 42504 lrwxr-xr-x   1 oracle     dba             58 Aug 24 17:01 tnsnames.ora@ -> /app/oracle/product/11.2.0.3/db/network/admin/tnsnames.ora
oracle@test1:/app/grid/product/11.2.0.3/network/admin $ cd $TNS_ADMIN
oracle@test1:/app/oracle/product/11.2.0.3/db/network/admin $ ls -lia
total 82
150342 drwxr-xr-x   4 oracle     dba           1024 Aug 21 16:29 ./
150341 drwxr-xr-x  11 oracle     dba           1024 Aug  9 11:36 ../
214228 drwxr-xr-x   2 oracle     dba           1024 Oct 30 22:55 OLD/
268044 -rw-r-----   1 oracle     dba           3554 Aug 14 14:43 listener.ora
150343 drwxr-xr-x   2 oracle     dba             96 Aug  9 11:23 samples/
170627 -rw-r--r--   1 oracle     dba            205 May 11  2011 shrept.lst
268082 -rw-r--r--   1 oracle     dba            561 Aug 14 14:50 sqlnet.ora
266832 -rw-r--r--   1 oracle     dba          32061 Oct  9 10:42 tnsnames.ora

Daily check on the database before business volume picks up

Session Count

SQL>
    SELECT a.inst_id, COUNT (1) "Session Count"
     FROM sys.gv_$session a
    GROUP BY a.inst_id
SQL> /

   INST_ID Session Count
---------- -------------
         1            67
         2           105

Long Operation – Time Remaining is greater than Zero.

SQL> l
    SELECT * FROM sys.gv_$session_longops
    WHERE  TIME_REMAINING > 0

DBMS Jobs

SELECT job,
       SUBSTR (what, 1, 30),
       schema_user,
       last_date,
       next_date,
       broken,
       NVL2 (this_date, 'Y', 'N') running
  FROM dba_jobs s
ORDER BY schema_user, last_date

Buffer Gets

Replace the v.sql text with the frequent SQL statements important to your application.

SELECT v.inst_id,
       ROUND (v.buffer_gets / v.executions, 1) avggets,
       v.executions,
       v.module,
       SUBSTR (v.sql_text, 1, 60) querysql
  FROM sys.gv_$sql v
WHERE v.buffer_gets > 0
   AND v.executions > 0
   AND v.executions IS NOT NULL
   AND DECODE (executions, 0, NULL, (v.buffer_gets / v.executions)) > 10
   AND (v.sql_text LIKE 'FROM TBL_ABC%'
     OR  v.sql_text LIKE 'FROM TBL_XYZ%') 
ORDER BY v.inst_id, avggets DESC;

Thursday, March 08, 2012

How to register a database to use RMAN catalog using OEM Grid 11g

 

  1. Login Oracle Enterprise Manager.
  2. Select Target –> Chose the database
  3. Go Availability tab and click "Recovery Catalog Settings" under Backup/Recovery Setup.
  4. Choose "Use Recovery Catalog" option.
  5. Click "Add Recovery Catalog" button to add recovery catalog.
  6. And fill required fields such as host, port,sid, username, etc

 

image

Friday, October 14, 2011

Moving Data files Between ASM Disk Groups

 

Method 1: Using RMAN

Step 1: Start RMAN and connect to the target database.

$ rman target /

Step 2: Generate a report that shows the names of the datafiles.

RMAN> REPORT SCHEMA;

Step 3:  Back up the datafile to the new ASM disk group.

RMAN> BACKUP AS COPY DATAFILE '+DG_DEVSYS_mydb1_FLASH_01/mydb1/datafile/data01.290.709985421' FORMAT '+DG_DEVSYS_mydb1_DATA_01';

Step 4:  Bring the Datafile Offline
alter database datafile '+DG_DEVSYS_mydb1_FLASH_01/mydb1/datafile/data01.290.709985421' offline

Step 5: Point the control file to the newly created copy of the datafile

RMAN> SWITCH DATAFILE '+DG_DEVSYS_mydb1_FLASH_01/mydb1/datafile/data01.290.709985421' TO COPY;

Step 6:  Recover the renamed datafile
RMAN> recover datafile '+DG_DEVSYS_mydb1_DATA_01/mydb1/datafile/data01.272.764459767';

Step 7. Bring the datafile online.
alter database datafile '+DG_DEVSYS_mydb1_DATA_01/mydb1/datafile/data01.272.764459767' online

Step 8. Delete the old datafile
RMAN>DELETE DATAFILECOPY “DG_DEVSYS_mydb1_FLASH_01/mydb1/datafile/data01.290.709985421”

Reference: http://download.oracle.com/docs/cd/B28359_01/backup.111/b28270/rcmasmmi.htm

Method 2: Using ASMCMD CP ( Copy ) Command

Step 1: Start RMAN and connect to the target database.

$ rman target /

Step 2: Generate a report that shows the names of the datafiles.

RMAN> REPORT SCHEMA;

Step 3:  Bring the Datafile Offline
alter database datafile '+DG_DEVSYS_mydb1_FLASH_01/mydb1/datafile/data01.290.709985421' offline

Step 4:  Connect to ASMCMD and use CP to copy files
$ asmcmd –p

ASMCMD [+] > cp +DG_DEVSYS_mydb1_FLASH_01/mydb1/datafile/data01.290.709985421 +DG_DEVSYS_mydb1_DATA_01

Step 5:  After copied datafile, then rename file in database.  With ASM(OMF) this delete old datafile.

alter database rename file '+DG_DEVSYS_mydb1_FLASH_01/mydb1/datafile/data01.290.709985421'  to '+DG_DEVSYS_mydb1_DATA_01/mydb1/datafile/data01.272.764459767'

Step 6:  Recover the renamed datafile
RMAN> recover datafile '+DG_DEVSYS_mydb1_DATA_01/mydb1/datafile/data01.272.764459767';

Step 7. Bring the datafile online.
alter database datafile '+DG_DEVSYS_mydb1_DATA_01/mydb1/datafile/data01.272.764459767' online

Step 8: Verify the file name
RMAN> REPORT SCHEMA


Method 3:  Using RMAN Copy

Step 1:  Restrict the Session
ALTER SYSTEM enable restricted session;

Step 2:   Bring the Datafile Offline

alter database datafile '+DG_DEVSYS_mydb1_FLASH_01/mydb1/datafile/data01.290.709985421' offline

Step 3: Start RMAN and connect to the target database.

$ rman target /

Step 4:  RMAN Copy datafile
RMAN> copy datafile '+DG_DEVSYS_mydb1_FLASH_01/mydb1/datafile/data01.290.709985421' to '+DG_DEVSYS_mydb1_DATA_01';

Step 5:  After copied datafile, then rename file in database.  With ASM(OMF) this delete old datafile.

alter database rename file '+DG_DEVSYS_mydb1_FLASH_01/mydb1/datafile/data01.290.709985421'  to '+DG_DEVSYS_mydb1_DATA_01/mydb1/datafile/data01.272.764459767'

Step 6:  Recover the renamed datafile
RMAN> recover datafile '+DG_DEVSYS_mydb1_DATA_01/mydb1/datafile/data01.272.764459767';

Step 7. Bring the datafile online.
alter database datafile '+DG_DEVSYS_mydb1_DATA_01/mydb1/datafile/data01.272.764459767' online


Step 8: Verify the file name
RMAN> REPORT SCHEMA

Step 9: Disable the Restricted Session

ALTER SYSTEM disable restricted session;

Tuesday, June 28, 2011

Steps to set database on flashback mode in RAC for Oracle 11g

 

---- Check if flashback on?

SELECT flashback_on, log_mode
FROM v$database;

--- Check for Flashback Parameters existing

set linesize 121
col name format a30
col value format a30

SELECT name, value
FROM gv$parameter
WHERE name LIKE '%flashback%';

---- Stop the RAC Database , it will stop all the instances of the DB

srvctl stop database -d sfodb

--- Start the DB in mount state

srvctl start instance -d sfodb -i sfo38u1 -o mount 

-- Set the Flashback on

alter database flashback on;

--- Open the database

alter database open;

--- Start the remaining instances of the RAC

srvctl start instance -d sfodb -i sfo38u2 -o mount exclusive

-- Verify the flashback settings

select INST_ID,Name, FLASHBACK_ON from gv$database;