Tuesday, December 29, 2009

Configuring ASM on Windows environment

1) With asmtool

Follow below steps and create a ASM diskgroup on your local m/c

1) Creating a disks with asmtool

D:\>mkdir asmdisks
D:\>cd asmdisks
D:\asmdisks>asmtool -create D:\asmdisks\disk1 1024
D:\asmdisks>asmtool -create D:\asmdisks\disk2 1024
D:\asmdisks>asmtool -create D:\asmdisks\disk3 1024

Note: - size should be in MB’s

Now you have 3 disks of 1024mb each which can be used to create a ASM disk group.

2) Create ASM instance: -

a) Configure Cluster Synchronization Service: -

C:\oracle\product\10.2.0\db_1\BIN>localconfig add

Step 1: stopping local CSS stack
Step 2: deleting OCR repository
Step 3: creating new OCR repository
successfully accumulated necessary OCR keys.
Creating OCR keys for user 'hostname', privgrp ' ' . .
Operation successful.
Step 4: creating new CSS service
successfully created local CSS service
successfully reset location of CSS setup

b) Create init file: -

Open notepad edit the following parameters and save file as "C:\oracle\product\ 10.2.0\db_ 1\database\ init+ASM. ora"
INSTANCE_TYPE= ASM
DB_UNIQUE_NAME= +ASM
LARGE_POOL_SIZE= 8M
ASM_DISKSTRING= 'D:\asmdisks\ *'
_ASM_ALLOW_ONLY_ RAW_DISKS= FALSE

c) Create service and password file
oradim will create an ASM instance and start it automatically.
D:\> orapwd file=C:\oracle\ product\10. 2.0\db_1\ database\ PWD+ASM.ora password=asm
D:\> oradim -NEW -ASMSID +ASM -STARTMODE auto

3) Starting ASM instance: -

a) Change PFILE to SPFILE, Add ASM Diskgroup parameter and your all set to go and use ASM.
SQL> create spfile from pfile;
SQL> startup nomount;

Create asm disk group: -

SQL> select path, mount_status from v$asm_disk;
PATH MOUNT_STATUS
----------------------- -------------------
D:\ASMDISKS\ DISK1 CLOSED
D:\ASMDISKS\ DISK3 CLOSED
D:\ASMDISKS\ DISK2 CLOSED

SQL> create diskgroup data external redundancy disk
2 'D:\ASMDISKS\DISK1',
3 'D:\ASMDISKS\DISK2',
4 'D:\ASMDISKS\DISK3'
5 /
Diskgroup created.

SQL> alter system set asm_diskgroups= data scope=spfile;
SQL> shutdown immediate
SQL> startup

ASM instance started
Total System Global Area 83886080 bytes
Fixed Size 1247420 bytes
Variable Size 57472836 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted

Now you can go ahead and use your DBCA and create a database and on step 6 of 13, you can use Automatic Storage management as your Filesystem.

Monday, December 21, 2009

SYSRESV Utility

This utility was the result of enhancement request 566223 [BUG: 566223]:

"Currently, many Oracle applications determine whether a particular instance is up by checking for the presence of the sgadef file. We should provide a separate utility for this purpose instead, based on the contents of the SGA."

The sysresv utility included with Oracle 8.1.5 and above provides instance status (and OS resources used) for specified ORACLE_SIDs. This utility is especially useful when multiple instances are running. OS resources can be removed using this utility if the specified instance is detected to be dead.

This utility may be useful when an instance has crashed or was aborted and memory and semaphores related to this instance were not cleaned up automatically. This utility is also helpful in determining which instance is running. The sysresv utility, located in $ORACLE_HOME/bin, can be used from locations other than $ORACLE_HOME/bin.

Point your environment to the instance of interest before using sysresv.

NOTE: (9i 64-bit):

Must set up as follows to get sysresv to work.

Oracle 9.X.X (64Bit) on Solaris (64Bit) OS
- Set LD_LIBRARY_PATH=$ORACLE_HOME/lib32
- Set LD_LIBRARY_PATH_64=$ORACLE_HOME/lib

Usage:

sysresv:
usage :
sysresv [-if] [-d (on/off)] [-l sid1 (sid2) ...]
-i : Prompt before removing ipc resources for each sid
-f : Remove ipc resources silently, over rides -i option
-d (on/off) : List ipc resources for each sid if on
-l sid1 (sid2) .. : apply sysresv to each sid

Default: sysresv -d on -l $ORACLE_SID
Note: ipc resources are attempted to be deleted for a sid only if there is no currently running instance with that sid.


Examples:

Instance is not running:

/u02/app/oracle/product/8.1.7 $ sysresv
IPC Resources for ORACLE_SID “R817”:
Shared Memory
ID KEY
No shared memory segments used
Semaphores:
ID KEY
No semaphore resources used
Oracle Instance not alive for sid "R817"

Instance is running:

/u03/app/oracle/product/8.1.6 $ sysresv

IPC Resources for ORACLE_SID "X816" :
Shared Memory:
ID KEY
16437 0xe4efa8dc
Semaphores:
ID KEY
12320802 0x09d48346
Oracle Instance alive for sid "X816"

Attempting to remove memory and semaphores using sysresv when Oracle detects an instance is running:

