July 25, 2015

How to add ASM disk to ASM Diskgroup

1. Login to the ASM instance

-bash-3.2$ ps -ef|grep pmon
oracle    1829     1  0 Jul21 ?        00:04:58 ora_pmon_PROD1
oracle    9529  8780  0 21:18 pts/0    00:00:00 grep pmon
oracle   16319     1  0  2014 ?        00:10:46 asm_pmon_+ASM1

-bash-3.2$ . oraenv
ORACLE_SID = [oracle] ? +ASM1
The Oracle base has been set to /u01/oracle/product
-bash-3.2$
-bash-3.2$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Jul 24 21:18:43 2015

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

2. Identify the disks to be added to the ASM diskgroup

SQL> select name,group_number,state,total_mb/1024 "Totalspace(GB)",free_mb/1024 "Freespace(GB)", (free_mb/total_mb)*100 "PCT_FREE" from v$asm_diskgroup;

NAME                 GROUP_NUMBER STATE       Totalspace(GB) Freespace(GB)   PCT_FREE
--------------------- ------------ ----------- -------------- ------------- ----------
SIVA_DBF01                               8 MOUNTED               600    82.396484 13.6675571

SQL> col path for a45
Select path,group_number,disk_number,mount_status,header_status,os_mb/1024,total_mb/1024,free_mb/1024 from v$asm_disk where group_number=&n;
Enter value for n: 8
old   1: Select path,group_number,disk_number,mount_status,header_status,os_mb/1024,total_mb/1024,free_mb/1024 from v$asm_disk where group_number=&n
new   1: Select path,group_number,disk_number,mount_status,header_status,os_mb/1024,total_mb/1024,free_mb/1024 from v$asm_disk where group_number=8

PATH                                          GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU OS_MB/1024 TOTAL_MB/1024 FREE_MB/1024
--------------------------------------------- ------------ ----------- ------- ------------ ---------- ------------- ------------
ORCL:SIVA_ASM01                                         8          01 CACHED  MEMBER              200           200   28.7119141
ORCL:SIVA_ASM02                                         8          02 CACHED  MEMBER              200           200   28.7089844
ORCL:SIVA_ASM03                                         8          03 CACHED  MEMBER              200           200   28.7207031

SQL> Select path,group_number,disk_number,mount_status,header_status,os_mb/1024,total_mb/1024,free_mb/1024 from v$asm_disk where header_status <>'MEMBER';

PATH                                          GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU OS_MB/1024 TOTAL_MB/1024 FREE_MB/1024
--------------------------------------------- ------------ ----------- ------- ------------ ---------- ------------- ------------
ORCL:SIVA_ASM04                                         0           4 CLOSED  PROVISIONED         200             0            0
ORCL:SIVA_ASM05                                         0           5 CLOSED  PROVISIONED         200             0            0
ORCL:SIVA_ASM06                                         0           6 CLOSED  PROVISIONED         200             0            0

3. Add the disk to the Diskgroup

SQL> alter diskgroup SIVA_DBF01 add disk 'ORCL:SIVA_ASM04' name SIVA_ASM04 size 204800m;
alter diskgroup SIVA_DBF01 add disk 'ORCL:SIVA_ASM04' name SIVA_ASM04 size 204800m
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15260: permission denied on ASM disk group

Note:
****
For adding a disk to the diskgroup you need to login as a SYSASM not SYSDBA.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

-bash-3.2$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.3.0 Production on Fri Jul 24 21:24:33 2015

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options


SQL> alter diskgroup SIVA_DBF01 add disk 'ORCL:SIVA_ASM04' name SIVA_ASM04 size 204800m rebalance power 4;

Diskgroup altered.

SQL>  select * from v$asm_operation;

GROUP_NUMBER OPERA STAT      POWER     ACTUAL      SOFAR   EST_WORK   EST_RATE EST_MINUTES ERROR_CODE
------------ ----- ---- ---------- ---------- ---------- ---------- ---------- ----------- --------------------------------------------
           8 REBAL RUN           4          4        972     154322       4344          35


Happy Learning :)









July 4, 2015

ORA-20 Maximum number of processes(150) exceeded

SQL> select status,count(*) from v$session group by status;

