How to Set Up ORMB Batch Scheduling with Oracle DBMS Scheduler

Oracle DBMS Scheduler is the easiest and cost saving way for ORMB Batch Scheduling.

Download and Apply Oracle DBMS Scheduler Patch

The Patch id is 23639775, which can be downloaded from Oracle support.
This patch is supposed to be installed on to ORMB application server. But we zip it and ship onto a Windows server for installation.

$ unzip Oracle_Scheduler_Integration.zip
Archive: Oracle_Scheduler_Integration.zip
 inflating: Getting Started Guide ORMB Batch Scheduling.pdf
 inflating: ORACLE_DBMS_SCHEDULER_SETUP_LINUX.pdf
 inflating: ORMB_Integration_Installer/lastDayPrevMonthJobs.properties
 inflating: ORMB_Integration_Installer/readme.txt
 inflating: ORMB_Integration_Installer/setup.sh
 inflating: ORMB_Integration_Installer/sql/oem_ouaf_package.sql
 inflating: ORMB_Integration_Installer/sql/ouaf_batch_package.sql
 inflating: ORMB_Integration_Installer/sql/setup.sql
 inflating: ORMB_Integration_Installer/sql/user_cisadm_setup.sql
 inflating: ORMB_Integration_Installer/sql/user_schadm_NEW_I.sql
 inflating: ORMB_Integration_Installer/sql/user_schadm_NEW_S.sql
 inflating: ORMB_Integration_Installer/sql/user_schadm_setup_NEW.sql
 inflating: ORMB_Integration_Installer/sql/user_schadm_setup_OEM_N.sql
 inflating: ORMB_Integration_Installer/sql/user_schadm_setup_OEM_Y.sql
 inflating: ORMB_Integration_Installer/sql/user_schadm_setup_UPD.sql
 extracting: ORMB_Integration_Installer/sql/user_schadm_UPD_I.sql
 extracting: ORMB_Integration_Installer/sql/user_schadm_UPD_S.sql

$ cd ORMB_Integration_Installer
oracle@racnode1:/tmp/ORMB_Integration_Installer$ chmod 777 setup.sh
oracle@racnode1:/tmp/ORMB_Integration_Installer$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Thu Mar 16 10:23:42 2017

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options

SQL> alter session set container=ormbpdb;

Session altered.

SQL> show user
USER is "SYS"
SQL> @?/rdbms/admin/userlock.sql;

Package dropped.
Package created.
Package body created.
Synonym created.
Grant succeeded.
SQL> grant execute,debug on user_lock to cisadm;
Grant succeeded.

oracle@racnode1:/tmp/ORMB_Integration_Installer$ ls -ltr
total 16
-rwxrwxrwx 1 oracle oinstall 417 Mar 14 16:10 setup.sh
-rw-r--r-- 1 oracle oinstall 3485 Mar 14 16:10 readme.txt
-rw-r--r-- 1 oracle oinstall 112 Mar 14 16:10 lastDayPrevMonthJobs.properties
drwxr-xr-x 2 oracle oinstall 4096 Mar 16 10:20 sql

oracle@racnode1:/tmp/ORMB_Integration_Installer$ ./setup.sh

OUAF DBMS Scheduler Setup (4.2.x, 4.3.x)
========================================

NOTES:
1. Package USER_LOCK must be installed before running this script.
That can typically be done by executing @?/rdbms/admin/userlock.sql
2. The schema owner (e.g. CISADM) must have "create user" permission.

Hit enter to start
Enter database service (SID) name: ORMB
Enter schema owner [CISADM]: cisadm
Enter password for user cisadm: xxxxxx
Connecting to cisadm@ORMB ...
Validating user cisadm
Checking USER_LOCK package
Enter scheduler user name [SCHADM]: schadm
User SCHADM does not exist and will be created
Enter password for user SCHADM:
Confirm password for user SCHADM: xxxxxx
Enter default tablespace [CISTS_01]: CISADM
Enter temp tablespace [TEMP]:
Creating user SCHADM
Connecting to SCHADM@ORMB ...

