Monday, February 18, 2013

Start dbconsole for multiple databases on same host

If you want to start the dbconsole of multiple database on same host the parameter ORACLE_UNQNAME  and ORACLE_HOSTNAME needs to be set along with ORACLE_SID for that particular database .


[oracle@localhost ~]$ export ORACLE_SID=migrate
[oracle@localhost ~]$ export ORACLE_HOSTNAME=localhost
[oracle@localhost ~]$ export ORACLE_UNQNAME=migrate


[oracle@localhost ~]$ export ORACLE_HOSTNAME=localhost
[oracle@localhost ~]$ emctl start dbconsole
Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
Copyright (c) 1996, 2009 Oracle Corporation.  All rights reserved.
https://localhost:5501/em/console/aboutApplication
Starting Oracle Enterprise Manager 11g Database Control ................................. started.
------------------------------------------------------------------
Logs are generated in directory /u01/app/oracle/product/11.1.0/db_1/localhost_migrate/sysman/log



Thursday, February 7, 2013

ORA-15063: ASM discovered an insufficient number of disks for diskgroup "DATA"

This error can happen due to many different reasons .When it happens you may need to think of what has changed  in your environment.It was on my testing machine that I started getting this error  .I was wondering what could have gone wrong. I searched on the ineternet but I was not able to get anything which can match my  error and the environment that I have.It am using a standalone 11.2 machine on OEL5 with oracle restart feature enabled.From 11.2 onwards ASM is part of grid infrastructure and a diskgroup resource is always there under clusterware.This diskgroup houses the most important file for the ASM instance ie  SPFILE.This diskgroup resource (ora.DATA.dg) was not coming up and complaining ORA-15063 when I was trying to start it manually.