STATUS     COUNT(*)
-------- ----------
ACTIVE           43
INACTIVE        354

SQL> select * from v$resource_limit where resource_name in ('sessions','processes');

RESOURCE_NAME                  CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_ALLOCATION             LIMIT_VALUE
------------------------------ ------------------- --------------- ------------------------------ ------------------------------
processes                                      403             435        500                            500
sessions                                       421             530        792                            792

SQL> select username,status,count(*) from v$session group by username,status;

USERNAME                       STATUS     COUNT(*)
------------------------------ -------- ----------
PROD_101                INACTIVE         27
CRM_USER                        INACTIVE          3
SYS                            ACTIVE            1
ORDM                            INACTIVE          1
DBSNMP                         INACTIVE          2
ORDM_TEST                     INACTIVE         38

KZAENGER                       INACTIVE          4
RTALBOOM                       INACTIVE          1

CPINEDA                        INACTIVE          1
GROMERO                        INACTIVE          2
ORDM_UAT                       INACTIVE        275
PUBLIC                         INACTIVE          1

12 rows selected.

SQL> select count(*) from v$session where last_call_et>3600 and username='ORDM_UAT';

  COUNT(*)
----------
202


From the above result we can understand that there are 202 sessions are in inactive state more than half an hour.
If we kill the sessions then the issue will resolved (But confirm with the application team before killing the sessions)

July 1, 2015

Upload timed out before completion. Agent upload status failed

bash-4.1$  ./emctl upload agent
Oracle Enterprise Manager Cloud Control 12c Release 2
Copyright (c) 1996, 2012 Oracle Corporation.  All rights reserved.
---------------------------------------------------------------
EMD upload error:full upload has failed: Upload Recent Sending Statistics
________________________________

Avg send time=0.0 milliseconds
Backoff Event List
________________________________
Upload Failure List
_______________________________
Connection Event List
_____________________________
Upload timed out before completion.
Number of files to upload before the uploadNow call: 4903, total size (MB): 3.049202
Remaining number of files to upload: 4903, total size (MB): 3.049202 (TIMEOUT)

When you got the above error we need to do the as the below.

-bash-4.1$ emctl stop agent
Oracle Enterprise Manager Cloud Control 12c Release 2
Copyright (c) 1996, 2012 Oracle Corporation.  All rights reserved.
Stopping agent ..... stopped.
-bash-4.1$ pwd
/u01/app/oracle/product/agent12c/agent_inst/sysman/emd

you need to move the upload,colletction and state folders as stated the below.