The email server, recipient and sender addresses are required for email
notifications when threads end in error and the thread_notifications
option is in effect. These values can be set here or the defaults
can be accepted and then modified by connecting to user SCHADM and:
a) running statement "DBMS_SCHEDULER.set_scheduler_attribute(...)" to
change the email server and
b) editing scheduler job OUAF_NOTIFY and changing its email notification
settings.

Enter email server name [mailserver.company.com]: smtp.wordpress.com
Enter email recipient address [foo.bar@company.com]: infor@dbalifeeasy.com
Enter email sender address [do-not-reply@company.com]: schadm@dbalifeeasy.com
Use OEM_NOTIFY for thread errors (Y/N)? [N]: Y
Job OEM_NOTIFY will be used for thread error notifications

OUAF DBMS Scheduler setup completed

Schedule Jobs With Scheduler Using Sql Developer

We will follow the following steps to achieve this :

Subscribe to get access

Read more of this content when you subscribe today.

How to Kill Oracle RAC Sessions

Kill a session on any RAC instance:
SQL>alter system kill session ‘SID, SERIAL#,@INST_ID’ immediate;

We know the syntax for killing a session is :

SQL>alter system kill session 'SID, SERIAL#' immediate;

In RAC environment, the syntax will be :

SQL>alter system kill session 'SID, SERIAL#,@INST_ID' immediate;

Kill all the sessions from username ‘TESTUSER’:

SQL> select 'alter system kill session '||''''||sid||','||serial#||','
            ||'@'||INST_ID||''''||' immediate;' 
     from gv$session 
    where USERNAME='TESTUSER' order by INST_ID;

'ALTERSYSTEMKILLSESSION'||''''||SID||','||SERIAL#||','||'@'||INST_ID||''''||'IMMEDIATE;'
--------------------------------------------------------------------------
alter system kill session '3839,1429,@1' immediate;
alter system kill session '3269,62522,@1' immediate;
alter system kill session '2135,2483,@1' immediate;
alter system kill session '1994,10353,@1' immediate;
alter system kill session '1144,30683,@1' immediate;
alter system kill session '1003,59576,@1' immediate;
alter system kill session '4,33789,@1' immediate;
alter system kill session '4268,11193,@1' immediate;
alter system kill session '2846,21471,@2' immediate;
alter system kill session '2987,43213,@2' immediate;
alter system kill session '3983,62058,@2' immediate;
alter system kill session '4122,56820,@2' immediate;
alter system kill session '4125,54104,@2' immediate;
alter system kill session '4263,55362,@2' immediate;
alter system kill session '4268,43052,@2' immediate;
alter system kill session '2704,41337,@2' immediate;
alter system kill session '2564,24435,@3' immediate;
alter system kill session '1851,17069,@3' immediate;
alter system kill session '857,25207,@3' immediate;
alter system kill session '4408,37890,@3' immediate;
alter system kill session '576,38233,@4' immediate;
alter system kill session '432,5600,@4' immediate;
alter system kill session '6,29398,@4' immediate;
alter system kill session '719,42236,@4' immediate;

24 rows selected.

Check sessions are killed :

SQL> select username, machine,count(*) 
       from gv$session 
      where USERNAME = 'TESTUSER' 
   group by username, machine;

no rows selected

TNS-12508: TNS:listener could not resolve the COMMAND given

Setting “ADMIN_RESTRICTIONS_listener_name=on” disables the runtime
modification of parameters in listener.ora.

Got error message “TNS-12508: TNS:listener could not resolve the COMMAND given” when trying to switch off listener log.

LSNRCTL> set log_status off
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=racnode1)(PORT=1521)))
TNS-12508: TNS:listener could not resolve the COMMAND given
LSNRCTL>

Subscribe to get access

Read more of this content when you subscribe today.

ORA-28002 : the password will expire within 3 days

User password can be restored back to its original one by using password hash value.

The password is unknown, and it is encrypted in application configurations. User doesn’t want to change it at the moment.

$ oerr ora 28002
28002, 00000, "the password will expire within %s days"
// *Cause: The user's account is about to expire and the password
// needs to be changed
// *Action: change the password or contact the DBA
//

