Friday, March 23, 2012

reset sysman password for 11g grid


Resetting forgotten SYSMAN password in Grid Control 11g
Change SYSMAN password in the database to a known value.

[oracle@grid11 ~]$ cd $OMS_HOME/bin
[oracle@grid11 bin]$ ./emctl config oms -change_repos_pwd

Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation.  All rights reserved.
-change_in_db option not specified. Password not changed in backend.
Enter Repository User’s New Password : ******
Changing monitoring credentials …
Monitoring credentials changed successfully.
Updating repository password in Credential Store…
Repository password in Credential Store updated successfully.
Bounce the OMS.
Successfully changed repository password.
If you have multiple OMS’s in your environment, run this command on all of them.
[oracle@grid11 bin]$ ./emctl stop oms -all
Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation.  All rights reserved.
Stopping WebTier…
WebTier Successfully Stopped
Stopping Oracle Management Server…
Oracle Management Server Successfully Stopped
Oracle Management Server is Down
[oracle@grid11 bin]$ ./emctl start oms
Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation.  All rights reserved.
Starting WebTier…
WebTier Successfully Started
Starting Oracle Management Server…
Oracle Management Server Successfully Started
Oracle Management Server is Up

Thursday, February 9, 2012

PGA usage per user

set lines 132
set pages 1000
col username for a30
col name for a30
select a.username,b.name STATISTIC_NAME, round(sum(c.value/1024)) PGA_USAGE_KB
from v$session a, v$statname b, v$sesstat c
where b.statistic# in (25) and a.sid=c.sid and b.statistic#=c.statistic#
and a.username is not null
group by a.username, b.name
order by 1,2
/

Monday, January 23, 2012

TO GET SESSION ID AND SEE WHICH QUERY IS HITTING DB


select
   c.owner,
   c.object_name,
   c.object_type,
   b.sid,
   b.serial#,
   b.status,
   b.osuser,
   b.machine
from
   v$locked_object a ,
   v$session b,
   dba_objects c
where
   b.sid = a.session_id
and
   a.object_id = c.object_id;



select a.sid, a.serial#, b.sql_text
    from v$session a, v$sqlarea b
    where a.sql_address=b.address
   and a.username='RMI';

select a.sid, a.serial#,a.time_remaining,a.elapsed_seconds,b.sql_text,b.users_executing
    from v$session_longops a, v$sqlarea b
    where a.sql_address=b.address
   and a.username='RMI';

TO CHECK RECYCLEBINN SPACE


select r.owner,
 count(distinct r.original_name) orig_obj,
 count(distinct r.object_name) objects,
 sum(bytes)/1024 kb
from dba_recyclebin r
 join dba_segments s
 on (r.owner = s.owner and r.object_name = s.segment_name)
group by r.owner;

Steps to apply the WebLogic patch


>>Weblogic patch location:
/mnt/Stage11i/linux/11g_GRID-64-bit/Weblogic_patch/WDJ7

>> First run the following script to set the environment variables:
>> /u01/app/oracle/Middleware/wlserver_10.3/server/bin/setWLSEnv.sh

>> Go to directory:
>> /u01/app/oracle/Middleware/utils/bsu

>> Issue the command to apply the patch:
>> ./bsu.sh -prod_dir=/u01/app/oracle/Middleware/wlserver_10.3 -patchlist=WDJ7 -verbose -install -patch_download_dir=/mnt/Stage11i/linux/11g_GRID-64-bit/Weblogic_patch/WDJ7

>> Check the patching status:
>> ./bsu.sh -view -status=applied -prod_dir=/u01/app/oracle/Middleware/wlserver_10.3

Check Statistics Advisor Jobs Status


col owner format a20
col job_name format a30
col start_date format a30
select owner,JOB_NAME,START_DATE ,ENABLED,RUN_COUNT,STOP_ON_WINDOW_CLOSE FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME ='AUTO_SPACE_ADVISOR_JOB';

select owner,JOB_NAME,START_DATE ,ENABLED,RUN_COUNT,STOP_ON_WINDOW_CLOSE FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME ='GATHER_STATS_JOB';

for metadata expdp & impdp


take export of metadata of schema only using expdp

>expdp directory=exp_dp dumpfile=j.dmp content=metadata_only schemas=<schema_name>

after that create sqlfile using impdp -

>impdp directory=exp_dp dumpfile=j.dmp logfile=imp_j.log sqlfile=j.sql include=view

You can filter the views only like above, you can get everything in the schema as follows:

>impdp directory=exp_dp dumpfile=j.dmp logfile=imp_j.log sqlfile=j.sql