-bash-4.1$ ls -ltrh
total 72K
drwxr-----  2 oracle dba 4.0K Sep 16  2014 dumps
drwxr-----  4 oracle dba 4.0K Sep 16  2014 upload
drwxr-----  2 oracle dba 4.0K Sep 16  2014 metricExtLib
drwxr-----  2 oracle dba 4.0K Sep 16  2014 attachmentDB
drwxr-----  2 oracle dba 4.0K Sep 16  2014 metricCache
drwxr-----  2 oracle dba 4.0K Sep 16  2014 temp
drwxr----- 12 oracle dba 4.0K Dec 10  2014 state
-rw-r-----  1 oracle dba 5.9K Apr  8 15:32 targets.xml.bak
-rw-r-----  1 oracle dba  910 Jun 26 22:10 blackouts.xml.bak
-rw-r-----  1 oracle dba   13 Jun 27 00:46 blackouts.xml
-rw-r-----  1 oracle dba 3.1K Jun 30 09:06 emagent_storage.config
-rw-r-----  1 oracle dba 5.9K Jul  1 03:48 targets.xml
-rw-r-----  1 oracle dba    0 Jul  1 03:48 blackouts.lck
-rw-r-----  1 oracle dba  282 Jul  1 04:01 agntstmp.txt.bak
drwxr-----  2 oracle dba 4.0K Jul  1 04:03 collection
-rw-r-----  1 oracle dba   23 Jul  1 04:03 ag_current_status.msg
-rw-r-----  1 oracle dba  321 Jul  1 04:03 agntstmp.txt
-bash-4.1$ cd upload
-bash-4.1$ ls -ltrh
total 16K
drwxr----- 10 oracle dba 4.0K Sep 16  2014 upload
drwxr-----  2 oracle dba  12K Jul  1 04:03 pending
-bash-4.1$ mkdir old
-bash-4.1$ pwd
/u01/app/oracle/product/agent12c/agent_inst/sysman/emd/upload
-bash-4.1$ mv upload /u01/app/oracle/product/agent12c/agent_inst/sysman/emd/upload/old
-bash-4.1$ mv pending /u01/app/oracle/product/agent12c/agent_inst/sysman/emd/upload/old
-bash-4.1$ ls -ltrh
total 4.0K
drwxr-xr-x 4 oracle dba 4.0K Jul  1 04:05 old
-bash-4.1$ cd ..
-bash-4.1$ ls -ltrh
total 72K
drwxr-----  2 oracle dba 4.0K Sep 16  2014 dumps
drwxr-----  2 oracle dba 4.0K Sep 16  2014 metricExtLib
drwxr-----  2 oracle dba 4.0K Sep 16  2014 attachmentDB
drwxr-----  2 oracle dba 4.0K Sep 16  2014 metricCache
drwxr-----  2 oracle dba 4.0K Sep 16  2014 temp
drwxr----- 12 oracle dba 4.0K Dec 10  2014 state
-rw-r-----  1 oracle dba 5.9K Apr  8 15:32 targets.xml.bak
-rw-r-----  1 oracle dba  910 Jun 26 22:10 blackouts.xml.bak
-rw-r-----  1 oracle dba   13 Jun 27 00:46 blackouts.xml
-rw-r-----  1 oracle dba 3.1K Jun 30 09:06 emagent_storage.config
-rw-r-----  1 oracle dba 5.9K Jul  1 03:48 targets.xml
-rw-r-----  1 oracle dba    0 Jul  1 03:48 blackouts.lck
-rw-r-----  1 oracle dba  282 Jul  1 04:01 agntstmp.txt.bak
drwxr-----  2 oracle dba 4.0K Jul  1 04:03 collection
-rw-r-----  1 oracle dba   23 Jul  1 04:03 ag_current_status.msg
-rw-r-----  1 oracle dba  321 Jul  1 04:03 agntstmp.txt
drwxr-----  3 oracle dba 4.0K Jul  1 04:05 upload
-bash-4.1$ cd collection

-bash-4.1$ mkdir old
-bash-4.1$ mv * old
mv: cannot move `old' to a subdirectory of itself, `old/old'
-bash-4.1$ ls -ltrh
total 4.0K
drwxr-xr-x 2 oracle dba 4.0K Jul  1 04:05 old
-bash-4.1$ cd ..
-bash-4.1$ ls -ltrh
total 72K
drwxr-----  2 oracle dba 4.0K Sep 16  2014 dumps
drwxr-----  2 oracle dba 4.0K Sep 16  2014 metricExtLib
drwxr-----  2 oracle dba 4.0K Sep 16  2014 attachmentDB
drwxr-----  2 oracle dba 4.0K Sep 16  2014 metricCache
drwxr-----  2 oracle dba 4.0K Sep 16  2014 temp
drwxr----- 12 oracle dba 4.0K Dec 10  2014 state
-rw-r-----  1 oracle dba 5.9K Apr  8 15:32 targets.xml.bak
-rw-r-----  1 oracle dba  910 Jun 26 22:10 blackouts.xml.bak
-rw-r-----  1 oracle dba   13 Jun 27 00:46 blackouts.xml
-rw-r-----  1 oracle dba 3.1K Jun 30 09:06 emagent_storage.config
-rw-r-----  1 oracle dba 5.9K Jul  1 03:48 targets.xml
-rw-r-----  1 oracle dba    0 Jul  1 03:48 blackouts.lck
-rw-r-----  1 oracle dba  282 Jul  1 04:01 agntstmp.txt.bak
-rw-r-----  1 oracle dba   23 Jul  1 04:03 ag_current_status.msg
-rw-r-----  1 oracle dba  321 Jul  1 04:03 agntstmp.txt
drwxr-----  3 oracle dba 4.0K Jul  1 04:05 upload
drwxr-----  3 oracle dba 4.0K Jul  1 04:05 collection
-bash-4.1$ cd state