/u03/app/oracle/product/8.1.6 $ sysresv -f
IPC Resources for ORACLE_SID "X816" :
Shared Memory:
ID KEY
16437 0xe4efa8dc
Semaphores:
ID KEY
12320802 0x09d48346
Oracle Instance alive for sid "X816"
SYSRESV-005: Warning
Instance maybe alive - aborting remove for sid "X816"

Removing IPC resources:

[Sysresv shows memory and semaphores exist but Oracle determines the instance is not alive. Cleanup is needed.]

/u03/app/oracle/product/8.1.6 $ sysresv
IPC Resources for ORACLE_SID "X816" :
Shared Memory:
ID KEY
16837 0xe4efa8dc
Semaphores:
ID KEY
12714018 0x09d48346
Oracle Instance not alive for sid "X816"

Removing IPC resources using sysresv:

/u03/app/oracle/product/8.1.6 $ sysresv -i

IPC Resources for ORACLE_SID "X816" :
Shared Memory
ID KEY
No shared memory segments used
Semaphores:
ID KEY
No semaphore resources used

Oracle Instance not alive for sid "X816"
Remove ipc resources for sid "X816" (y/n)?y
Done removing ipc resources for sid "X816"
/u03/app/oracle/product/8.1.6

Verify the resources were removed:

/u03/app/oracle/product/8.1.6 $ sysresv

IPC Resources for ORACLE_SID "X816" :
Shared Memory
ID KEY
No shared memory segments used
Semaphores:
ID KEY
No semaphore resources used
Oracle Instance not alive for sid "X816"

If you need to remove memory segments, and Oracle detects the instance is alive through sysresv:

$ ipcrm -m (memid)

Where (memid) is the memory id shown in the sysresv output.

Example:
$ ipcrm -m 16437

If you need to remove semaphores, and Oracle detects the instance is alive through sysresv:

$ ipcrm -s (semid)

where (semid) is the semaphore id shown in the sysresv output.

Example:
$ ipcrm -s 12320802

115235.1
Resolving ORA-7279 or ORA-27146 errors when starting instance

Problem Description
-------------------

When attempting to start an instance, you receive the following error:

ORA-7279: spcre: semget error, unable to get first semaphore set

This error may possibly be accompanied by one or more of the following
additional errors:

ORA-600: internal error code, arguments [SKGMBUSY]
SVR4 error: 28: no space left on device

If you are using version 8.1.5 or 8.1.6, you receive the following error instead of the ora-7279 when attempting to start an instance:

ORA-27146: post/wait initialization failed

With 8.1.7, instance startup fails with ora-3113.

These errors happen whenever attempting to start an instance, which includes, but is not limited to, creating a new database during an install, creating a new database with an existing install, starting an existing database which had the initSID.ora parameter PROCESSES changed, or starting an existing database which was either shutdown incorrectly or crashed.


Solution Description

The problem is that there are not enough semaphores to start the instance. This can be resolved based on one of the two scenarios below:

Scenario 1
If no new instances have been created and you are trying to start an existing database which was shutdown incorrectly or crashed, the semaphores from the crashed instance may still be allocated and will need to be removed.

Step 1: -

Before removing semaphores, you should be certain that there are no running instances using them. First check for running instances using the following command:
$ ps -ef | grep -v grep | grep pmon
If there are no pmon processes running, then there should be no semaphores owned by the oracle user, and any semaphores owned by the oracle user can safely be removed.

See steps 3 and 4 for the commands to list and remove semaphores.

Step 2: -

If you have multiple instances running, you will need to either shut them down or determine which semaphores are being used by each instance. It is recommended that you shut down all of the instances, but if this is not possible, then follow the instructions below.

A) If the running instances are version 8.1.x or higher, set your environment to that of the running instance, then run the following command:
% $ORACLE_HOME/bin/sysresv
This will show you the semaphore ids being used by this instance. Make a note of them and repeat the sysresv command for each running instance.
B) If you are not running version 8.1.x or higher, use the following commands to get a listing of semaphores:
$ svrmgrl
svrmgr) connect internal
svrmgr) oradebug ipc

Repeat these commands for each running instance making note of the "Semaphore identifiers" for each.

Step 3)

Now get a list of all of the allocated semaphores on the system using the following command:

% ipcs -sb | grep -v grep | grep (oracle)
where (oracle) is the name of the oracle user.

Compare the output of the ipcs command with the notes you made from the sysresv command or oradebug ipc command , and remove any semaphores that do not belong to a running instance.

Step 4)
You can remove semaphores using the following command:
% ipcrm -s (semid)
where (semid) is the semaphore id shown in the second column of the ipcs output titled ID.

Step 5)
Now try to start your instance again.


Scenario 2
----------
You are trying to start a new instance, or an existing instance that had the initSID.ora parameter PROCESSES changed. You will need to raise the kernel parameter SEMMNS.

Set the kernel parameter SEMMNS to double the sum of all of the initSID.ora PROCESSES parameters on the system.

For example, if you have 5 instances with the initSID.ora PROCESSES parameter set to 25, 50, 100, 200, and 250, then set the kernel parameter SEMMNS equal to 1250.

((25 + 50 + 100 + 200 + 250) * 2) = 1250

After making changes to the kernel parameter SEMMNS, you will be required to reboot the system. Depending on your operating system, you may also be required to rebuild the kernel. For more information on changing kernel parameters, please consult your OS documentation and/or your OS vendor.