Sunday, November 9, 2014

if not able to create user with particular name and getting user or role exist

select role from DBA_roles;

->Take a backup of the role

-> Drop the role ( Which has the same name as user)

-> Create the user

Note : Roles are not listed in all_objects or dba_objects.

Script to clone one user and his privilages to another user

rem --------------------------------------------------------------------------------------------------------
rem Name                : CLONEUSER.SQL
rem
rem Compatible versions : 10.x and above
rem
rem Description         : This script will generate SQL file with DDLs for user creation, associated grants
rem                       and privilegs (roles, system privileges, object privileges and tablespace quotas)
rem
rem prerequisites       : - You must login with DBA role to execute this script
rem                       - Package DBMS_METADATA must be in valid status
rem
rem --------------------------------------------------------------------------------------------------------
rem
----------------------
-- Setting SQL prompt:
----------------------
whenever sqlerror exit;
set serveroutput on long 100000000 pagesize 60 linesize 150 heading off feedback off verify off echo off
--------------------------------------------------
-- Handling Exception for Insufficient privileges:
--------------------------------------------------
declare
        privusercnt     number;
begin
    select count(username)
    into   privusercnt
    from   user_role_privs
    where  granted_role = 'DBA'
    and    username = ora_login_user;
    if ( privusercnt = 0 ) then
      raise_application_error
         (-20001, 'ERROR !'
          || CHR (10)
          || '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
          || CHR (10)
          || 'INFO: Insufficient privileges. You must login with DBA role to execute this script'
          || CHR (10)
          || '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
          || CHR (10)
          || CHR (10)
          || 'Terminating the script...'
         );
    end if;
end;
/
-------------------------------------------------------
-- Handling Exception for Invaid DBMS_METADATA package:
-------------------------------------------------------
declare
        invalidstatcnt  number;
begin
    select count(status)
    into   invalidstatcnt
    from   dba_objects
    where  object_name = 'DBMS_METADATA'
    and    status <> 'VALID';
    if ( invalidstatcnt > 0 ) then
      raise_application_error
         (-20001, 'ERROR !'
          || CHR (10)
          || '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
          || CHR (10)
          || 'INFO: Package SYS.DBMS_METADATA is not in valid status. Please recompile'
          || '      the package and package body, and try again.'
          || CHR (10)
          || '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
          || CHR (10)
          || CHR (10)
          || 'Terminating the script...'
         );
    end if;
end;
/
column dbname noprint new_value db_name
column fdate noprint new_value datestamp

select name dbname,
       to_char(sysdate,'yyyymmddhh24miss') fdate
from   v$database
/
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prompt ATTENTION:
prompt
prompt (1) A NULL | ENTER for source user will abort the script.
prompt (2) A NULL | ENTER for target user will keep the same source user name as target user.
prompt (3) To abort the script execution, please use CTRL+d
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prompt
accept sourceuser prompt "Enter source user for generating DDL : "
----------------------------------------------
-- Handling Exception for Invalid source user:
----------------------------------------------
declare
        sourceusercount number;
begin
    select count(username)
    into   sourceusercount
    from   dba_users
    where  username = upper(trim('&&sourceuser'));
    if ( sourceusercount = 0 ) then
      raise_application_error
         (-20002, 'ERROR !'
          || CHR (10)
          || '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
          || CHR (10)
          || 'INFO: Invalid username specified. Please enter a valid username'
          || CHR (10)
          || '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
          || CHR (10)
          || CHR (10)
          || 'Terminating the script...'
         );
    end if;
end;
/
prompt
accept targetuser prompt "Enter target user for generating DDL : "
prompt

------------------------------------------------------
-- Setting Transform Parameters for the DDL Transform:
------------------------------------------------------
begin
    dbms_metadata.set_transform_param (dbms_metadata.session_transform, 'SQLTERMINATOR', true);
    dbms_metadata.set_transform_param (dbms_metadata.session_transform, 'PRETTY', true);
end;
/
------------------
-- Generating DDL:
------------------
spool user_ddl_&&sourceuser._&&db_name._&&datestamp..sql

prompt
prompt -- (1). DDL for user creation:
-------------------------------------
prompt
prompt -- Notes:
prompt
prompt -- (1) Please edit the password, default tablespace, temporary tablespace for target user.
prompt -- (2) If not, all these attributes will be the same as source user.
prompt -- (3) If you are using 11g database, please make sure that the encripted passoword dont have any space | line break
prompt
col userddl format a600
select trim(replace (dbms_metadata.get_ddl('USER',upper(trim('&&sourceuser')))
  ,'USER "'||upper(trim('&&sourceuser'))||'"','USER "'||upper(trim(nvl('&&targetuser','&&sourceuser')))||'"')) userddl
from dual
where exists
  (select 'x'
  from dba_users drp
  where drp.username = upper(trim('&&sourceuser')))
/
set linesize 110
prompt
prompt -- (2). DDL for tablespace quotas:
-----------------------------------------
prompt
prompt -- Note: - Please verify and edit the target tablespace names, quotas by checking contents.
prompt
select 'ALTER USER '
  ||replace(username,upper(trim('&&sourceuser')),upper(trim(nvl('&&targetuser','&&sourceuser'))))
  ||' QUOTA '
  ||decode(max_bytes,-1,'UNLIMITED',max_bytes)
  ||' ON '
  ||tablespace_name
  ||';' ddl
from dba_ts_quotas
where username = upper(trim('&&sourceuser'))
and  exists
  (select 'x'
  from dba_ts_quotas drp
  where drp.username = upper(trim('&&sourceuser')))
/
/*
----------------------------------------------------------------------------------------------------------
Note:
-----
The below SQL can be useed instead of the above TABLESPACE QUOTA generation command
this will generate the DDL in PL/SQL block format.

select replace (dbms_metadata.get_granted_ddl('TABLESPACE_QUOTA',upper(trim('&&sourceuser')))
  ,'"'||upper(trim('&&sourceuser'))||'"','"'||upper(trim(nvl('&&targetuser','&&sourceuser')))||'"') ddl
from dual
where exists
  (select 'x'
  from dba_ts_quotas drp
  where drp.username = upper(trim('&&sourceuser')))
/
----------------------------------------------------------------------------------------------------------
*/
prompt
prompt -- (3). DDL for roles:
-----------------------------
select replace (dbms_metadata.get_granted_ddl('ROLE_GRANT',upper(trim('&&sourceuser' )))
  ,'"'||upper(trim('&&sourceuser'))||'"','"'||upper(trim(nvl('&&targetuser','&&sourceuser')))||'"') ddl