-bash-4.1$ mkdir old
-bash-4.1$ mv * old
mv: cannot move `old' to a subdirectory of itself, `old/old'
-bash-4.1$ ls -ltrh
total 4.0K
drwxr-xr-x 12 oracle dba 4.0K Jul  1 04:06 old
-bash-4.1$ emctl status agent
Oracle Enterprise Manager Cloud Control 12c Release 2
Copyright (c) 1996, 2012 Oracle Corporation.  All rights reserved.
---------------------------------------------------------------
Agent is Not Running
-bash-4.1$ emctl clearstate agent
Oracle Enterprise Manager Cloud Control 12c Release 2
Copyright (c) 1996, 2012 Oracle Corporation.  All rights reserved.
EMD clearstate completed successfully
-bash-4.1$ df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper         99G   63G   32G  67% /u01

-bash-4.1$ emctl start agent
Oracle Enterprise Manager Cloud Control 12c Release 2
Copyright (c) 1996, 2012 Oracle Corporation.  All rights reserved.
Starting agent ......... started.
-bash-4.1$ emctl upload agent
Oracle Enterprise Manager Cloud Control 12c Release 2
Copyright (c) 1996, 2012 Oracle Corporation.  All rights reserved.
---------------------------------------------------------------
EMD upload completed successfully

June 20, 2015

ORA-16501: the Data Guard broker operation failed

ORA-16664: unable to receive the result from a database

You may see the redo shipping is working fine from Primary to standby DB. But you can notice this error when you try to enable the DG broker.

Test the following:

1. connection to standby from Primary server - should be good if the redo shipping is fine
2. connection from standby to Primary server

This could be the cause - As during normal redo shipping we don't need the vice versa connection from standby to Primary but when you enable the DG Broker it needs that for the auto switchover, fail over.

From standby server, try to connect to the Primary DB. If it throws the any error look into it accordingly.

Primary:
----------
Alertlog Details:
*************
Thu Jun 18 17:19:55 2015
LNS: Attempting destination LOG_ARCHIVE_DEST_2 network reconnect (3135)
LNS: Destination LOG_ARCHIVE_DEST_2 network reconnect abandoned
Error 3135 for archive log file 3 to 'ebox'
Errors in file /u01/app/oracle/diag/rdbms/eb/eb/trace/eb_nsa2_0022.trc:

ORA-03135: connection lost contact

DGBroker Log(DRC log) Details:
********************
06/18/2015 18:00:25
Failed to send message to site p1ebox. Error code is ORA-16501.
Data Guard Broker Status Summary:
  Type                        Name                             Severity  Status
  Configuration               DG-eb                           Warning  ORA-16607
  Primary Database            eb                              Success  ORA-00000
  Physical Standby Database   ebox                              Error  ORA-16501

DGMGRL> show configuration

Configuration - DG-eb

  Protection Mode: MaxPerformance
  Databases:
  eb   - Primary database
  ebox - Physical standby database
  Error: ORA-16501: the Data Guard broker operation failed

Fast-Start Failover: DISABLED

Configuration Status:
ERROR
                               
Standby:
----------

Alertlog Details:
*****************
Thu Jun 18 17:19:55 2015
RFS[4]: Possible network disconnect with primary database
Thu Jun 18 17:25:29 2015
Primary database is in MAXIMUM PERFORMANCE mode

DGBroker Log(DRC log) Details:
*********************
05/28/2015 19:23:30
Site eb returned ORA-16664.
05/28/2015 19:25:45
Site eb returned ORA-16664.
05/28/2015 19:26:02
Redo Apply is running without USING CURRENT LOGFILE option while DelayMins=0
05/28/2015 20:12:38
Command ENABLE DATABASE ebox completed
06/08/2015 11:35:01
Site eb returned ORA-16664.
06/17/2015 12:30:39
Command ENABLE CONFIGURATION completed
Creating Data Guard Broker Monitor Process (DMON)
06/18/2015 07:53:12

06/18/2015 17:53:40
Site eb returned ORA-16664.

 DGMGRL> show configuration

Configuration - DG-eb

  Protection Mode: MaxPerformance
  Databases:
    eb   - Primary database
    ebox - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
