Tuesday, August 18, 2009

Running OIM Task Scheduler from Command line

In OIM, reconciliation is done with Scheduler Tasks .
Unfortunately there is no tool to launch a Scheduler Task from the command-line, which is required at many times when you need to run OIM scheduler from schedulers outside OIM or command line.

I wrote this utility to run scheduler from cmd.This Utility launches a Scheduler Task from the command-line.First create a directory "RunSchedulerTask" and then copy these files (source code below)· "RunSchedulerTask.java" · "build.xml" To run, simply open a command-line prompt, change directory to RunSchedulerTask, and run ant: ${xl.home}\ant\bin\ant.bat run -Dxl.home="${xl.home}" -Dargs=" "Where · classname is the full classname of the scheduler task to run · username is xelsysadm · password is abcd1234 · task-file.properties is the properties file containing the Scheduler Task attributes ExampleTo run the Lookup reconciliation: Create a Task attributes file "ADGroupLookupRecon.properties" and add the following lines: Server=MyActiveDirectoryServerItResourceInstanceLookupCodeName=Lookup.ADReconliation.GroupLookupRun Ant ${xl.home}\ant\bin\ant.bat run -Dxl.home="${xl.home}" -Dargs="com.thortech.xl.schedule.tasks.ADGroupLookupReconTask xelsysadm abcd1234 ADGroupLookupRecon.properties"