from dual
where exists
  (select 'x'
  from dba_role_privs drp
  where drp.grantee = upper(trim('&&sourceuser')))
/
-- DDL for alter user with default role
--
select replace (dbms_metadata.get_granted_ddl('DEFAULT_ROLE',upper(trim('&&sourceuser' )))
  ,'"'||upper(trim('&&sourceuser'))||'"','"'||upper(trim(nvl('&&targetuser','&&sourceuser')))||'"') ddl
from dual
where exists
  (select 'x'
  from dba_role_privs drp
  where drp.grantee = upper(trim('&&sourceuser')))
/

prompt
prompt -- (4). DDL for system privileges:
-----------------------------------------
select replace (dbms_metadata.get_granted_ddl('SYSTEM_GRANT',upper(trim( '&&sourceuser')))
  ,'"'||upper(trim('&&sourceuser'))||'"','"'||upper(trim(nvl('&&targetuser','&&sourceuser')))||'"') ddl
from dual
where exists
  (select 'x'
  from dba_sys_privs drp
  where drp.grantee = upper(trim('&&sourceuser')))
/

prompt
prompt -- (5). DDL for object privileges:
-----------------------------------------
select replace (dbms_metadata.get_granted_ddl('OBJECT_GRANT',upper(trim( '&&sourceuser')))
  ,'"'||upper(trim('&&sourceuser'))||'"','"'||upper(trim(nvl('&&targetuser','&&sourceuser')))||'"') ddl
from dual
where exists
  (select 'x'
  from dba_tab_privs drp
  where drp.grantee = upper(trim('&&sourceuser')))
/

spool off

prompt
prompt Post steps:
prompt ~~~~~~~~~~~
prompt INFO: (1) Please review, edit and execute the script user_ddl_&&sourceuser._&&db_name._&&datestamp..sql in target database.
prompt INFO: (2) Please remove space | line break from the SQL file, before execution
prompt
------------------------
-- Resetting SQL prompt:
------------------------
prompt
prompt

undefine sourceuser targetuser db_name datestamp
whenever sqlerror continue;
set heading on feedback on verify on echo on
exit;

Script to drop all objects in a schema




drop_all_objects_of_selected_user.sql

 REM name: drop_objects_of_selected_user.sql
  REM usage:@drop_objects_of_selected_user.sql
  REM -------------------------------------------------------------------------
  REM requirements: dba-role
  REM -------------------------------------------------------------------------
  REM -------------------------------------------------------------------------
  REM Purpose:
  REM This script drops all objects (except DATABASE LINK) of a user, which must
  REM be typed in after this script was started. Only one user can be specified
  REM for each run. The user typed in must be different to SYS or SYSTEM.
  REM -------------------------------------------------------------------------
  REM -------------------------------------------------------------------------
select 'Attention ! This script will drop all objects of the user you type in !' ATTENTION from dual;
select 'If you are not sure to finish, so break with ctrl+d !' ATTENTION from dual;
accept user_to_clean prompt "Enter user to drop all his objects: "
set linesize 120 heading off termout off pagesize 2000 recsep 0 trimspool on
set feedback off echo off show off ver off
set serveroutput on
spool drop_all_objects_of_selected_user_l1.sql
declare
        cnt_user_objects number;
        ora_version number;
begin
        dbms_output.enable;
        select max(to_number(substr(version,1,1))) into ora_version from dba_registry;
        IF ora_version > 4 THEN
--              dbms_output.put_line('This is Oracle-version lower than version 10');
                dbms_output.put_line('set feedback off echo off show off ver off');
                dbms_output.put_line('set linesize 120 heading off termout off pagesize 2000 trimspool on');
                dbms_output.put_line('spool drop_all_objects_of_selected_user_l2.sql');
                dbms_output.put_line('select '||'''spool drop_all_objects_of_user_'''||'||'||'''&&user_to_clean'''||'||'||'''.log'''||' from dual;');
                dbms_output.put_line('select '||'''drop table "'''||'||'||'owner'||'||'||'''"."'''||'||'||'table_name'||'||'||'''" cascade constraints;'''||' from dba_tables where owner=upper('||'''&&user_to_clean'''||') AND owner not in ('||'''SYS'''||','||'''SYSTEM'''||');');
                dbms_output.put_line('select '||'''drop '''||'||'||'object_type'||'||'||''' "'''||'||'||'owner'||'||'||'''"."'''||'||'||'object_name'||'||'||'''";'''||' from dba_objects where owner=upper('||'''&&user_to_clean'''||') AND owner not in ('||'''SYS'''||','||'''SYSTEM'''||') AND object_type not in ('||'''TABLE'''||','||'''DATABASE LINK'''||','||'''INDEX'''||','||'''TRIGGER'''||','||'''PACKAGE BODY'''||','||'''LOB'''||');');
                dbms_output.put_line('select '||'''spool off'''||' from dual;');
                dbms_output.put_line('spool off');
                dbms_output.put_line('@@drop_all_objects_of_selected_user_l2.sql');
        ELSE
--              dbms_output.put_line('This is Oracle-version 10. Note: Objects are dropped with purge-option!');
                dbms_output.put_line('set feedback off echo off show off ver off');
                dbms_output.put_line('set linesize 120 heading off termout off pagesize 2000 trimspool on');
                dbms_output.put_line('spool drop_all_objects_of_selected_user_l2.sql');
                dbms_output.put_line('select '||'''spool drop_all_objects_of_user_'''||'||'||'''&&user_to_clean'''||'||'||'''.log'''||' from dual;');
                dbms_output.put_line('select '||'''drop table "'''||'||'||'owner'||'||'||'''"."'''||'||'||'table_name'||'||'||'''" cascade constraints purge;'''||' from dba_tables where owner=upper('||'''&&user_to_clean'''||') AND owner not in ('||'''SYS'''||','||'''SYSTEM'''||');');
                dbms_output.put_line('select '||'''drop '''||'||'||'object_type'||'||'||''' "'''||'||'||'owner'||'||'||'''"."'''||'||'||'object_name'||'||'||'''";'''||' from dba_objects where owner=upper('||'''&&user_to_clean'''||') AND owner not in ('||'''SYS'''||','||'''SYSTEM'''||') AND object_type not in ('||'''TABLE'''||','||'''DATABASE LINK'''||','||'''INDEX'''||','||'''TRIGGER'''||','||'''PACKAGE BODY'''||','||'''LOB'''||');');
                dbms_output.put_line('select '||'''spool off'''||' from dual;');
                dbms_output.put_line('spool off');
                dbms_output.put_line('@@drop_all_objects_of_selected_user_l2.sql');
        END IF;
        EXCEPTION
        WHEN OTHERS THEN
                dbms_output.put_line(SQLERRM);