ORA-16664: unable to receive the result from a database
DGM-17017: unable to determine configuration status

We have done the below steps.

DGMGRL> show configuration

Configuration - DG-eb

  Protection Mode: MaxPerformance
  Databases:
    eb   - Primary database
    ebox - Physical standby database
    Error: ORA-16501: the Data Guard broker operation failed

Fast-Start Failover: DISABLED

Configuration Status:
ERROR

DGMGRL> enable configuration
Enabled.

DGMGRL> show configuration

Configuration - DG-eb

  Protection Mode: MaxPerformance
  Databases:
    eb   - Primary database
    ebox - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

Primary DRC log:
***************
06/18/2015 18:22:10
ENABLE CONFIGURATION
06/18/2015 18:22:11
Command ENABLE CONFIGURATION completed

Standby DRC log:
**************
06/18/2015 18:22:11
Command ENABLE CONFIGURATION completed

Happy Learning :)


June 10, 2015

ORA-28001: the password has expired

SYS>> select dbms_metadata.get_ddl('USER','DBSNMP') from dual;

DBMS_METADATA.GET_DDL('USER','DBSNMP')
--------------------------------------------------------------------------------
   CREATE USER "DBSNMP" IDENTIFIED BY VALUES 'S:DDFDBFCD2DE1B4C1BEF25EA7E30A2F7C
558313D07013DE468963223CF2EC;E066D214D5421CCC'
      DEFAULT TABLESPACE "SYSAUX"
      TEMPORARY TABLESPACE "TEMP"
      PASSWORD EXPIRE

SYS>>alter user DBSNMP identified by values 'S:DDFDBFCD2DE1B4C1BEF25EA7E30A2F7C558313D07013DE468963223CF2EC;E066D214D5421CCC';

User altered.

SYS>>select dbms_metadata.get_ddl('USER','DBSNMP') from dual;

DBMS_METADATA.GET_DDL('USER','DBSNMP')
--------------------------------------------------------------------------------
   CREATE USER "DBSNMP" IDENTIFIED BY VALUES 'S:DDFDBFCD2DE1B4C1BEF25EA7E30A2F7C
558313D07013DE468963223CF2EC;E066D214D5421CCC'
      DEFAULT TABLESPACE "SYSAUX"
      TEMPORARY TABLESPACE "TEMP"

March 14, 2015

Recreating the Database Link

Hi,

SQL> show parameter db_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----
db_name                              string      DEV


SQL> select * from dba_db_links where db_link like 'CMS_LINK.ABC.ORG';

OWNER                          DB_LINK                             USERNAME                       HOST                                          CREATED
------------------------------ ----------------------------------- ------------------------------ --------------------------------------------- ---------
CSR                            CMS_LINK.ABC.ORG                CSR                            CMS                                           25-DEC-14


SQL> SELECT DBMS_METADATA.GET_DDL('DB_LINK','CMS_LINK.ABC.ORG','CSR') FROM dual;

DBMS_METADATA.GET_DDL('DB_LINK','CMS_LINK.ABC.ORG','CSR')
--------------------------------------------------------------------------------

  CREATE DATABASE LINK "CMS_LINK.ABC.ORG"
   CONNECT TO "CSR" IDENTIFIED BY VALUES '05B57442670C49D297101E6A84'
   USING 'CMS'


SQL> drop database link CMS_LINK.ABC.ORG;
drop database link CMS_LINK.ABC.ORG
                   *
ERROR at line 1:
ORA-02024: database link not found


SQL> CREATE PROCEDURE csr.drop_db_link AS
  2  BEGIN
  3  EXECUTE IMMEDIATE 'drop database link CMS_LINK.ABC.ORG';
  4  END drop_db_link;
  5  /

Procedure created.

SQL> exec csr.drop_db_link

PL/SQL procedure successfully completed.


SQL> CREATE PUBLIC DATABASE LINK "CMS_LINK.ABC.ORG"
  2     CONNECT TO "CSR" IDENTIFIED BY VALUES '05B57442670C49D297101E6A84'
  3     USING 'CMS';

Database link created.


SQL> select * from dba_db_links where db_link like 'CMS_LINK.ABC.ORG';

