Tuesday, June 28, 2011

How to Verify if OID services are Completely Down

Dear All,

We had a situation where in we were asked to rebuild indexes of OID using "bulkload".Within OID all attributes needs to be indexed or attributes which are indexed needs to be rebuild.

Before we start rebuilding activity the OID should be either in 'read-only' mode or 'shutdown'.I have issued 'opmnctl stopall' and all services were shutdown cleanly,but when we ran bulkload we got the message that OID services are still running ,pelase shutdown.

So below are simple steps to check if OID services are shutdown cleanly.

1. First step is to use the normal 'OS command'

ps -ef | grep -i oid ( or ) ps -ef | grep -i <username>

<username> - is the user which you start/stop OID services

2. The next step is to use the 'oidctl' utility

$ oidctl connect=<servicename> status

<service name> - is the name of the DB service.

Eg
===
$ oidctl connect=OIDB status (in my case 'OIDB' is the database name)
NLS_LANG not set in environment
Setting NLS_LANG to AMERICAN_AMERICA.AL32UTF8
oidctl:Checking Oracle Internet Directory Processes ...
Process oidmon is not running ------------------> if any OID process is running,it would give you the PID
Checking OIDLDAPD instance 1 ...
Instance is shutdown ------------------> if any OIDLDAPD process is running,it would give you the PID and ports of dispatcher and server
OIDREPLD instance is not configured
ODISRV instance is not configured



3. The third step is to check the table 'ODS.ODS_PROCESS'

Normally after OID is shutdown there are no entries on these tables.Sometimes if the shutdown is not clear or due to any bugs
there are normally some entries on the table.Use the below query to check

set lines 200
col HOSTNAME format a30
col FLAGS format a20

select instance,PID,SERVERID,FLAGS,HOSTNAME,STATE,RETRYCOUNT,LASTWAKETIME from ods.ods_process;


If the above query returns any values after stopping OID,then it is not a clean shutdown. After ensuring the OID services are down ,truncate the table ODS.ODS_PROCESS.

truncate table ODS.ODS_PROCESS;

So now we have gone through the different ways/methods of how to check if OID services are down before starting any maintenance activities.

Tuesday, June 14, 2011

More about Cron

Hello ,

All of you would be aware that cron is a time based scheduler used in Unix based operarting systems.We used cron to schedule and execute shell scripts or commands periodically or during any date / time.

There was a requirement within our system to run a job at specific time intervals,no better option than cron.

When I logged in and issued "crontab -l" I received the following message

crontab: you are not authorized to use cron. Sorry.


On further researching found that there are two important control files which control the permissions and access to cron.They are

"cron.allow and cron.deny",both these files are ascii text and owned by root.

These files are generally found under directory /etc/cron.d/ .

If the cron.allow file does not exist and your username is not there in entry cron.deny you will be able to use cron.

If the file exists and your username does not exist in the cron.allow file then you will not be able to use cron.

The cron.deny will contain all users who are denied access to cron.

My case I just requested Unix sysadmin to add my username in file - cron.allow.

Thursday, May 5, 2011

During an 11GR2 DB installation Solaris OS Patch 124861-15 missing




If you are not installing the Pro*C precompiler, this message can be safely ignored by checking the box "Ignore all" and pressing "Next" and continue with installation.

If you wish to install the Pro*C precompiler, please install Sun Studio 12 plus patch 124861-15 (NOT Sun Studio 12 Update 1) before installing the Oracle software

Ref - BUG:9214210

Thanks to Metalink note id - 969497.1

Wednesday, May 4, 2011

Diferrent Datafile Renaming Methodologies

As far as renaming a datafile is concerned we have 3 diferrent ways through which it can be achieved

method 1 - Offline a particular datafile and renaming it
method 2 - offline the tablespace and renaming the datafile alone
method 3 - shutdown DB,mount DB and rename the datafile



Method 1
=========


Before you can use this method the database must be in archive log mode.
In the below scenario I am renaming a datafile names test11.dbf to test12.dbf



SQL> alter database datafile '/u06/oracle/11GR2/oradata/D11GR2/test11.dbf' offline;
alter database datafile '/u06/oracle/11GR2/oradata/D11GR2/test11.dbf' offline
*
ERROR at line 1:
ORA-01145: offline immediate disallowed unless media recovery enabled