END;
/
spool off
@@drop_all_objects_of_selected_user_l1.sql
set termout on
set serveroutput on
declare
        cnt_user_objects number;
begin
dbms_output.enable;
select count(*) into cnt_user_objects from dba_objects where owner=upper('&&user_to_clean');
        IF cnt_user_objects > 0
           THEN
                dbms_output.put_line('Please restart this script again ! There are objects left in schema '||'&&user_to_clean'||' !');
           ELSE
                dbms_output.put_line('All objects of user '||'&&user_to_clean'||' were dropped !');
        END IF;
        EXCEPTION
        WHEN OTHERS THEN
                dbms_output.put_line(SQLERRM);
END;
/
!rm drop_all_objects_of_selected_user_l1.sql
!rm drop_all_objects_of_selected_user_l2.sql




##########################
                                                                                V1-V3)
backup_abc.log
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT > RMAN-06005: connected to target database: QMCRMDBP (DBID=1706730871)
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT > RMAN-06008: connected to recovery catalog database
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT > 2>
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT >
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT > 19>
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT >
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT > 20>
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT > 23>
2013-01-07 02:48:16 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 02:53:31 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 02:58:46 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:04:01 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:09:16 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:14:31 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:19:46 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:25:01 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:30:15 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:35:30 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:40:45 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:46:00 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-20029: cannot make a snapshot control file
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-00571: ===========================================================
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-00571: ===========================================================
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-03002: failure of configure command at 01/07/2013 03:46:21
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-03014: implicit resync of recovery catalog failed
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-03009: failure of full resync command on default channel at 01/07/2013 03:46:21
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > ORA-00230: operation disallowed: snapshot control file enqueue unavailable

#######################

Solution:

SQL> SELECT vs.sid, vs.username, vs.program, vs.module, TO_CHAR(vs.logon_time, 'DD-MON-YYYY HH24:MI:SS')
FROM v$session vs, v$enqueue_lock vel
WHERE vs.sid = vel.sid AND vel.type = 'CF' AND vel.id1 = 0 AND vel.id2 = 2
  2    3    4