OWNER                          DB_LINK                             USERNAME                       HOST                                          CREATED
------------------------------ ----------------------------------- ------------------------------ --------------------------------------------- ---------
PUBLIC                         CMS_LINK.ABC.ORG                CSR                            CMS                                           13-MAR-15

Happy Learning :)

March 12, 2015

Backup and restore of Crontab

Hi,

A simple way to take the backup of crontab and restore it back to its original state.

Crontab Backup:
*************
$crontab -l>crontab_backup.out

Restore Crontab:
*************
$crontab crontab_backup.out

Once done just crosscheck it.


Happy Learning :)

February 18, 2015

Apply Jan 2015 PSU on 11.2.0.4

1. Download the Software from Oracle support
2.Transfer the software from our local system to client server using winscp.
3.  Comment out crontab entries on respective sever before applying patch to avoid alerts.
4. Blackout the target in OEM
5. Apply Patch using below steps
6. Uncomment crontab entries which was commented
7. Remove blackout in OEM
8. Ensure Database, Listener is up and running.

5. PSU APPLY STEPS (19769496- PSU JAN'15)
*******************
1) Pre-requisite check (Opatch Version check and Patch Conflict)
$ export PATH=$PATH:$ORACLE_HOME/OPatch
Determine whether any currently installed one-off patches conflict with the PSU patch as follows:
$ unzip p 19769489_112040_SOLARIS64
$ cd 19769489
$ opatch prereq CheckConflictAgainstOHWithDetail -ph ./

Oracle Interim Patch Installer version 11.2.0.3.6
Copyright (c) 2013, Oracle Corporation.  All rights reserved.
PREREQ session
Oracle Home       : /u01/app/oracle/product/11.2.0.4/ dbhome_1
Central Inventory : /u01/app/oracle/product/11.2.0.4/oraInventory
   from           : /u01/app/oracle/product/11.2.0.4/oraInst.loc
OPatch version    : 11.2.0.3.6
OUI version       : 11.2.0.3.0
Log file location : /u01/app/oracle/product/11.2.0.4/cfgtoollogs/opatch/opatch2015-02-13_00-26-40AM_1.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
Note: If OPatch version is not compatible then you need to apply the patch on OPatch first. Download the latest OPatch from Oracle support. Copy the latest OPatch software to OPatch directory resides in ORACLE HOME.
2)  Shutdown all oracle database services,listener.
 [oracle@ABC-TEST PSU_JAN15]$ lsnrctl stop LISTENER
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 10-FEB-2015 21:24:15
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
Down the database
[oracle@ABC-TEST PSU_JAN15]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Feb 10 21:25:16 2015
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Release 11.2.0.4.0 - 64bit Production
SQL> select name,open_mode from v$database;
NAME      OPEN_MODE
--------- --------------------
ABC  READ WRITE
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
3)  Apply the OPatch
[oracle@ABC-TEST 19769489]$ opatch apply
Oracle Interim Patch Installer version 11.2.0.3.6                                                                                       Copyright (c) 2013, Oracle Corporation.  All rights reserved.                                                                 Oracle Home       : /u01/app/oracle/product/11.2.0.4/dbhome_1                                                               Central Inventory : /u01/app/oraInventory                                                                                                 from           : /u01/app/oracle/product/11.2.0.4/dbhome_1/oraInst.loc 
OPatch version    : 11.2.0.3.6                                                                                                                   OUI version       : 11.2.0.4.0 
Log file location : /u01/app/oracle/product/11.2.0.4/dbhome_1/cfgtoollogs/opatch/opatch2015-02-10_21-32-06PM_1.log                                                                                                                                               
Verifying environment and performing prerequisite checks...       
OPatch continues with these patches:   19769489 
Do you want to proceed? [y|n] 
y                                                                                                                                                                 User Responded with: Y                                                                                                                           All checks passed.                                                                                                                                     Provide your email address to be informed of security issues, install and initiate Oracle Configuration Manager. Easier for you if you use your Oracle Support Email address/User Name.
Visit http://www.oracle.com/support/policies.html for details.                                                                 Email address/User Name: 
You have not provided an email address for notification of security issues.
Do you wish to remain uninformed of security issues ([Y]es, [N]o) [N]:  y                                             Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/11.2.0.4/dbhome_1')                  
Is the local system ready for patching? [y|n]  y
User Responded with: Y                                                                                                                           Backing up files...                                                                                                     
Applying sub-patch '19769489' to OH '/u01/app/oracle/product/11.2.0.4/dbhome_1'
ApplySession: Optional component(s) [ oracle.oraolap, 11.2.0.4.0 ] , 
[ oracle.sysman.agent, 11.2.0.4.0 ]  not present in the Oracle Home or a higher version is found.                  
Patching component oracle.precomp.common, 11.2.0.4.0...
Patching component oracle.ovm, 11.2.0.4.0...
Patching component oracle.xdk, 11.2.0.4.0...
Patching component oracle.rdbms.util, 11.2.0.4.0...
Patching component oracle.rdbms, 11.2.0.4.0...
Patching component oracle.rdbms.dbscripts, 11.2.0.4.0...
Patching component oracle.xdk.parser.java, 11.2.0.4.0...
Patching component oracle.rdbms.rsf, 11.2.0.4.0...
Patching component oracle.xdk.rsf, 11.2.0.4.0...
Patching component oracle.rdbms.rman, 11.2.0.4.0...
Patching component oracle.rdbms.deconfig, 11.2.0.4.0...
Verifying the update...
Composite patch 19769489 successfully applied.
Log file location: /u01/app/oracle/product/11.2.0.4/dbhome_1/cfgtoollogs/opatch/opatch2015-02-10_21-32-06PM_1.log
OPatch succeeded.
4) connect to the database using SQL*Plus. Connect as SYSDBA and run the catbundle.sql script as follows:
$ sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @?/rdbms/admin/catbundle.sql psu apply