Source code for RunSchedulerTask.java
import Thor.API.Security.LoginHandler.LoginSession;import Thor.API.Security.XLClientSecurityAssociation;import Thor.API.tcUtilityFactory;import com.thortech.util.logging.Logger;import com.thortech.xl.client.dataobj.tcDataBaseClient;import com.thortech.xl.scheduler.tasks.SchedulerBaseTask;import com.thortech.xl.util.config.ConfigurationClient;import java.io.*;import java.util.Properties;
/* * RunSchedulerTask * * Runs an Xellerate Scheduler task from the command-line. * @author Akshat Agarwal */public class RunSchedulerTask{ /* * arg[0] : recon class name. Class must derived from SchedulerBaseTask * arg[1] : username * arg[2] : password * arg[3] : Aktask.properties is the properties file containing the Scheduler Task attributes */ public static void main(String args[]) { if (args.length < sctask =" (SchedulerBaseTask)" prop =" ConfigurationClient.getComplexSettingByPath(" tcutilityfactory =" new" attributes =" new"> 3) { attributes.load( new FileInputStream( new File(args[3]) )); scTask.setTaskAttributeMap(attributes); } // Get a database handle LoginSession loginsession = tcutilityfactory.getLoginSession(); XLClientSecurityAssociation.setGlobalLoginSession(loginsession);
tcDataBaseClient dbClient = new tcDataBaseClient(); //String s = dbClient.getDatabaseName(); scTask.setDataBase(dbClient);
// Running the Scheduler Base task scTask.runAsThread(); boolean success = scTask.isSuccess(); if (!success) { System.out.println("Scheduler Failed to Run"); String message = scTask.getStatus(); System.out.println("Status: " + message); Exception ex = scTask.getResult(); } } catch (Exception ex) { ex.printStackTrace(); } System.exit(0); }}


BUILD.xml file

-----
task.properties
Day Max=UNLIMITED
Task Max=UNLIMITED

Tuesday, August 4, 2009

How to generate AWR Report for all instances in Oracle 11g RAC?

spawrrac.sql:This script generates a global AWR report to report performance statistics on all nodes of a cluster.

Different Object types in Oracle 11g DB

Different Object types in Oracle 11g DB:
1 = INDEX,
2 = TABLE,
3 = CLUSTER,
4 = VIEW,
5 = SYNONYM,
6 = SEQUENCE,
7 = PROCEDURE,
8 = FUNCTION,
9 = PACKAGE,
10 = NON-EXISTENT,
11 = PACKAGE BODY,
12 = TRIGGER,
13 = TYPE,
14 = TYPE BODY,
19 = TABLE PARTITION,
20 = INDEX PARTITION,
21 = LOB,
22 = LIBRARY,
23 = DIRECTORY ,
24 = QUEUE,
25 = IOT,
26 = REPLICATION OBJECT GROUP,
27 = REPLICATION PROPAGATOR,
28 = JAVA SOURCE,
29 = JAVA CLASS,
30 = JAVA RESOURCE,
31 = JAVA JAR,
32 = INDEXTYPE,
33 = OPERATOR ,
34 = TABLE SUBPARTITION,
35 = INDEX SUBPARTITION
82 = (Data Mining) MODEL
92 = OLAP CUBE DIMENSION,
93 = OLAP CUBE ,
94 = OLAP MEASURE FOLDER,
95 = OLAP CUBE BUILD PROCESS


Source: 11g: dcore.bsq . The object types 92-95 are newly introduced in 11g DB for "On-line Analytical Processing".
Futher detail visit site: "http://www.oracle.com/technology/products/bi/olap/index.html"

Oracle 11g DB locks Details

Oracle 11g DB locks Details:

Lock type:
'MR', 'Media Recovery',
'RT', 'Redo Thread',
'UN', 'User Name',
'TX', 'Transaction',
'TM', 'DML',
'UL', 'PL/SQL User Lock',
'DX', 'Distributed Xaction',
'CF', 'Control File',
'IS', 'Instance State',
'FS', 'File Set',
'IR', 'Instance Recovery',
'ST', 'Disk Space Transaction',
'TS', 'Temp Segment',
'IV', 'Library Cache Invalidation',
'LS', 'Log Start or Switch',
'RW', 'Row Wait',
'SQ', 'Sequence Number',
'TE', 'Extend Table',
'TT', 'Temp Table',

Lock Mode:
0, 'None', /* Mon Lock equivalent */
1, 'Null', /* N */
2, 'Row-S (SS)', /* L */
3, 'Row-X (SX)', /* R */
4, 'Share', /* S */
5, 'S/Row-X (SSX)', /* C */
6, 'Exclusive', /* X */
blocking_others:
0, 'Not Blocking', /* Not blocking any other processes */
1, 'Blocking', /* This lock blocks other processes */
2, 'Global', /* This lock is global, so we can't tell */
to_char(block)) blocking_others

DBA_LOCK_INTERNAL has a row for each lock or latch that is being held, and
one row for each outstanding request for a lock or latch.
The columns of DBA_LOCK_INTERNAL are:
session_id - session holding or acquiring the lock
type - type of lock (DDL, LATCH, etc.)
mode_held - mode the lock is currently held in by the session
mode_requested - mode that the lock is being requested in by the process
lock_id1 - type specific identifier of the lock
lock_id2 - type specific identifier of the lock

Important objects to view lock monitoring: DBA_KGLLOCK, DBA_LOCKS, DBA_LOCK_INTERNAL, DBA_DML_LOCKS, DBA_DDL_LOCKS, DBA_WAITERS, DBA_BLOCKERS, V$LOCK, V$LOCKED_OBJECT,
V$$SESSION_WAIT,V$RESOURCE_LIMIT, V$lock_element, V$lock_activity,v$locks_with_collisions

Further Details can be found in $ORACLE_HOME/rdbms/admin/catblock.sql

Tuesday, April 14, 2009

enable only sftp for identied user and disable ssh

Goal: only allow sftp to list of users and disable ssh.

Generally if ssh is enable, user can do both ssh as well as sftp. But some time business need that list of user should be able to do the sftp only and ssh for these users should be disabled.

1. To achieve this check openssh is installed on you unix box.

2. Start ssh service "/etc/init.d/sshd start"

2. Run command "env|grep -i shell" to find the default shell for user.

3. find the path of sftp-server in /usr/lib. (in my env. OEL5 path is /usr/libexec/openssh/sftp-server)

4. Run cammand to change the shell for user:
usermod -s /usr/libexec/openssh/sftp-server

5. now try to do the ssh with this user
ssh @localhost

This will not work.

6. Now try sftp @localhost

This will work.


After this user will be able to do only sftp and ssh would not work for these users for which login shell has been changed.