SQL> /
          SID USERNAME                       PROGRAM              MODULE                         TO_CHAR(VS.LOGON_TIME,'DD-MON
---------- ------------------------------ -------------------- ------------------------------ -----------------------------
        24 SYS                            rman@s96qmcr0d0 (TNS backup full datafile           24-NOV-2012 06:27:36
                                           V1-V3)


SQL> select SID,SERIAL#,USERNAME,COMMAND,PROCESS,PROGRAM from v$session where sid=24;
 
       SID    SERIAL# USERNAME                COMMAND PROCESS                  PROGRAM              LOGON_TIM
---------- ---------- -------------------- ---------- ------------------------ -------------------- ---------
        24      10203 SYS                           0 29489                    rman@s96qmcr0d0 (TNS 24-NOV-12V1-V3)
       
       
SQL> alter system kill session '24,10203';
alter system kill session '24,10203'
*
ERROR at line 1:
ORA-00031: session marked for kill

      SID    SERIAL# USERNAME                          COMMAND PROCESS                  PROGRAM              STATUS
---------- ---------- ------------------------------ ---------- ------------------------ -------------------- --------
        24      10203 SYS                                     0 29489                    rman@s96qmcr0d0 (TNS KILLED

SELECT P.SPID, S.SID, S.SERIAL#
FROM V$PROCESS P, V$SESSION S
WHERE P.ADDR = S.PADDR
AND S.SID =24
-> Kill the process id from os level

-> Resync catalog;
-> Triger fresh backup.

RMAN error 00230 and 00230 to backup.

Issue:


##########################
                                                                                V1-V3)
backup_abc.log
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT > RMAN-06005: connected to target database: QMCRMDBP (DBID=1706730871)
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT > RMAN-06008: connected to recovery catalog database
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT > 2>
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT >
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT > 19>
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT >
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT > 20>
2013-01-07 02:43:19 +0100( 22310. 0) SESSION  OUT > 23>
2013-01-07 02:48:16 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 02:53:31 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 02:58:46 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:04:01 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:09:16 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:14:31 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:19:46 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:25:01 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:30:15 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:35:30 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:40:45 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:46:00 +0100( 22310. 0) SESSION  OUT > RMAN-08512: waiting for snapshot control file enqueue
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-20029: cannot make a snapshot control file
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-00571: ===========================================================
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-00571: ===========================================================
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-03002: failure of configure command at 01/07/2013 03:46:21
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-03014: implicit resync of recovery catalog failed
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > RMAN-03009: failure of full resync command on default channel at 01/07/2013 03:46:21
2013-01-07 03:46:21 +0100( 22310. 0) SESSION  OUT > ORA-00230: operation disallowed: snapshot control file enqueue unavailable

#######################

Solution:
SELECT vs.sid, vs.username, vs.program, vs.module, TO_CHAR(vs.logon_time, 'DD-MON-YYYY HH24:MI:SS') FROM v$session vs, v$enqueue_lock vel WHERE vs.sid = vel.sid AND vel.type = 'CF' AND vel.id1 = 0 AND vel.id2 = 2



          SID USERNAME                       PROGRAM              MODULE                         TO_CHAR(VS.LOGON_TIME,'DD-MON
---------- ------------------------------ -------------------- ------------------------------ -----------------------------
        24 SYS                            rman@s96qmcr0d0 (TNS backup full datafile           24-NOV-2012 06:27:36
                                           V1-V3)


select SID,SERIAL#,STATUS,USERNAME,COMMAND,PROCESS,PROGRAM from v$session where sid=121;
 
       SID    SERIAL# USERNAME                COMMAND PROCESS                  PROGRAM              LOGON_TIM
---------- ---------- -------------------- ---------- ------------------------ -------------------- ---------
        24      10203 SYS                           0 29489                    rman@s96qmcr0d0 (TNS 24-NOV-12V1-V3)
       
       
SQL> alter system kill session '24,10203';
alter system kill session '24,10203'
*
ERROR at line 1:
ORA-00031: session marked for kill

select SID,SERIAL#,STATUS,USERNAME,COMMAND,PROCESS,PROGRAM from v$session where sid=121;

      SID    SERIAL# USERNAME                          COMMAND PROCESS                  PROGRAM              STATUS
---------- ---------- ------------------------------ ---------- ------------------------ -------------------- --------
        24      10203 SYS                                     0 29489                    rman@s96qmcr0d0 (TNS KILLED

SELECT P.SPID, S.SID, S.SERIAL#
FROM V$PROCESS P, V$SESSION S
WHERE P.ADDR = S.PADDR
AND S.SID =24
-> Kill the process id from os level

-> Resync catalog;

-> Trigger fresh backup.

Thursday, April 10, 2014

Patching steps and details PSU

 Master link

http://www.oracleportal.org/

================



Very good link for oracle patching
===========================


What is Patch


http://www.oracleportal.org/knowledge-base/oracle-database/database-concepts/installation-and-patching/patching/patches.aspx



=================
OPATCH



http://www.oracleportal.org/knowledge-base/oracle-database/database-concepts/installation-and-patching/patching/opatch-utility.aspx


=================



Apply PSU Patch in Oracle
* You Must have two thing to apply PSU Patch :
1-Lastest version For Optach.
2-PSU Patch that you want to apply.


Steps:

$ORACLE_HOME/OPatch/opatch version
Output will be:
Invoking OPatch 11.2.0.1.7
OPatch Version:  11.2.0.1.7
OPatch succeeded

1-you need to Update latest version For Optach, to do this :

cd $ORACLE_HOME

cp -r Optach/ /u01/backup/Optach

**make sure you in ORACLE_HOME

rm -rf $ORACLE_HOME/Optach

unzip Optach_that_you_download_from_MOS inside $ORACLE_HOME.

Patch Number :6880880

2-Check Optach After Doing Above Steps :

$ORACLE_HOME/OPatch/opatch version
Output will be:
Invoking OPatch 11.2.0.3.0
OPatch Version:  11.2.0.3.0
OPatch succeeded

3-Apply PSU Patch By Doing the Following, for example :

unzip p13923374_11203_.zip
cd 13923374
opatch apply

Answer the question that you been asked by Oracle

4- Post Installation Steps :

cd $ORACLE_HOME/rdbms/admin
sqlplus /nolog
 SQL> CONNECT / AS SYSDBA
SQL> STARTUP
SQL> @catbundle.sql psu apply
SQL> QUIT


==============

                                                                     How to Apply Patch

========================================================================

This is the latest Patch Set Update for the 11.2.0.2.0 RDBMS Home.
The OPatch utility version should be higher than 11.2.0.1.3 to apply the patch.

How to check and update the opatch utility?

1-you need to Update latest version For Optach, to do this :

cd $ORACLE_HOME

cp -r Optach/ /u01/backup/Optach

**make sure you in ORACLE_HOME

rm -rf $ORACLE_HOME/Optach


unzip Optach_that_you_download_from_MOS  inside $ORACLE_HOME.

Patch Number :6880880



=================================
Go to support.oracle.com and download the 12827726 Patch Set Update
Transfer the file on to the remote server
[I copied it to the /oratemp01/11202 directory on the remote server] and unzip the file using
unzip p12827726_112020_Linux-x86-64.zip
Set the environment variables.
I am going demonstrate by applying the patch to the 11.2.0.2.0 RDBMS Home.
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db11202_s
export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/OPatch
========================
Determine whether any currently installed one-off patches conflict with the PSU patch as follows:
cd /oratemp01/11202/
[Note: This is the directory where I copied the psu zip file and unzipped]
================================
Run the following command

opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir ./12827726
=================================
Here is the output and you can notice that the pre-req checks succeed

Invoking OPatch 11.2.0.1.8
Oracle Interim Patch Installer version 11.2.0.1.8
Copyright (c) 2011, Oracle Corporation. All rights reserved.
PREREQ session
Oracle Home : /u01/app/oracle/product/11.2.0/db11202_s
Central Inventory : /u01/app/oracle/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.8
OUI version : 11.2.0.2.0
Log file location : /u01/app/oracle/product/11.2.0/db11202_s/cfgtoollogs/opatch/opatch2011-11-10_09-21-35AM.log
Invoking prereq "checkconflictagainstohwithdetail"
Prereq "checkConflictAgainstOHWithDetail" passed.
OPatch succeeded.
==================
If you are applying the patch to the RDBMS_HOME;
shutdown all the databases associated with that RDBMS_HOME.
Apply the patch by issuing the following command.
You may be asked for your metalink credentials.
====================
cd 12827726
opatch apply


================================

[oracle@xyz 12827726]$ opatch apply
Invoking OPatch 11.2.0.1.8

Oracle Interim Patch Installer version 11.2.0.1.8
Copyright (c) 2011, Oracle Corporation. All rights reserved.

Oracle Home : /u01/app/oracle/product/11.2.0/db11202_s
Central Inventory : /u01/app/oracle/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.8
OUI version : 11.2.0.2.0
Log file location : /u01/app/oracle/product/11.2.0/db11202_s/cfgtoollogs/opatch/opatch2011-11-10_09-21-45AM.log

Applying interim patch '12827726' to OH '/u01/app/oracle/product/11.2.0/db11202_s'
Verifying environment and performing prerequisite checks...

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 My
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/db11202_s')
Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Patching component oracle.rdbms.rsf, 11.2.0.2.0...
Patching component oracle.rdbms, 11.2.0.2.0...
Copying file to "/u01/app/oracle/product/11.2.0/db11202_s/psu/11.2.0.2.4/catpsu.sql"
Copying file to "/u01/app/oracle/product/11.2.0/db11202_s/psu/11.2.0.2.4/catpsu_rollback.sql"
Copying file to "/u01/app/oracle/product/11.2.0/db11202_s/cpu/scripts/patch_8837510.sql"
Copying file to "/u01/app/oracle/product/11.2.0/db11202_s/cpu/scripts/emdb_recomp_invalids.sql"
Patching component oracle.sysman.console.db, 11.2.0.2.0...
Patching component oracle.sysman.oms.core, 10.2.0.4.3...
Patching component oracle.ldap.rsf, 11.2.0.2.0...
Patching component oracle.rdbms.dv, 11.2.0.2.0...
Patching component oracle.rdbms.dbscripts, 11.2.0.2.0...
Patching component oracle.sysman.plugin.db.main.repository, 11.2.0.2.0...
Patching component oracle.rdbms.rman, 11.2.0.2.0...
Patching component oracle.sdo.locator, 11.2.0.2.0...
patch 12827726 successfully applied
Log file location: /u01/app/oracle/product/11.2.0/db11202_s/cfgtoollogs/opatch/opatch2011-11-10_09-21-45AM.log
OPatch succeeded.
=====================================
STARTUP the databases with the newly patched RDBMS_HOME,
set ORACLE_SID variable and load modified sql files into the database.
Perform these steps
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.2/db11202_r
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
cd $ORACLE_HOME/rdbms/admin
sqlplus / as sysdba
At the sql prompt enter the following commands:
@?/rdbms/admin/catbundle.sql psu apply
QUIT

=======================================


Wednesday, December 19, 2012

OS ws


        ===================================
        WorkSheets - Operating System
        ===================================
http://www.athirathram.org/home.html
Linux Commands -http://www.pixelbeat.org/cmdline.html

Grepping multiple processes  - ps -ef | egrep -i "|"
spliting a file in to several  - split -b 1024m
parts of 1 GB filesize each.

Presentation Pictures   - http://www.istockphoto.com/file_search.php?action=file&lightboxID=664079
Report format-
 ###begin_report###
 
 ###end_report###

"DB - 8*5 check"
To direct an output to screen as well as file - ./102_relocate_containers.sh  | tee 102_relocate_containers.log
pk7xap01@s96ss0d14:/home/pk7xap01 : while true
> do
> db2 list utilities show detail
> sleep 60
> done
------------------------------------------------
CISM database checking procedure -
Server    - s96ars10-v2
Database  - arsprd
PORT    - 1522
Check Listener  - ps -ef | grep -i inherit
TNS Checking - tnsping arsprd
OS user   - ora_arsprd
------------------------------------------------

Laste successful TSM backup- `db2adutl query full db $LOGNAME|grep '1 Time:'|awk '{print $3}'|head -1`
To find the TSM using - dsmc q sess

Operating System
================
 Creating log file for a .sh script:
 -----------------------------------
 .sh | tee -a .log
 Send a message (Banner) for all users:
 --------------------------------------
 wall + + + + CTRL-D

 Create a link
 =============
  Soft link -
   ln -s
   Example:

    ln -s /epeople/onredom/hrepgll9 hrepprd9
   Removal of link-
    rm hrepprd9

 Process tree structure
 ======================
  SUN - pstree
  AIX - proctree

 List system error message
 =========================
  SUN - errpt

 No of processors
 ================
  AIX - lsdev -Cc processor | wc -l
  SUN - prtdiag -v
 Bit version
 ===========

  Sun  - isainfo -kv
  AIX  - bootinfo -K
  HP   - getconf KERNEL_BITS
  Linux - getconf LONG_BIT

 Memory tracking
 ===============

  Linux:
  ------
  Linux stores memory related information in a file called /proc/meminfo.
  You can list the meminfo file to see the current state of system memory.

   cat /proc/meminfo

  The Linux free command extracts and formats pertinent
  information from the meminfo file and displays it as follows:

   free -k or free -m

  To check memory size in Linux using dmesg, run the following command:

   dmesg |grep -i memory (Running dmesg command in Linux displays memory in kilobytes)


  Linux also comes with top command, top can be run to check real memory size  and
  memory utilization.Top display total memory size,used memory,free memory ,memory
  buffers size and swap memory utilization :

   top


  Solaris:
  --------
  To display the amount of RAM:
   top
   /usr/sbin/prtconf | grep Memory

   vmstat


  HP-UX:
  ------
   vmstat

   swapinfo -tm (HP-Ux swap space monitor)

  AIX:
  ----

   nmon

   lsps -s (AIX paging monitor)

   prtconf | grep -i mem

 How to check system error messages
 ==================================
  Sun - cat /var/adm/messages (Optionally tail /var/adm/messages)
  AIX - errpt

 Create and maintain screen
 ==========================
 Create screen  - screen -S
        Eg: screen -S TT11320203_Ora_task
 Attach to screen - screen -r  
      Eg: screen -r TT11320203_Ora_task
 Detach from screen - CTRL+A and release hand then press D

 Database list in EDC
 ====================

  read db_name;cat /sysadm/utils/ora_util.sid..| grep -i $db_name
  read db_name;cat ora_util.sid..| grep -i $db_name
  cat /sysadm/utils/ora_util.sid..| grep -i

 Find
 ====

  To find the pattern and print the line + the line above
  -------------------------------------------------------

  awk '{if ($2=="ALTER") {print ab,"\n",$0} {ab=$0}}'
  To find the pattern in a file
  -----------------------------
  awk '{print $1}' imp_ttu2_METADATA_ONLY_19022010.log|grep -i ORA-|head
  awk '{print $1}' imp_ttu2_METADATA_ONLY_19022010.log|grep -i ORA-|sort -u

 Loop to monitor
 ===============

  while :;do ls -l | wc -l;sleep 60;done   # use CTRL+C for exit from loop
  while : ; do ls -l *.Z | wc -l ; sleep 60 ; done

  Loop to monitor a FS
  --------------------
   cat > fschk.sh
   clear; echo 'Please enter FS: '; read fs; clear; echo 'Please enter freequency (in seconds): '; read freeq; while : ; do clear; df -h $fs ; sleep $freeq; clear ; done
   chmod 755 fschk.sh
   alias watch=./fschk.sh
  Ex:
   while : ; do clear ; echo "Fleetboard Restoration Progress (in last 30 mins)" ; ./fleetboard_db_restore_status.sh|grep "Completed Work"; sleep 1800 ; clear ; done

  To make the desired date format
  -------------------------------
  Date format: $(date +"%d%m%Y")    - ddmmyy
  Date format: $(date +"%d-%m-%Y %H:%M:%S")  - dd-mm-yyyy hh24:mi:ss


 File management
 ===============

  Replacement command
  -------------------
   Press SHIFT+: then type 1,$s/10.2.0/10.2.0.4/g -- Here 10.2.0 is the string to be replaced with 10.2.0.4
  Checking difference in 2 files
  ------------------------------
   diff

   Example:
   --------
   vkvxap01@s96gbs01:/home/vkvxap01 : ls -ltr backup_dbm_cfg_270309.txt
   -rw-r--r--   1 vkvxap01 vkvxap01       5220 Mar 27 05:05 backup_dbm_cfg_270309.txt
   vkvxap01@s96gbs01:/home/vkvxap01 : db2 get dbm cfg > dbm_cfg_updated_270309.txt
   vkvxap01@s96gbs01:/home/vkvxap01 : ls -ltr dbm_cfg_updated_270309.txt
   -rw-r--r--   1 vkvxap01 vkvxap01       5220 Mar 27 05:37 dbm_cfg_updated_270309.txt
   vkvxap01@s96gbs01:/home/vkvxap01 :
   vkvxap01@s96gbs01:/home/vkvxap01 :
   vkvxap01@s96gbs01:/home/vkvxap01 : diff backup_dbm_cfg_270309.txt dbm_cfg_updated_270309.txt
   8c8
   <  CPU speed (millisec/instruction)             (CPUSPEED) = 5.038339e-07
   ---
   >  CPU speed (millisec/instruction)             (CPUSPEED) = 5.668131e-07
   vkvxap01@s96gbs01:/home/vkvxap01 :
      

  Delete audit files
  ------------------
   find -name '*.aud' -exec rm {} \;

  Pack/ Compress
  --------------
   gzip -9
   nohup gzip -c > &
   compress

   Example:
    gzip -9 < /log/oracle/network/listener.log > /log/oracle/network/listener.log.gz
    compress < /log/oracle/network/listener.log > /log/oracle/network/listener.log.Z

  Pack/ Compress perticular files
  -------------------------------
   cd
   FILES="`ls`"
   tar -cvf .tar $FILES
   gzip --best .tar
   rm $FILES

   Example:
    cd /db2/backup_zujxap03/
    FILES="`echo ls *.trc`"
    tar -cvf db_oft1_trcs_301109.tar $FILES
    gzip --best db_oft1_trcs_301109.tar
    rm $FILES
   New Methode:


echo '';echo 'listing files to be archived:';echo '';FILES="`ls *.Z *.1`";echo $FILES;echo '';echo 'compressing..';echo '';tar -cvf logs_$(date +"%d%m%Y").tar $FILES;gzip -9 logs*.tar;echo '';echo 'files compressed as -';echo '';ls -ltr logs*tar*.gz
dsmc arch  "logs*tar*.gz"
dsmc q arch  "logs*tar*.gz"
rm $FILES

  Truncate  file
  --------------
   cat '' >
   Eg: cat '' > /log/oracle/network/listener.log

   Note:
    While handlying with listener, do not  remove this file as the listener  keeps a
    filehandle to this file.  In case , if  we accidently removed listener.log,  The
    only solution to this problem is restarting the listener. If one knows that  the
    database is at that moment not under heavy connect/disconnect-load, then restart
    online. su - -c "lsnrctl stop; lsnrctl start"
    Now the disc-space should have been freed! 


  File system HWM
  ---------------

   df -g
   read fs;df -h fs
   read dir_name;cat /sysadm/utils/ora_fsmon.`hostname`.par | grep -i $dir_name
   cat /sysadm/utils/ora_fsmon.`hostname`.par | grep -i
   cat  /sysadm/utils/ora_fsmon.`hostname`.par
   

  Finding a word in all files under a FS
  --------------------------------------
   grep $(find .)
    Ex: grep DATABASE_PASSWORD $(find .)

  Finding file sizes in unix mountpoints
  --------------------------------------

   find -xdev -type f -size +10000000c -exec du -sk {} \;|sort -nr|more

  Easly copy file from local desktop to PUTTY
  -------------------------------------------
  Copy from file (Press CTRL+A and CTRL+C )

  in PUTTY -
   cat >
   Right click the mouse
   Press CTRL+D 


  Split file into equal size
  --------------------------
  split -b m
  Once split complete, rename the files



  Eg:
   split -b 1945m VL6XAQ01.0.vl6xaq01.NODE0000.CATN0000.20101019132228.001.gz -- spliting file into 1.9G approx

   root@s96ivk2d1:/mig12 : ls -ltr
   total 66228304
   drwxrwxrwx    2 root     system         4096 Sep 23 14:48 .snapshot
   -rw-r-----    1 vl6xaq01 vl6xaq01 16921180833 Oct 19 14:40 VL6XAQ01.0.vl6xaq01.NODE0000.CATN0000.20101019132228.001.gz
   -rw-------    1 vl6xaq01 vl6xaq01          0 Oct 19 15:00 nohup.out
   -rw-r--r--    1 root     system   2039480320 Oct 19 20:03 xaa
   -rw-r--r--    1 root     system   2039480320 Oct 19 20:05 xab
   -rw-r--r--    1 root     system   2039480320 Oct 19 20:06 xac
   -rw-r--r--    1 root     system   2039480320 Oct 19 20:08 xad
   -rw-r--r--    1 root     system   2039480320 Oct 19 20:09 xae
   -rw-r--r--    1 root     system   2039480320 Oct 19 20:11 xaf
   -rw-r--r--    1 root     system   2039480320 Oct 19 20:13 xag
   -rw-r--r--    1 root     system   2039480320 Oct 19 20:14 xah
   -rw-r--r--    1 root     system    605338273 Oct 19 20:15 xai
   root@s96ivk2d1:/mig12 :
   root@s96ivk2d1:/mig12 :
   root@s96ivk2d1:/mig12 : mv xaa VL6XAQ01.0.vl6xaq01.NODE0000.CATN0000.20101019132228.001_01
   root@s96ivk2d1:/mig12 : mv xab VL6XAQ01.0.vl6xaq01.NODE0000.CATN0000.20101019132228.001_02
   root@s96ivk2d1:/mig12 : mv xac VL6XAQ01.0.vl6xaq01.NODE0000.CATN0000.20101019132228.001_03
   root@s96ivk2d1:/mig12 : mv xad VL6XAQ01.0.vl6xaq01.NODE0000.CATN0000.20101019132228.001_04
   root@s96ivk2d1:/mig12 : mv xae VL6XAQ01.0.vl6xaq01.NODE0000.CATN0000.20101019132228.001_05
   root@s96ivk2d1:/mig12 : mv xaf VL6XAQ01.0.vl6xaq01.NODE0000.CATN0000.20101019132228.001_06
   root@s96ivk2d1:/mig12 : mv xag VL6XAQ01.0.vl6xaq01.NODE0000.CATN0000.20101019132228.001_07
   root@s96ivk2d1:/mig12 : mv xah VL6XAQ01.0.vl6xaq01.NODE0000.CATN0000.20101019132228.001_08
   root@s96ivk2d1:/mig12 : mv xai VL6XAQ01.0.vl6xaq01.NODE0000.CATN0000.20101019132228.001_09

 To find pool serevr
 ===================

  tail -100 /sysadm/utils/ora_omnib.log | grep -i dyn


 To check the total backup for a server
 ======================================
  root@:/sysadm/utils : ora_omnib -l -N | head

 TSM Commands
 ============
  Archieve to TSM  -  dsmc arch
      Eg : dsmc arch ZU8XAP01.0.zu8xap01.NODE0000.CATN0000.20081026194320.001
  
  Query TSM   -  dsmc q arch
      Eg : dsmc q arch ZU8XAP01.0.zu8xap01.NODE0000.CATN0000.20081026194320.001


  If those commands not working -


  Archieve to TSM  -  dsmc back
      Eg: dsmc back  listener.log.01042009.Z


  Query TSM   - dsmc q back
      Eg: dsmc q back  listener.log.01042009.Z

  Archive multiple files  -  dsmc archive "*"
      Eg: dsmc archive "nncc*"

  Query TSM   -  dsmc q archive "*"
      Eg: dsmc q archive "nncc*" 

  dsmc ret  "*S006297*"  -subdir=yes /db2/tmp_logs/

  Archive files under a directory
  -------------------------------
  dsmc arch -subdir=yes "/oracle/data1/exports/TT9416776/*" -desc=TT0011119940

  dsmc q arch "/oracle/data1/exports/TT9416776/*" -desc=TT0011119940

 RMAN backup schedule monitoring
 ===============================
  As root - ps -ef | grep dsm

    Eg:
     root@s96hrd11:/root : ps -ef | grep dsm
         root 1269888       1   0   Jun 24      -  0:02 /usr/bin/dsmcad -optfile=/usr/bin/dsm_s96hrd11_leadsnt.opt
         root 1274016       1   0   Jun 24      -  0:02 /usr/bin/dsmcad -optfile=/usr/bin/dsm_s96hrd11_leadt.opt
         root 1286228       1   0   Jun 24      -  0:02 /usr/bin/dsmcad -optfile=/usr/bin/dsm_s96hrd11_omr1.opt
         root 1310858       1   0   Jun 24      -  0:02 /usr/bin/dsmcad -optfile=/usr/bin/dsm_s96hrd11_epwtint.opt
         root 1327244       1   0   Jun 24      -  0:02 /usr/bin/dsmcad -optfile=/usr/bin/dsm_s96hrd11_hrapp03i.opt
         root 1331340       1   0   Jun 24      -  0:02 /usr/bin/dsmcad -optfile=/usr/bin/dsm_s96hrd11_hrapp01t.opt
         root 1335438       1   0   Jun 24      -  0:02 /usr/bin/dsmcad -optfile=/usr/bin/dsm_s96hrd11_hrapp01i.opt
         root 9347194 9789580  38 03:18:50      -  0:47 /opt/tivoli/tsm/client/ba/bin/dsmc incremental -subdir=yes / /epeople/cntrl1/ /epeople/cntrl2/ /epeople/cntrl3/ /epeople/databases/ /epeople/log/ /epeople/offredo/ /epeople/onredom/ /epeople/onredop/ /epeople/sort/ /glockware/ /home/ /opt/ /oracle/ /root/ /sysmgmt/ /tmp/ /usr/ /var/
         root 9482396 9797792   0 03:29:34  pts/1  0:00 grep dsm



    dsmc q sched <-optfile>

    Eg:
     root@s96hrd11:/root : dsmc q sched -optfile=/usr/bin/dsm_s96hrd11_epwtint.opt
     IBM Tivoli Storage Manager
     Command Line Backup/Archive Client Interface
       Client Version 5, Release 3, Level 4.0
       Client date/time: 06/27/09   03:29:45
     (c) Copyright by IBM Corporation and other(s) 1990, 2006. All Rights Reserved.

     Node Name: S96HRD11_EPWTINT
     Session established with server S96TSM02: AIX-RS/6000
       Server Version 5, Release 5, Level 1.1
       Server date/time: 06/27/09   03:29:45  Last access: 06/27/09   03:29:01

         Schedule Name: ONLINE_EPWTINT
           Description: schedules RMAN Onlinebackup
        Schedule Style: Enhanced
                Action: Command
               Options:
               Objects: /usr/bin/su - ora9i -c "export ORACLE_SID=epwtint;/usr/tivoli/tsm/client/oracle/scripts/oracle_tdpo.ksh -l full -s BUOn -r 1 -o 30"
              Priority: 5
        Next Execution: 1 Minute
              Duration: 1 Hour
                Period:
           Day of Week: Tuesday, Saturday
                 Month: Any
          Day of Month: Any
         Week of Month: Any
                Expire: Never

    ps -ef | grep /usr/tivoli/tsm/client/oracle/scripts/oracle_tdpo.ksh

    Eg:
     root@s96hrd11:/root : ps -ef | grep /usr/tivoli/tsm/client/oracle/scripts/oracle_tdpo.ksh
        ora9i 9212104 9367796   0 03:30:06      -  0:00 /usr/bin/ksh /usr/tivoli/tsm/client/oracle/scripts/oracle_tdpo.ksh -l full -s BUOn -r 1 -o 30
         root 9416958 9797792   1 03:30:49  pts/1  0:00 grep /usr/tivoli/tsm/client/oracle/scripts/oracle_tdpo.ksh
       ora10g 9842854 8982722   0 03:29:07      -  0:00 /usr/bin/ksh /usr/tivoli/tsm/client/oracle/scripts/oracle_tdpo.ksh -l full -s ArchRedo -r 1
     root@s96hrd11:/root : ps -ef | grep /usr/tivoli/tsm/client/oracle/scripts/oracle_tdpo.ksh
        ora9i 9212104 9367796   0 03:30:06      -  0:00 /usr/bin/ksh /usr/tivoli/tsm/client/oracle/scripts/oracle_tdpo.ksh -l full -s BUOn -r 1 -o 30
         root 9670860 9797792   0 03:35:53  pts/1  0:00 grep /usr/tivoli/tsm/client/oracle/scripts/oracle_tdpo.ksh
     root@s96hrd11:/root :


  Check the log file-

    cd /opt/tivoli/tsm/client/oracle/logs

    ls -ltr | grep epwtint | grep dbback | tail

    Eg:
     root@s96hrd11:/opt/tivoli/tsm/client/oracle/logs : ls -ltr | grep epwtint | grep dbback | tail
     -rw-r--r--    1 ora9i    dba           19131 May 30 11:23 rman_out.30.05.09-03:30:06.dbbackup.epwtint.5562582
     -rw-r--r--    1 ora9i    dba           19131 Jun 02 17:09 rman_out.02.06.09-03:30:11.dbbackup.epwtint.4710402
     -rw-r--r--    1 ora9i    dba           19131 Jun 06 11:13 rman_out.06.06.09-03:30:09.dbbackup.epwtint.7864520
     -rw-r--r--    1 ora9i    dba           19131 Jun 09 17:33 rman_out.09.06.09-03:30:16.dbbackup.epwtint.8315070
     -rw-r--r--    1 ora9i    dba           19131 Jun 13 11:27 rman_out.13.06.09-03:30:04.dbbackup.epwtint.8839226
     -rw-r--r--    1 ora9i    dba            6093 Jun 16 03:30 rman_out.16.06.09-03:30:10.dbbackup.epwtint.8265896
     -rw-r--r--    1 root     system          489 Jun 16 19:57 rman_out.16.06.09-15:06:52.dbbackup.epwtint.8212650
     -rw-r--r--    1 ora9i    dba            6111 Jun 17 16:13 rman_out.17.06.09-15:36:31.dbbackup.epwtint.9240606
     -rw-r--r--    1 ora9i    dba           19131 Jun 23 19:36 rman_out.23.06.09-08:00:14.dbbackup.epwtint.4481260
     -rw-r--r--    1 ora9i    dba            5456 Jun 27 03:30 rman_out.27.06.09-03:30:06.dbbackup.epwtint.9212104
    tail -f

    Eg:
     root@s96hrd11:/opt/tivoli/tsm/client/oracle/logs : :30:06.dbbackup.epwtint.9212104                        <
     RMAN-08522: input datafile fno=00079 name=/epeople/databases/epwtint/dbf/pclarge01.dbf
     RMAN-08522: input datafile fno=00103 name=/epeople/databases/epwtint/dbf/pswork01.dbf
     RMAN-08522: input datafile fno=00126 name=/epeople/databases/epwtint/dbf/tllarge01.dbf
     RMAN-08522: input datafile fno=00045 name=/epeople/databases/epwtint/dbf/eotpapp01.dbf
     RMAN-08522: input datafile fno=00025 name=/epeople/databases/epwtint/dbf/eocmwrk01.dbf
     RMAN-08522: input datafile fno=00029 name=/epeople/databases/epwtint/dbf/eodslrg01.dbf
     RMAN-08522: input datafile fno=00034 name=/epeople/databases/epwtint/dbf/eoeilrg01.dbf
     RMAN-08522: input datafile fno=00039 name=/epeople/databases/epwtint/dbf/eoiulrg01.dbf
     RMAN-08522: input datafile fno=00052 name=/epeople/databases/epwtint/dbf/glapp01.dbf
     RMAN-08038: channel epwtint_t1: starting piece 1 at 27-jun-2009_03:30:13
   

 Copy directory
 ==============
  cp -r
  tar cf - ./ | ( cd ; tar xf - )

  Example:
   tar cf - ./V9.1 | ( cd /mif/DB/mifarchive/AbsBackup/20090325to20190325/DB2/s96mif0c0 ; tar xf - )


 Compress directory
 ==================

  tar -cvf .tar   
  Example: tar -cvf pk6xap01_db2move.tar db2move

xxx -------------------------------------------------------------------- xxx -------------------------------------------------------------------- xxx

Linux Shell Scripting Excercises
================================

Sites:  http://www.freeos.com/guides/lsst/
 http://linuxgazette.net/133/cherian.html
Eg :1
-----
 hostname>name.log ; vserver=`cat name.log` ; echo $vserver ; rm name.log
Eg :2
-----
 ora1023@s96dbt01:/home/ora1023 : cat test.sh
 echo "Enter character:"
 read vchr
 if [ "$vchr" = "" ]
 then
    echo 'Invalid!'
 else
    echo $vchr
 fi

Eg :3
-----
 uname > OSname.log
 vos=`cat OSname.log`
 rm OSname.log
 echo 'File removed sucessfully!'
 if [ "$vos" = "SunOS" ]
 then
  echo 'Sun Operating System'
 else
  echo 'Not a Sun Operating System'
 fi

xxx -------------------------------------------------------------------- xxx -------------------------------------------------------------------- xxx

root@s96iuk0d0:/oracle/log/iukp/cdump : cp -rf /oracle/log/iukp/cdump/core_* /root/core
root@s96iuk0d0:/oracle/log/iukp/cdump : cd /root/core
root@s96iuk0d0:/root/core : ls -l
total 18
drwxr-x---   2 root     root         512 Feb  3 23:20 core_10403
drwxr-x---   2 root     root         512 Feb  3 23:20 core_1093
drwxr-x---   2 root     root         512 Feb  3 23:20 core_1103
drwxr-x---   2 root     root         512 Feb  3 23:20 core_11675
drwxr-x---   2 root     root         512 Feb  3 23:20 core_22041
drwxr-x---   2 root     root         512 Feb  3 23:20 core_23177
drwxr-x---   2 root     root         512 Feb  3 23:20 core_27323
drwxr-x---   2 root     root         512 Feb  3 23:21 core_28608
drwxr-x---   2 root     root         512 Feb  3 23:21 core_4117
root@s96iuk0d0:/root/core :
root@s96iuk0d0:/root : tar -cvf /root/core.tar /root/core
a /root/core/ 0K
a /root/core/core_10403/ 0K
a /root/core/core_10403/core 151478K
a /root/core/core_1093/ 0K
a /root/core/core_1093/core 28160K
a /root/core/core_1103/ 0K
a /root/core/core_1103/core 5784K
a /root/core/core_11675/ 0K
a /root/core/core_22041/ 0K
a /root/core/core_22041/core 135477K
a /root/core/core_23177/ 0K
a /root/core/core_23177/core 0K
a /root/core/core_27323/ 0K
a /root/core/core_27323/core 149837K
a /root/core/core_28608/ 0K
a /root/core/core_4117/ 0K
a /root/core/core_4117/core 138990K
root@s96iuk0d0:/root :
root@s96iuk0d0:/root :

root@s96iuk0d0:/oracle/log/iukp/cdump : mv /root/core.tar.gz .
root@s96iuk0d0:/oracle/log/iukp/cdump : bdf .
Filesystem            kbytes    used   avail capacity  Mounted on
/oracle/log           985951  595769  331025    65%    /oracle/log
root@s96iuk0d0:/oracle/log/iukp/cdump :

Script to be checked -
cat /tmp/awk.scr
awk '/ORA-1109/{print x};{x=$0}' /dblogs/oft1/bdump/alert_oft1.log.1
awk '/ORA-1109/{print}' /dblogs/oft1/bdump/alert_oft1.log.1
awk '/ORA-1109/{getline;print}' /dblogs/oft1/bdump/alert_oft1.log.1