Note: If there are errors, refer to Section 5, "Known Issues". In READ ME.
The catbundle.sql execution is reflected in the dba_registry_history view by a row associated with bundle series PSU.

SQL> select * from DBA_REGISTRY_HISTORY;
ACTION_TIME               ACTION                         NAMESPACE                      VERSION                                ID BUNDLE_SERIES                  COMMENTS
------------------------- ------------------------------ ------------------------------ ------------------------------ ---------- ------------------------------ -----------------------------------
17-DEC-14 07.03.58.553848 APPLY                          SERVER                         11.2.0.4                                4 PSU                            PSU 11.2.0.4.4
 AM
10-FEB-15 09.45.48.024710 APPLY                          SERVER                         11.2.0.4                                5 PSU                            PSU 11.2.0.4.5
 PM
[oracle@ABC-TEST OPatch]$ opatch lsinv -bugs_fixed | grep -i psu
20074391   19769489  Tue Feb 10 21:34:21 EST 2015   PSU 11.2.0.3.13 POST-DEINSTALLATION CATBUNDLE
19727057   19121551  Tue Dec 16 14:43:35 EST 2014   HANDLE JVMPSU.SQL IN CATBUNDLE
18180390   18031668  Tue Dec 16 14:42:04 EST 2014   AFTER APPLYING DBPSU 11.2.0.4.1 DB PROCESSES GET
Check the following log files in $ORACLE_HOME/cfgtoollogs/catbundle or $ORACLE_BASE/cfgtoollogs/catbundle for any errors:
catbundle_PSU_<database SID>_APPLY_<TIMESTAMP>.log
catbundle_PSU_<database SID>_GENERATE_<TIMESTAMP>.log
where TIMESTAMP is of the form YYYYMMMDD_HH_MM_SS. If there are errors, refer to Section 5, "Known Issues".

5) Start the Listener
[oracle@ABC-TEST PSU_JAN15]$ lsnrctl start LISTENER
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 10-FEB-2015 21:24:15
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
[oracle@ABC-TESTDB PSU_JAN15]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 10-FEB-2015 21:20:31
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                17-DEC-2014 07:46:12
Uptime                    55 days 13 hr. 34 min. 19 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/ABC-TESTDB/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Services Summary...
Service "ABC" has 1 instance(s).
  Instance "ABC", status READY, has 1 handler(s) for this service...
Service "ABCXDB" has 1 instance(s).
  Instance "ABC", status READY, has 1 handler(s) for this service...