[oracle@localhost ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  OFFLINE      localhost
ora.LISTENER.lsnr
               ONLINE  ONLINE       localhost
ora.LISTENER_GRID.lsnr
               ONLINE  ONLINE       localhost
ora.asm
               ONLINE  OFFLINE      localhost                Instance Shutdown
ora.eons
               OFFLINE OFFLINE      localhost
ora.ons
               OFFLINE OFFLINE      localhost
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       localhost
ora.diskmon
      1        ONLINE  ONLINE       localhost
ora.migrate.db
      1        ONLINE  OFFLINE                               Instance Shutdown
ora.orcl.db
      1        OFFLINE OFFLINE
ora.orcl.test.svc
      1        OFFLINE OFFLINE
ora.stby.db
      1        OFFLINE OFFLINE



From the above output I can see that the resource ora.DATA.dg is offline which is the crs resource of my data diskgroup DATA.Now when I tried to start it manually I got the following error.



[oracle@localhost ~]$ crsctl start resource ora.DATA.dg
CRS-2672: Attempting to start 'ora.asm' on 'localhost'
ORA-01012: not logged on
CRS-2676: Start of 'ora.asm' on 'localhost' succeeded
CRS-2672: Attempting to start 'ora.DATA.dg' on 'localhost'
ORA-15032: not all alterations performed
ORA-15017: diskgroup "DATA" cannot be mounted
ORA-15063: ASM discovered an insufficient number of disks for diskgroup "DATA"
CRS-2674: Start of 'ora.DATA.dg' on 'localhost' failed
CRS-2679: Attempting to clean 'ora.DATA.dg' on 'localhost'
CRS-2681: Clean of 'ora.DATA.dg' on 'localhost' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'localhost'
CRS-2677: Stop of 'ora.asm' on 'localhost' succeeded
CRS-4000: Command Start failed, or completed with errors.




Clearly from the above output I can see that I am not able to access the diskgroup data  and this error makes me believe that there could be some issue with the disks like corruption or missing metadata but that's not true in my case .This error message is misleading.

When I try to start the ASM instance manually I am able to do that but with the following error that no spfile found.



[oracle@localhost ~]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.1.0 Production on Thu Feb 7 02:05:37 2013

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

Connected to an idle instance.

SQL> startup
ORA-00099: warning: no parameter file specified for ASM instance
ASM instance started

Total System Global Area  283930624 bytes
Fixed Size                  2212656 bytes
Variable Size             256552144 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted


SQL> show parameter asm_

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string
asm_diskstring                       string
asm_power_limit                      integer     1
asm_preferred_read_failure_groups    string
SQL>


So I needed to investigate further about my ASM resource and I looked at the ASM resource profile.Suddenly I remembered that I had removed and added ASM resource again one day before. Following is the output of the ASM resource profile and you can clearly see that that spfile and ASM_diskstring are blank.The  point is I didn't specify the ASM_DISKstring at the time of adding the ASM resource and that was my mistake.




[oracle@localhost ~]$ crsctl stat resource ora.asm -f
NAME=ora.asm
TYPE=ora.asm.type
STATE=ONLINE
TARGET=ONLINE
ACL=owner:oracle:rwx,pgrp:oinstall:rwx,other::r--
ACTION_FAILURE_TEMPLATE=
ACTION_SCRIPT=
AGENT_FILENAME=%CRS_HOME%/bin/oraagent%CRS_EXE_SUFFIX%
ALIAS_NAME=
ASM_DISKSTRING=              <<<<<<<<<<<<<<
AUTO_START=restore
CHECK_INTERVAL=1
CHECK_TIMEOUT=600
CREATION_SEED=83
CURRENT_RCOUNT=0
DEFAULT_TEMPLATE=PROPERTY(RESOURCE_CLASS=asm) ELEMENT(INSTANCE_NAME= %GEN_USR_ORA_INST_NAME%)
DEGREE=1
DESCRIPTION=Oracle ASM resource
ENABLED=1
FAILURE_COUNT=0
FAILURE_HISTORY=
GEN_USR_ORA_INST_NAME=+ASM
ID=ora.asm
INCARNATION=0
LAST_FAULT=0
LAST_RESTART=0
LAST_SERVER=
LOAD=1
LOGGING_LEVEL=1
NLS_LANG=
NOT_RESTARTING_TEMPLATE=
OFFLINE_CHECK_INTERVAL=0
PROFILE_CHANGE_TEMPLATE=
RESTART_ATTEMPTS=5
SCRIPT_TIMEOUT=60
SPFILE=    <<<<<<<<<<<<<
START_DEPENDENCIES=hard(ora.cssd) weak(ora.LISTENER.lsnr)
START_TIMEOUT=900
STATE_CHANGE_TEMPLATE=
STATE_CHANGE_VERS=0
STATE_DETAILS=
STOP_DEPENDENCIES=hard(ora.cssd)
STOP_TIMEOUT=600
UPTIME_THRESHOLD=1d
USR_ORA_ENV=
USR_ORA_INST_NAME=+ASM
USR_ORA_OPEN_MODE=mount
USR_ORA_OPI=false
USR_ORA_STOP_MODE=immediate
VERSION=11.2.0.1.0



Solution:  

The Solution was to modeify or remove and add asm resource again with the correct asm_diskstring path.Everything came online after that.You can also modify the resource in case you don't want to remove it.

srvctl modeify asm -d /dev/oracleasm/disks

And stop and start the ASM

OR

[oracle@localhost ~]$ srvctl stop asm
[oracle@localhost disks]$ srvctl remove asm
[oracle@localhost disks]$  srvctl add asm -d /dev/oracleasm/disks
[oracle@localhost disks]$ srvctl start asm


[oracle@localhost disks]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       localhost
ora.LISTENER.lsnr
               ONLINE  ONLINE       localhost
ora.LISTENER_GRID.lsnr
               ONLINE  ONLINE       localhost
ora.asm
               ONLINE  ONLINE       localhost                Started
ora.eons
               OFFLINE OFFLINE      localhost
ora.ons
               OFFLINE OFFLINE      localhost
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       localhost
ora.diskmon
      1        ONLINE  ONLINE       localhost
ora.migrate.db
      1        ONLINE  OFFLINE                               Instance Shutdown
ora.orcl.db
      1        OFFLINE OFFLINE
ora.orcl.test.svc
      1        OFFLINE OFFLINE
ora.stby.db
      1        OFFLINE OFFLINE


Thursday, December 27, 2012

DBFS filesystem Write error

I was trying to use the DBFS file system on test environment to take rman backup(Although it is not one of the recommended filesystem for keeping the backups).DBFS is basically used to store LOB data which is referred a securefiles in 11g.The LOB data of format pre 11g version is referred as basicfiles. After configuration of DBFS I used the most basic method to mount the file system


dbfs_client dbfs_user@migrate  /mnt/dbfs.

My dbfs filesystem got mounted and I was able to create the files manually there but I had issue while invoking the RMAN backup


[oracle@localhost ~]$ df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      37295632  27205460   8165052  77% /
/dev/sda1               101086     43302     52565  46% /boot
tmpfs                   765228    158800    606428  21% /dev/shm
dbfs                     19648       184     19464   1% /mnt/dbfs


RMAN BACKUP was throwing following error

RMAN> backup as copy datafile 2 format '/mnt/dbfs/staging_area/file2.bkp';

Starting backup at 27-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=49 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+DATA/migrate/datafile/sysaux.259.793193181
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/27/2012 08:24:22
ORA-19504: failed to create file "/mnt/dbfs/staging_area/file2.bkp"
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 13: Permission denied
Additional information: 1


The cause of the problem could be following.The staging area directory is owned by root user.



[oracle@localhost dbfs]$ ls -lrt
total 0
drwxrwxrwx 3 root root 0 Dec 26 15:44 staging_area

So I mounted again the filesystem with the following option (allow_other).


 dbfs_client dbfs_user@migrate --pass-through-fuse-options -o allow_other,direct_io  /mnt/dbfs

Still it was not working.Then I got the following error.Note that it was not letting me to use allow_other and allow_root options together. 

RMAN>  backup as copy datafile 2 format '/mnt/dbfs/staging_area/file2.bkp';

Starting backup at 27-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+DATA/migrate/datafile/sysaux.259.793193181
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/27/2012 08:26:40
ORA-19502: write error on file "/mnt/dbfs/staging_area/file2.bkp", block number 13568 (block size=8192)
ORA-27072: File I/O error
Additional information: 4
Additional information: 13568
Additional information: 917504
ORA-19502: write error on file "/mnt/dbfs/staging_area/file2.bkp", block number 13568 (block size=8192)
As per the oracle documentation we have following.
  • allow_root allows the root user to access the filesystem. This option requires setting the user_allow_other parameter in the /etc/fuse.confconfiguration file.
  • allow_other allows other users to access the filesystem. This option requires setting the user_allow_other parameter in the /etc/fuse.confconfiguration file.
I had mounted the FS again with the allow_root option and it worked !!!!!!!!
I used the following option (allow_root) this time.

[oracle@localhost staging_area]$ nohup dbfs_client dbfs_user@migrate -o allow_other,direct_io /mnt/dbfs  < .passwd_dbfs &

[oracle@localhost ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Feb 7 10:10:27 2013


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


connected to target database: MIGRATE (DBID=3570484994)


RMAN> backup as copy datafile 2 format '/mnt/dbfs/staging_area/file2.bkp';


Starting backup at 07-FEB-13

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+DATA/migrate/datafile/sysaux.259.793193181
output file name=/mnt/dbfs/staging_area/file2.bkp tag=TAG20130207T101052 RECID=17 STAMP=806753697
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:04:12
Finished backup at 07-FEB-13

Starting Control File and SPFILE Autobackup at 07-FEB-13

piece handle=/u01/app/oracle/flash_recovery_area/MIGRATE/autobackup/2013_02_07/o1_mf_s_806753705_8k7r8xln_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 07-FEB-13



[oracle@localhost ~]$ cd /mnt/dbfs/*/

[oracle@localhost staging_area]$ ls -lrt
total 552968
-rw-r----- 1 oracle asmadmin 566239232 Feb  7 10:14 file2.bkp



My backup file was listed in the metadata of DBFS filesystem as well.

SQL> select pathname from t_staging_area;

PATHNAME
--------------------------------------------------------------------------------
/
/.sfs
/.sfs/RECYCLE
/.sfs/attributes
/.sfs/content
/.sfs/snapshots
/.sfs/tools
/file2.bkp

8 rows selected.






Sunday, November 18, 2012

Shared NFS mount point for Real application testing (RAT) on RAC

Hi All,

I was trying to test the DB replay process from my 2 node RAC (11gR2) test machine set up on Oracle virtualbox environment . I faced the issue that I don't have a shared mount point to store the capture files.Following points are to be noted.

1) You can't use ASM for storing the DB capture files.ASM was the only shared directory I had at that point.
2) If you run capture from one instance it will capture the workload of all the instances.

So the shared file system has to be on ext3 file system shared by both the instances.Fo this I did following.


Create the disk and associate it with VirtualBox machines rac1 and rac2.
$ VBoxManage createhd --filename nfs.vdi --size 5120 --format VDI --variant Fixed

# Connect it to the rac1 vm.
$ VBoxManage storageattach rac1 --storagectl "SATA Controller" --port 7 --device 0 --type hdd --medium nfs.vdi --mtype shareable

$ # Make shareable.
$ VBoxManage modifyhd nfs.vdi --type shareable


# Connect it to the rac2 vm.
VBoxManage storageattach rac2 --storagectl "SATA Controller" --port 7 --device 0 --type hdd --medium nfs.vdi --mtype shareable

You will see the new disk as /dev/sd* on rac1>i had formatted it wih ext3 format on rac1

1)Format the /dev/sdg using the ext3 format on rac1 .So you will get the /dev/sdg1

2)service nfs start on both the nodes

3)Create a directory to mount the newly created disk.For me it is /nfs on both the nodes.Add following line to the /etc/fstab on node 1

/dev/sdg1               /nfs                    ext3    defaults        1 1

 for the first time mount -t nfs  /dev/sdg1               /nfs 

4)Now you need to mount the disk from node 2 as well .for that  do the following.

mount 192.168.56.101:/nfs /nfs -o rsize=8192,wsize=8192

where 192.168.56.101 is the ip address of rac1 machine accessible from rac2.


Now if you create a directory with ownership oracle:oinstall in /nfs it should be visible from bot the nodes


[root@rac2 RAT]# cd /nfs
[root@rac2 nfs]# ls -lrt
total 20
drwx------ 2 root   root     16384 Nov 16 23:00 lost+found
-rw-r--r-- 1 root   root         0 Nov 17 03:19 1
drwxr-xr-x 4 oracle oinstall  4096 Nov 19 06:54 RAT


Now you can create a database directory on the shared nfs filesystem and  you are good to run the capture process .


DBMS_WORKLOAD_CAPTURE.START_CAPTURE (name => 'capture01',dir => 'RAT')





Wednesday, November 14, 2012

Index issue core dumping

I had seen the following issue in the trace files while it was core dumping every few secs.The offending statement was a delete statement with where clause.On examining the trace files it looked like an issue of key mismatch.Note that this is key mismatch issue not a corrupt index issue so all the tools used for finding the corrupt blocks will not return anything.eg-database Validate,dbverify and analyze on index will come clean since the logical structure of the index is valid.To identify the key mismatch issue proceed as follwing.

From the trace files see following error

oer 8102.2 - obj# 155099, rdba: 0x53037ad2(afn 332, blk# 363218)
kdk key 8102.2:
  ncol: 2, len: 14
  key: (14):  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  mask: (4096)

Clearly the delete staement was not able to identify a key which was there in the table but not in the index.Next find the offending index using the object id reported in the trace file


--> select name from obj$ where obj# = 155099 

To identify the keys that are missing from the index we ran the following queries.

Following query will give the keys which are there in the table but not in the index.


SELECT /*+ FULL(t1) */ rowid,ORDER_ID
FROM scott.Task_activity t1
MINUS
SELECT /*+ index(t XIE4TASK_ACTIVITY$C) */ rowid,ORDER_ID
FROM scott.Task_activity t;

Following query will give the keys which are there in the index but not in the table.

SELECT /*+ index(t XIE4TASK_ACTIVITY$C) */ rowid,ORDER_ID
FROM scott.Task_activity t
MINUS
SELECT /*+ FULL(t1) */ rowid,ORDER_ID
FROM scott.Task_activity t1;


The resolution is to drop and recreate the index don't use the online rebuild of the index.

ORA-03113: end-of-file on communication channel

After doing a package install the 2 node RAC database running on 11.1.0.7.0 was brought up .One instance came up fine but the other instance was not coming up and throwing the following error.


ORA-03113: end-of-file on communication channel
Process ID: 20194
Session ID: 1655 Serial number: 5
WARNING: The 'LOG_ARCHIVE_CONFIG' init.ora parameter settings
are inconsistent with another started instance. This may be
caused by the 'DB_UNIQUE_NAME' init.ora parameter being specified
differently on one or more of the other RAC instances; the
DB_UNIQUE_NAME parameter value MUST be identical for all
instances of the database.
Errors in file /u02/diag/rdbms/shas/shas2/trace/swprd2_lgwr_5292.trc:



--After looking at the paratemet log_archive_config it was null and also the DB_UNIQUE_NAME was same across 2 nodes.The we checked the view "Select * from v$dataguard_config" and identified that it has non identical entry from the other node.I used following steps to resolve the issue:


you can reset this parameter and bring the instance.

Just mount the instance - problematic one

alter system set log_archive_config='dg_config=(nodg_config)' scope=both sid='*';

Temporary tablespace tempfile moved accidently at OS level

I saw this issue when the tempfile was moved accidently at the operating system level.It was throwing following error in the alert log.


data file 202: '/udb/u02/ORACLE/shas/temp2.dbf'
ORA-27041: unable to open file
ORA-12012: error on auto execute of job 449748
ORA-01116: error in opening database file ORA-01116: error in opening database file 202
ORA-01110: data file 202: '/udb/u02/ORACLE/shas/temp2.dbf'
ORA-27041: unable to open file
ORA-06512:


The resolution is to drop and add the tempfile but when I tried to drop I recieved the  following error.

ORA-25152: TEMPFILE cannot be dropped at this time

I used the following steps to identify the SID using the tempfile .After killing the SID I was able to drop and recreate the tempfile.

1)  SELECT s.sid, s.username, s.status, u.tablespace, u.segfile#, u.contents, u.extents, u.blocks  
FROM v$session s, v$sort_usage u  
WHERE s.saddr=u.session_addr  
ORDER BY u.tablespace, u.segfile#, u.segblk#, u.blocks; 
 

2)  select sid, username, osuser, program, machine from v$session where sid in   
();