SQL> alter database archivelog;

Database altered.

SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 6
Next log sequence to archive 8
Current log sequence 8
SQL>
SQL> alter database open;

Database altered.

SQL> alter database datafile '/u06/oracle/11GR2/oradata/D11GR2/test11.dbf' offline;

Database altered.


$ cp test11.dbf test12.dbf
$

SQL> alter database rename file '/u06/oracle/11GR2/oradata/D11GR2/test11.dbf' to '/u06/oracle/11GR2/oradata/D11GR2/test12.dbf';

Database altered.

SQL> alter database datafile '/u06/oracle/11GR2/oradata/D11GR2/test12.dbf' online;
alter database datafile '/u06/oracle/11GR2/oradata/D11GR2/test12.dbf' online
*
ERROR at line 1:
ORA-01113: file 8 needs media recovery
ORA-01110: data file 8: '/u06/oracle/11GR2/oradata/D11GR2/test12.dbf'


SQL> recover datafile 8;
Media recovery complete.
SQL>
SQL> alter database datafile '/u06/oracle/11GR2/oradata/D11GR2/test12.dbf' online;

Database altered.

SQL>





Method 2
=========




Tablespace Offline Datafile Rename method

I take the particular tablespace offline and then rename the datafile.

a)

alter tablespace APPS_TS_TX_IDX offline;

b)

mv /u01/oracle/PROD/db/apps_st/data5/a_media19.dbf /u01/oracle/PROD/db/apps_st/index3/a_txn_ind43.dbf


c)

alter tablespace APPS_TS_TX_IDX rename datafile
/u01/oracle/PROD/db/apps_st/data5/a_media19.dbf
to
/u01/oracle/PROD/db/apps_st/index3/a_txn_ind43.dbf;

d)

alter tablespace APPS_TS_TX_IDX online;




Method 3
=========


In this scenario we take the database down ,start the database in mount option and then rename the datafile.Finally open the database.

In the below example I am renaming datafile test2.dbf to test3.dbf.



SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u06/oracle/11GR2/oradata/D11GR2/system01.dbf
/u06/oracle/11GR2/oradata/D11GR2/sysaux01.dbf
/u06/oracle/11GR2/oradata/D11GR2/undotbs01.dbf
/u06/oracle/11GR2/oradata/D11GR2/users01.dbf
/u06/oracle/11GR2/oradata/D11GR2/example01.dbf
/u06/oracle/11GR2/oradata/D11GR2/test1.dbf
/u06/oracle/11GR2/oradata/D11GR2/test2.dbf
/u06/oracle/11GR2/oradata/D11GR2/test12.dbf

8 rows selected.

SQL>
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL>
SQL>
SQL> exit


$ mv /u06/oracle/11GR2/oradata/D11GR2/test2.dbf /u06/oracle/11GR2/oradata/D11GR2/test3.dbf



$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed May 4 17:18:22 2011
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area 2723282944 bytes
Fixed Size 2151200 bytes
Variable Size 1509952736 bytes
Database Buffers 1191182336 bytes
Redo Buffers 19996672 bytes
Database mounted.
SQL>
SQL>
SQL> alter database rename file '/u06/oracle/11GR2/oradata/D11GR2/test2.dbf' to '/u06/oracle/11GR2/oradata/D11GR2/test3.dbf';

Database altered.

SQL> alter database open;

Database altered.

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u06/oracle/11GR2/oradata/D11GR2/system01.dbf
/u06/oracle/11GR2/oradata/D11GR2/sysaux01.dbf
/u06/oracle/11GR2/oradata/D11GR2/undotbs01.dbf
/u06/oracle/11GR2/oradata/D11GR2/users01.dbf
/u06/oracle/11GR2/oradata/D11GR2/example01.dbf
/u06/oracle/11GR2/oradata/D11GR2/test1.dbf
/u06/oracle/11GR2/oradata/D11GR2/test3.dbf
/u06/oracle/11GR2/oradata/D11GR2/test12.dbf

8 rows selected.

SQL>