Rollback Steps:
************
1.Shutdown the database and listener
2. Verify that an $ORACLE_HOME/rdbms/admin/catbundle_PSU_<database SID>ROLLBACK.sql file exists for each database associated with this ORACLE_HOME. If this is not the case, you must execute the step (Loading Modified SQL Files into the Database)
3. Cd 19769496
export PATH=$PATH:$ORACLE_HOME/OPatch
opatch rollback -id 19769496
4. STARTUP DATABASE
For each database instance running out of the ORACLE_HOME, connect to the database using SQL*Plus as SYSDBA and run the rollback script as follows:
cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catbundle_PSU_<database SID>_ROLLBACK.sql
SQL> QUIT
5.      Check the log file for any errors. The log file is found in $ORACLE_BASE/cfgtoollogs/catbundle and is named catbundle_PSU_<database SID>ROLLBACK_<TIMESTAMP>.log where TIMESTAMP is of the form YYYYMMMDD_HH_MM_SS
6.      Start Listener


January 21, 2015

How to Kill a session in 10g OEM

To kill a session in OEM level,

Login to the OEM > Go to the Targets> Select the database > Click on Performance > select Search Sessions (in Additional Monitoring Links) > In the Search filter give the Sid if you know otherwise press the Go button it will list out all the sessions then select the required sid > Click on kill session button > it will ask for the Confirmation, Select the Kill Immediate button then Press Yes >  Then you will get
ORA-00031: Session marked for kill error.
Then the session is no more exist in the database.


Happy Learning :)

January 4, 2015

Check Temp tablespace usage in oracle 8i

For checking the temp used, allocation and free space, use the below query.

SQL> select ddf.tablespace_name, ddf.allocatedspace "AllocatedSpace(in GB)",
ds.usedspace "UsedSpace(in GB)",dfs.freespace "FreeSpace(in GB)",
round(((dfs.freespace/ddf.allocatedspace)*100),2) "FreeSpace%",round(((ds.usedspace/ddf.allocatedspace)*100),2) "UsedSpace%"
from
(select tablespace_name,round((sum(bytes)/1024/1024/1024),2) allocatedspace from dba_data_files group by tablespace_name)ddf,
(select tablespace_name,round((sum(bytes)/1024/1024/1024),2) usedspace from dba_segments group by tablespace_name)ds,
(select tablespace_name,round((sum(bytes)/1024/1024/1024),2) freespace from dba_free_space group by tablespace_name)dfs
where
ddf.tablespace_name=ds.tablespace_name and
ds.tablespace_name=dfs.tablespace_name and
ddf.tablespace_name='TEMP';


TABLESPACE_NAME                Allocated(in GB)  Used(in GB) Free(in GB)   Free%   Used%
------------------------------                   ---------------------    ---------------     ----------------   ----------   ----------
TEMP                                            1.95              .07                 1.88            96.41     3.59


* If you don't now the the temp tablespace name you can obtain it from dba_tablespaces.

To find out the which user using most temp space can be find by using the below query

SQL> SELECT s.username,s.sid,s.serial#,u.tablespace, u.contents, u.extents, u.blocks FROM v$session s, v$sort_usage u WHERE s.saddr=u.session_addr order by u.blocks desc;


USERNAME SID SERIAL# TABLESPACE CONTENTS EXTENTS BLOCKS 
------------------------------ ---------- ---------- ------------------------------- --------- ---------- ---------- 
SYS 156 36776 TEMP PERMANENT 61 7929 
BGAPP 176 61877 TEMP PERMANENT 1 129 
BGAPP 176 61877 TEMP PERMANENT 1 129

In the above result it clearly shows that most of the temp is used by the SYS user. So you have to find which sql statement consuming more temp by using the below query.

SQL> SELECT SQL_TEXT FROM V$SQLAREA WHERE (ADDRESS, HASH_VALUE) IN (SELECT SQL_ADDRESS, SQL_HASH_VALUE FROM V$SESSION WHERE SID= 156;

SQL_TEXT 
--------------------------------------------- 
analyze table OC.BKP_ODOMREADINGENTRY_2013010 
2 compute statistics

In this case the above sql statement consuming more temp space.