SQL> select USERNAME,PASSWORD,ACCOUNT_STATUS,EXPIRY_DATE 
       from dba_users 
      where username='TESTUSER';

USERNAME         PASSWORD             ACCOUNT_STATUS    EXPIRY_DATE
---------------- -------------------- ----------------  ---------
TESTUSER                              EXPIRED(GRACE)    18-MAR-17

Get hash password value from USER$.

SQL> select password from user$ where name='TESTUSER';

PASSWORD
--------------------
512795B1F6AC27B8

Reset the password with the original one:

SQL> alter user testuser identified by values '512795B1F6AC27B8';

User altered.
SQL> select USERNAME,ACCOUNT_STATUS,EXPIRY_DATE 
       from dba_users 
      where USERNAME='TESTUSER';

USERNAME       ACCOUNT_STATUS    EXPIRY_DATE
-------------- ---------------   -----------
TESTUSER       OPEN              14-MAY-17

“SELECT MEDIA FROM V$BACKUP_PIECE_DETAILS” Takes Long Time and Uses Huge Temp Space

It is a good practice for DBA to periodically collect stats of fixed objects, data dictionary, SYS and SYSTEM schemas,

The following query from OEM agent keeps failing, after upgrading Enterprise Manager Cloud Control and a monitoring agent to 13.2, this query is run in the 11.2.0.4 target database:

SELECT MEDIA
 FROM V$BACKUP_PIECE_DETAILS
 WHERE SESSION_KEY=:B3 AND SESSION_RECID=:B2 AND SESSION_STAMP=:B1 
   AND DEVICE_TYPE = 'SBT_TAPE' AND ROWNUM = 1

Also it uses huge temp space :

SQL> select USERNAME,TABLESPACE,BLOCKS*8/1024/1024 
      from V$TEMPSEG_USAGE 
  order by BLOCKS desc ;

USERNAME   TABLESPACE                       BLOCKS*8/1024/1024
---------- ------------------------------- ------------------
DBSNMP     TEMP                             30.649414

It is the exact same issue as perĀ (Doc ID 2201982.1). so the following actions are taken :

SQL> exec dbms_stats.gather_fixed_objects_stats;

PL/SQL procedure successfully completed.

SQL> exec dbms_stats.gather_schema_stats ('SYSTEM');

PL/SQL procedure successfully completed.

SQL> exec dbms_stats.gather_schema_stats ('SYS');

PL/SQL procedure successfully completed.

SQL> exec dbms_stats.gather_dictionary_stats;

PL/SQL procedure successfully completed.

Finally flush the cursor out of memory for next running :

SQL> select address, hash_value,PLAN_HASH_VALUE, executions, 
            loads, version_count, invalidations, parse_calls 
      from v$sqlarea 
     where sql_id='dx4nqvbtu06bx';

ADDRESS          HASH_VALUE PLAN_HASH_VALUE EXECUTIONS LOADS    
---------------- ---------- --------------- ---------- -----
VERSION_COUNT INVALIDATIONS PARSE_CALLS
------------- ------------- -----------
00000001418FA048 4087355773 1896464546      213        5          
1             1             213

SQL> exec dbms_shared_pool.purge('00000001418FA048,4087355773','C');

PL/SQL procedure successfully completed.

SQL> select address, hash_value,PLAN_HASH_VALUE, executions, loads, 
            version_count, invalidations, parse_calls 
       from v$sqlarea 
      where sql_id='dx4nqvbtu06bx';

no rows selected

Have a check of the new execution time. We can see the new execution plan is created, and the execution time is only 0.25 second.

SQL> select address, hash_value,PLAN_HASH_VALUE, executions,
            ELAPSED_TIME,ELAPSED_TIME/executions/1000000 TimePerExecution
      from v$sqlarea 
     where sql_id='dx4nqvbtu06bx';

ADDRESS          HASH_VALUE  PLAN_HASH_VALUE EXECUTIONS ELAPSED_TIME 
---------------- ----------- --------------- ---------- ------------ 
TIMEPEREXECUTION
----------------
00000001418FA048   4087355773   75529090       2          504858       .252429