Friday, November 21, 2008

Create OC4J Groups and Containers from command line.

Create OC4J Groups and Containers from command line.

$ORACLE_HOME/bin/createinstance –instanceName oc4j_foo -groupName foo_group
$ORACLE_HOME/bin/createinstance –instanceName BLUE –groupName COLORS


Script:
Create OC4J containers / OC4J Groups:
#!/bin/sh
if [ $# != 3 ];
then
echo "Start op: $0 "
echo "If there is no group create the container for the default group."
exit 1
fi

export ENV=${1}
export OC4J_CONTAINER=${2}
export OC4J_GROUP=${3}

. ~/${ENV}
$ORACLE_HOME/bin/createinstance -instanceName ${OC4J_CONTAINER} -groupName ${OC4J_GROUP}

opmnctl startproc process-type=${OC4J_CONTAINER}

exit 0

Links:
http://www.oracle.com/technology/tech/java/oc4j/1013/whitepapers/OC4J-FAQ-MGT-10131.pdf

Change oc4jadmin password

Change the password for the oc4jadmin user:

The j2ee/home/jazn.jar utility can be used to change the password for the oc4jadmin user from the command line.
cd j2ee/home
java –jar jazn.jar –setpassword jazn.com oc4jadmin


The password change can be immediately verified using jazn.jar
java -jar jazn.jar -checkpasswd jazn.com oc4jadmin -pw 


Unsuccessful verification of user/password pair.
java -jar jazn.jar -checkpasswd jazn.com oc4jadmin -pw 

Successful verification of user/password pair.

Shell scripts with admin.jar

I created an check uri shell script to test if the URI is correct:
#!/bin/sh
if [ $# != 2 ];
then
echo "Start: $0 "
echo "Single instance: (deployer:oc4j:opmn://HOSTNAME:OPMN_REQUEST_PORT/OC4J_CONTAINER)"
echo "Cluster: (deployer:cluster:opmn://HOSTNAME:OPMN_REQUEST_PORT/OC4J_CONTAINER)"
exit 1
fi

export URI=${1}
export PASSWORD=${2}


echo " ... checking the URI ..."
$JAVA_HOME/bin/java -Djava.util.logging.config.file=logging.properties -jar $ORACLE_HOME/j2ee/home/admin_client.jar ${URI} oc4jadmin ${PASSWORD} -validateURI
exit 0


Add Shared Libraries:
#!/bin/sh
if [ $# != 6 ];
then
echo "Start op: $0 "
echo "Example: "
echo "Single instance uri : deployer:oc4j:opmn://HOSTNAME:PORT/CONTAINER_NAME"
echo "Cluster uri : deployer:cluster:opmn://HOSTNAME:PORT/CONTAINER_NAME"
echo "Library sources : 'path/source1.jar path/source2.jar'"
exit 1
fi

export ENV=${1}
export URI=${2}
export PASSWORD=${3}
export LIBRARY_NAME=${4}
export LIBRARY_VERSION=${5}
export LIBRARY_SOURCE=${6}

. ~/${ENV}

check_uri ${ENV} ${URI} ${PASSWORD}
if [ $? == 0 ];
then
$JAVA_HOME/bin/java -Djava.util.logging.config.file=logging.properties -jar $ORACLE_HOME/j2ee/home/admin_client.jar ${URI} oc4jadmin ${PASSWORD} -publishSharedLibrary -name ${LIBRARY_NAME} -version ${LIBRARY_VERSION} -installCodeSources ${LIBRARY_SOURCE}
fi

exit 0


Script to create datasources/connection pools:
#!/bin/sh
if [ $# != 8 ];
then
echo "Start op: $0 "
echo "Example: "
echo "Single instance uri : deployer:oc4j:opmn://HOSTNAME:PORT/CONTAINER_NAME"
echo "Cluster uri : deployer:cluster:opmn://HOSTNAME:PORT/CONTAINER_NAME"
echo "Database connect string: DATABASE_HOSTNAME:PORT:ORACLE_SID"
exit 1
fi

export ENV=${1}
export URI=${2}
export PASSWORD=${3}
export CONNECTION_POOL=${4}
export DATASOURCE=${5}
export DB=${6}
export DB_USER=${7}
export DB_PASSWORD=${8}


. ~/${ENV}

check_uri ${ENV} ${URI} ${PASSWORD}
if [ $? == 0 ];
then
echo " ...create connection pool ${CONNECTION_POOL} ..."
$JAVA_HOME/bin/java -Djava.util.logging.config.file=logging.properties -jar $ORACLE_HOME/j2ee/home/admin_client.jar ${URI} oc4jadmin ${PASSWORD} -addDataSourceConnectionPool -name ${CONNECTION_POOL} -factoryClass oracle.jdbc.pool.OracleDataSource -dbUser ${DB_USER} -dbPassword ${DB_PASSWORD} -url jdbc:oracle:thin:@${DB}

echo " ...create managed data source ${DATASOURCE} ..."
$JAVA_HOME/bin/java -Djava.util.logging.config.file=logging.properties -jar $ORACLE_HOME/j2ee/home/admin_client.jar ${URI} oc4jadmin ${PASSWORD} -addManagedDataSource -name ${DATASOURCE} -jndiLocation jdbc/${CONNECTION_POOL} -connectionPoolName ${CONNECTION_POOL}

echo " ... Test managed data source ${DATASOURCE} ..."
$JAVA_HOME/bin/java -Djava.util.logging.config.file=logging.properties -jar $ORACLE_HOME/j2ee/home/admin_client.jar ${URI} oc4jadmin ${PASSWORD} -testDataSourceConnectionPool -name ${CONNECTION_POOL} -sqlStatement "select * from dual"
fi

exit 0

Thursday, November 20, 2008

Check if OID is accessible from database

With this SQL script it is possible to check if the OID is accessible from the database server:
set serverout on
DECLARE
retval PLS_INTEGER;
my_session DBMS_LDAP.session;
BEGIN
my_session := DBMS_LDAP.init('HOSTNAME','PORT');
retval := DBMS_LDAP.open_ssl(my_session, null, null, 1);
dbms_output.put_line('open_ssl returns: '|| to_char(retval));
retval := DBMS_LDAP.simple_bind_s(my_session,'cn=orcladmin','');
dbms_output.put_line('simple_bind_s returns: '|| to_char(retval));
retval := DBMS_LDAP.unbind_s(my_session);
dbms_output.put_line('unbind_s returns: '|| to_char(retval));
END;
/

Tuesday, November 18, 2008

Unlock account orcladmin

Unlock the orcladmin account when it is locked:
LDAP: ERROR CODE 49 - PASSWORD POLICY ERROR :9000: GSL_PWDEXPIRED_EXCP
cd $ORACLE_HOME/bin
./oidpasswd connect={METADATAREPOSITORY SID} unlock_su_acct=true

Output:
OID DB user password:
OID super user account unlocked successfully.

This unlocks the OID Super User account, cn=orcladmin ONLY. Do not confuse this account
with the default realm administrator "cn=orcladmin,cn=users,dc=xxxxx,dc=yyyyy". They are
two separate accounts. After resetting the orcladmin super user account, you will still
not be able to login to SSO using the orcladmin account until you perform the next step.

Monday, November 17, 2008

Shell script to clean up log files Oracle Application Server

This is an example of a shell script to clean up log files in an Oracle Application Server. Use at your own risk :)

#!/bin/sh
#################################################################
# Author : Arjan Goos #
# Date : 03-06-2008 #
# #
# Purpose : Clean log files Oracle Application Server #
# #
# History : #
# --------------------------------------------------------------#
# Date |Author |Description #
# --------------------------------------------------------------#
# 03-06-2008 |Arjan Goos |Creation #
# #
#################################################################
SCRIPT=`basename $0`
SCRIPT_PATH="/oracle/scripts/as/clean_log"
HOST_NAME=`hostname`

DATE=`date "+%d-%m-%y"`
STATUS_FILE=$SCRIPT_PATH/log/status-${SCRIPT}_${HOST_NAME}_${DATE}.txt

MAILADRES="test@test.nl"
DU_TOTAL=0

mail_logfile()
{
mail -s "Clean log files $HOST_NAME - Oracle home: $ORACLE_HOME - ( $DATE )" $MAILADRES < $STATUS_FILE
}

disk_usages_dir()
{
DUH=`du -hc | grep -i total | awk -F"total" '{ print $1 }'`
DIR=`pwd`
}

disk_usages_home()
{
DU_HOME=`du -c | grep -i total | awk -F"total" '{ print $1 }'`
DU_HOME=`expr $DU_HOME / 1024`
}

clean_apache()
{
echo " Start Clean Up Apache logging" >> $STATUS_FILE
echo "" >> $STATUS_FILE
cd $ORACLE_HOME/Apache/Apache/logs
disk_usages_dir
echo " Disk Usages in $DIR before $SCRIPT: $DUH." >> $STATUS_FILE
FILE="*_log.*"
echo " These log files are removed:" >> $STATUS_FILE
for LOG_FILE in `find ./ -name "$FILE" -mtime +"$TIME" -print 2>&1`
do
echo " $LOG_FILE" >> $STATUS_FILE
rm $LOG_FILE
done
disk_usages_dir
echo " Disk Usages in $DIR after $SCRIPT: $DUH." >> $STATUS_FILE
echo "" >> $STATUS_FILE
echo " Ready Clean Up Apache logging" >> $STATUS_FILE
echo "" >> $STATUS_FILE
}

clean_application_server_control()
{
echo " Start Clean Up Application Server Control" >> $STATUS_FILE
echo "" >> $STATUS_FILE
cd $ORACLE_HOME/opmn/logs >> $STATUS_FILE
disk_usages_dir
echo " Disk Usages in $DIR before $SCRIPT: $DUH." >> $STATUS_FILE
# Rotate log files
FILE="*.log*"
rotate_files
# Delete old rotated log files
delete_files
disk_usages_dir
echo " Disk Usages in $DIR after $SCRIPT: $DUH." >> $STATUS_FILE
echo "" >> $STATUS_FILE
echo " Ready Clean Up Application Server Control" >> $STATUS_FILE
echo "" >> $STATUS_FILE
}

clean_oc4j_instances()
{
echo " Start Clean Up OC4J Instances" >> $STATUS_FILE
echo "" >> $STATUS_FILE
cd $ORACLE_HOME/j2ee >> $STATUS_FILE
# Get all oc4j_instances from the opmn.xml
for OC4J_INSTANCE in `grep -i module-id=\"OC4J\" $ORACLE_HOME/opmn/conf/opmn.xml | awk -F'<process-type id=' '{ print $2 }' | awk -F" " '{ print $1 }' | sed 's/\"//g'`
do
echo " Start OC4J_CONTAINER: $OC4J_INSTANCE." >> $STATUS_FILE
cd $OC4J_INSTANCE/log
disk_usages_dir
echo " Disk Usages in $DIR before $SCRIPT: $DUH." >> $STATUS_FILE
# Rotate log files
FILE="*.log"
rotate_files
# Delete old rotated log files
delete_files
disk_usages_dir
echo " Disk Usages in $DIR after $SCRIPT: $DUH." >> $STATUS_FILE
cd - > /dev/null
echo " Ready OC4J_CONTAINER: $OC4J_INSTANCE." >> $STATUS_FILE
echo "" >> $STATUS_FILE
done
echo "" >> $STATUS_FILE
echo " Ready Clean Up OC4J Instances" >> $STATUS_FILE
echo "" >> $STATUS_FILE
}

clean_webcache()
{
if [ -d $ORACLE_HOME/webcache/log ];
then
echo " Start Clean Up WebCache" >> $STATUS_FILE
echo "" >> $STATUS_FILE
cd $ORACLE_HOME/webcache/log >> $STATUS_FILE
disk_usages_dir
echo " Disk Usages in $DIR before $SCRIPT: $DUH." >> $STATUS_FILE
# Rotate log files
FILE="*_log"
rotate_files
# Delete old rotated log files
delete_files
disk_usages_dir
echo " Disk Usages in $DIR after $SCRIPT: $DUH." >> $STATUS_FILE
echo "" >> $STATUS_FILE
echo " Ready Clean Up WebCache" >> $STATUS_FILE
echo "" >> $STATUS_FILE
fi
}

rotate_files()
{
#This function rotates the log files when the file is bigger than $ROTATE_SIZE
echo " These files are rotated: " >> $STATUS_FILE
for LOG_FILE in `find ./ -name "$FILE" -size +"$ROTATE_SIZE" -print | grep -v "archive" 2>&1`
do
#echo "cp $LOG_FILE $LOG_FILE.archive.$DATE"
echo " $LOG_FILE to $LOG_FILE.archive.$DATE" >> $STATUS_FILE
cp $LOG_FILE $LOG_FILE.archive.$DATE
cp /dev/null $LOG_FILE
done
echo "" >> $STATUS_FILE
}

delete_files()
{
#This function removes the rotated log files when the file is older than $TIME
FILE="*.archive.*"
echo " These archive files are removed:" >> $STATUS_FILE
for LOG_FILE in `find ./ -name "$FILE" -mtime +"$TIME" -print 2>&1`
do
echo " $LOG_FILE" >> $STATUS_FILE
rm $LOG_FILE
done
echo "" >> $STATUS_FILE
}

find_large_log_files()
{
cd $ORACLE_HOME
echo "" >> $STATUS_FILE
echo " Overview big remaining log files (manual action required):" >> $STATUS_FILE
echo ""
echo " These *.log files are in the $ORACLE_HOME with a size larger than $ROTATE_SIZE and older than $TIME day(s)." >> $STATUS_FILE
find ./ -name "*log*" -size +"2048k" -mtime +"$TIME" -exec ls -lh {} \; | awk '{ print " " $9 " size: " $5 }' >> $STATUS_FILE
echo "" >> $STATUS_FILE
}
cd $SCRIPT_PATH
#MAIN
if [ $# != 1 ];
then
echo "Start op: $0 <files older than DATE>"
exit 1
fi

#ORACLE_HOME=$1
TIME=$1
#Files bigger than 2 Mb are rotated
ROTATE_SIZE="2048k"
#ROTATE_SIZE="10k"

clear
echo "Start of the $SCRIPT on `date`: $HOST_NAME." >> $STATUS_FILE
echo "" >> $STATUS_FILE

for ORACLE_HOME in `cat /etc/oratab | grep -v "^#" | grep -v "^agent" | awk -F":" '{ print $2 }'`
do
if [ -n ${ORACLE_HOME} ];
then
echo " Start Oracle Home: $ORACLE_HOME." >> $STATUS_FILE
cd $ORACLE_HOME
disk_usages_home
echo "" >> $STATUS_FILE
### MAIN PROG
### Apache log
clean_apache
### Application Server Control logs
clean_application_server_control
### OC4J instances
clean_oc4j_instances
### Webcache
clean_webcache
#TO_DO
#application specific logging
find_large_log_files
echo "" >> $STATUS_FILE
echo " Total Disk Usage $ORACLE_HOME before $SCRIPT : $DU_HOME MB." >> $STATUS_FILE
DU_HOME_START=$DU_HOME
disk_usages_home
DU_HOME_STOP=$DU_HOME
echo " Total Disk Usage $ORACLE_HOME after $SCRIPT : $DU_HOME MB." >> $STATUS_FILE
echo "" >> $STATUS_FILE
echo " Total Cleared Disk Space $ORACLE_HOME by $SCRIPT: `expr $DU_HOME_START - $DU_HOME_STOP` MB." >> $STATUS_FILE
echo "" >> $STATUS_FILE
echo " Ready Oracle Home: $ORACLE_HOME." >> $STATUS_FILE
echo "" >> $STATUS_FILE
echo "" >> $STATUS_FILE
fi
done

echo "" >> $STATUS_FILE
echo "Ready of the $SCRIPT on `date`" >> $STATUS_FILE
echo "" >> $STATUS_FILE
echo "" >> $STATUS_FILE
mail_logfile
exit 0

Error in BPELAdmin and BPELConsole

An error occures when you try to access the BPELAdmin or BPELConsole:
http://HOSTNAME:PORT/BPELConsole/default/index.jsp and

Error:
[java.lang.NoSuchMethodException]
com.collaxa.cube.ejb.impl.FinderBean.tryLookupInstanceByReferenceId(java.lang.String, com.oracle.bpel.client.auth.DomainAuth)
http://HOSTNAME:PORT/BPELAdmin/domains.jsp

Error:
com.collaxa.cube.ejb.impl.FinderBean.tryLookupInstanceByReferenceId

On Oracle Metalink this error is solved: note: 471035.1
There has been a problem with the orabpel.ear file in some environments. The issue
can be verified by checking the size of the orabpel.ear files in the the following locations

$ORACLE_HOME/bpel/system/services/lib

and

$ORACLE_HOME/j2ee/oc4j_soa/applications

If only one of them is of size 2530260 bytes, then you have hit upon the cause for this issue in your environment.

Solution
Copy the orabpel.ear from $ORACLE_HOME/bpel/system/services/lib (the one that is of size 2530260 bytes) to the location
$ORACLE_HOME/j2ee/oc4j_soa/applications (to replace the one that is not 2530260 bytes) and restart.

Designtime cache has not been initialized

This is a generic error in the ESB Control GUI.

More information about this error can be found in the logging of the OC4J container in which the esb-dt application is deployed (default: $ORACLE_HOME/opmn/logs/default_group~oc4j_soa~default_group~1.log) or in the log.xml of the application esb-dt (default: $ORACLE_HOME/j2ee/oc4j_soa/log/oc4j_soa_default_group_1/oc4j/log.xml).

Reason 1:
The connection to the database can not be made:
Warning: Unable to set up connection factory for a resource adapter in esb-rt: Error creating a ResourceAdapter implementation class. Error creating a JavaBean of class 'oracle.tip.esb.server.bootstrap.RuntimeResourceAdapter: javax.resource.spi.ResourceAdapterInternalException: java.lang.RuntimeException: failed to get ESB_HOME: java.lang.NullPointerException

Check your datasources in the Application Server Control

Reason 2:
The dehydration store tables are not filled with the correct data. If an virtual hostname is used check if the hostname is accessible on the correct port number.
There are several checks which can be executed:
ping hostname
telnet hostname port
nslookup ip address

There are two tables which must be checked: ORAESB.ESB_PARAMETERS and ORAESB.WF_AGENTS. I created an sql query that can be used:
set feedback off;
set heading off;
set pages 0;
set linesize 500;
select 'param_name: '||param_name, 'param_value: '||param_value from esb_parameter;
select 'queue_name: '||queue_name, 'name: '||name, 'tcf_jndi: '||tcf_jndi from wf_agents;
exit;
This should be the output:
param_name: PROP_NAME_MONITOR_TOPIC_JNDI
param_value: ESBTopics/Topics/ESB_MONITOR

param_name: PROP_NAME_ERROR_XATCF_JNDI
param_value: OracleOJMS/XATCF

param_name: PROP_NAME_ERROR_RETRY_JNDI
param_value: ESBTopics/Topics/ESB_ERROR_RETRY

param_name: DT_OC4J_HTTP_PORT
param_value: VIRTUAL PORT NUMBER

param_name: PROP_NAME_CONTROL_TCF_JNDI
param_value: OracleOJMS/XATCF

param_name: PROP_NAME_DEFERRED_TOPIC_JNDI
param_value: ESBTopics/Topics/ESB_JAVA_DEFERRED

param_name: PROP_NAME_MONITOR_TCF_JNDI
param_value: OracleOJMS/TCF

param_name: PROP_NAME_ERROR_TOPIC_JNDI
param_value: ESBTopics/Topics/ESB_ERROR

param_name: PROP_NAME_INITIAL_CONTEXT_FACTORY
param_value: com.evermind.server.rmi.RMIInitialContextFactory

param_name: PROP_NAME_ERROR_TCF_JNDI
param_value: OracleOJMS/TCF

param_name: ACT_ID_RANGE
param_value: 400

param_name: PROP_NAME_CONTROL_TOPIC_JNDI
param_value: ESBTopics/Topics/ESB_CONTROL

param_name: PROP_NAME_DEFERRED_TCF_JNDI
param_value: OracleOJMS/TCF

param_name: DT_OC4J_HOST
param_value: VIRTUAL HOSTNAME

param_name: PROP_NAME_DEFERRED_XATCF_JNDI
param_value: OracleOJMS/XATCF

param_name: PROP_NAME_ERROR_RETRY_TCF_JNDI
param_value: OracleOJMS/XATCF

SQL> queue_name: ESBTopics/Topics/ESB_JAVA_DEFERRED
name: ESBTopics/Topics/ESB_JAVA_DEFERRED
tcf_jndi: OracleOJMS/XATCF

queue_name: ESBTopics/Topics/ESB_JAVA_DEFERRED
name: ESBTopics/Topics/ESB_JAVA_DEFERRED
tcf_jndi: OracleOJMS/XATCF


Reason 3:
Apache.commons.logging must be removed from the orion-application.xml

In the file: $ORACLE_HOME/j2ee/oc4j_soa/application-deployments/esb-dt/orion-application.xml and in the file $ORACLE_HOME/j2ee/oc4j_soa/applications/esb-dt/META-INF/orion-application.xml a line must be added:
<remove-inherited name="apache.commons.logging"/>
After this change the container must be restarted.
opmnctl restartproc process-type=oc4j_soa

Rename system0 ESB system

When you create an ESB system in the GUI ESB Controle this system has the default name system0. This can be changed by clicking on this name.

Friday, November 14, 2008

Export/Import Portal

Export Existing Portal Page Groups:
First an export must be prepared in GUI of Portal, click on one of the login links to login with the portal user:
http://{HOSTNAME}:{PORT}/portal/page/portal

Click on the link navigator:

Click on the link export of every page group you want to export. In my case Export_portal_test

If this is the first page group you want to export you can make a new export set, if this is not the first page group you can add the page group to an existing page group.
Click on the next button:

Choose if you want to export extern objects, if you want this, select the objects and click the button Add to transportset.
When this is the only page group you want to export you can click the button Export Now. If you want to export more page groups you can save the export set for later use (button Save For Later).

Now you see a screen with a link to the log file of the process making the export ready. This export fills a couple of tables with information about your page groups. An script is generated that can be used to make a database export of these tables.

Copy the contents of this script to file on a linux server and make this file executable
chmod 700 exp_portal.sh

Now we can make an export of the portal tables which contain the page group export information. The Oracle SID is the database which hosts the portal metadata repository. First set the environment variables of the database:
. oraenv
ORACLE_SID = [oracle] ? [type the ORACLE SID]
./exp_portal.sh -mode export -s portal -p xxxxxxx -c $ORACLE_SID -d portal_dump.dmp

The portal password can be found in the OID. This script creates an database dump file: portal_dump.dmp. This file can be imported in another portal metadata repository database.

Import Portal Page Groups:
Copy the export script (created by portal) and the dump file which is created during execution of the export script to the database server which hosts the portal metadata repository where the page group should be imported to.

Execute the script to import the database dump in the other metadata repository like this:
. oraenv
ORACLE_SID = [oracle] ? [type the ORACLE SID]
./exp_portal.sh -mode import -s portal -p xxxxxx -pu portal -pp yyyyy -company none -c $ORACLE_SID -d portal_dump.dmp

The first password (xxxxxx) is for the portal user in the database, the second password (yyyyy)is from the portal user this password is given during installation of the Portal Application Server (same as orcladmin).

Now we can process the page group export in the portal. Log in on the portal builder click on one of the login links to login with the portal user:
http://{HOSTNAME}:{PORT}/portal/page/portal

Click on the tab Administer:

Now you can Browse Transport Sets in the portlet: Export/Import Transport Set there is a small button next to the import button:

Select the transport set you want to import and click on the button Import.

It is also possible to do it with a shell script: $ORACLE_HOME/portal/admin/plsql/wwu/opeasst.csh


For more information:
http://download-uk.oracle.com/docs/cd/B10464_05/portal.904/b13675/cg_imex.htm#i1022009

metalink note: 306785.1

Change default password bpeladmin: Oracle BPELAdmin (10.1.3.3)

Go to the Application Server Enterprise manager and login with oc4jadmin user. Click on the container where the orabpel application is deployed in my case oc4j_soa:

Click on the Administration link:

Click on the “Go To” icon behind Security Providers:

Click on the button Instance Level Security:

Click on the link Realms and on the link under users:

Click on the link bpeladmin:

Change the passwords and click on the Apply button:

Change default password admin OWSM: Oracle Web Service Manager (10.1.3.3):

There is no GUI availible to change passwords of the Oracle Web Service Manager
Change the file manageUserGroups.properties first make a copy:
cd $ORACLE_HOME/owsm/bin
cp manageUserGroups.properties manageUserGroups.properties.org
vi manageUserGroups.properties

Contents of the file:

#============== Recommendation =======================
#Since all passwords property values, db_password, user_password
#are in clear text, for security reason, we recommend those values
#be deleted right after the use of command-line user/group management
#tool (manageusergroups.xml) and not be kept in this file.

#============== Provide your Database Connection Properties below
# Sample DB Connection Values
#db_url=jdbc:oracle:thin:@//{HOSTNAME_DATABASE}:{PORT}/{ORACLE_SID}
#db_driver=oracle.jdbc.driver.OracleDriver
#db_user=ORAWSM
#db_password=xxxxxxxxxxxxxxxxxxxxxxxx

db_url=jdbc:oracle:thin:@//{HOSTNAME_DATABASE}:{PORT}/{ORACLE_SID}
db_driver=oracle.jdbc.driver.OracleDriver
db_user=ORAWSM
db_password=xxxxxxxxxxxxxxxxxxxxxxxx

#============== User Parameters
# Sample User Values
#user_id=ctang
#user_name=Administrator
#user_password=mypasswrod
#user_email=admin@admin.com

#user_id=
#user_name=
#user_password=
#user_email=

user_id=admin
user_name=admin user
user_password={PASSWORD}
user_email=wsmadmin@xxxx.xxx

group_id=su1-grp
group_desc=super user group

#============== Group Parameters
# Sample Group Values
#group_id=IT-INFR
#group_desc=IT Infrastructure

#group_id=
#group_desc=

Change the {PASSWORD} value with the new password.

Remove the old admin user and the group to which the user belongs

cd $ORACLE_HOME/owsm/bin
./wsmadmin.sh manageUserGroups deleteUserGroup

Output:

Buildfile: $ORACLE_HOME/owsm/bin/../scripts/manageusergroups.xml
set-classpath-oracle:
[echo] Setting Oracle Classpath

manage-del-user-group:
[java] SUCCESS : Mapping between user "admin" and Group "su1-grp" successfully deleted from database.

BUILD SUCCESSFUL
Total time: 1 second

Delete the user:

./wsmadmin.sh manageUserGroups deleteUser

Output:

Buildfile: $ORACLE_HOME/owsm/bin/../scripts/manageusergroups.xml

set-classpath-oracle:
[echo] Setting Oracle Classpath

manage-del-user:
[java] SUCCESS : User "admin" successfully deleted from database.

BUILD SUCCESSFUL
Total time: 1 second

Create new user:
cd $ORACLE_HOME/owsm/bin
./wsmadmin.sh manageUserGroups addUser

Output:

Buildfile: $ORACLE_HOME/owsm/bin/../scripts/manageusergroups.xml

set-classpath-oracle:
[echo] Setting Oracle Classpath

manage-add-user:
[java] SUCCESS : User "admin" successfully added into database.

BUILD SUCCESSFUL
Total time: 1 second

Create an usergroup and add the admin user to this group.
./wsmadmin.sh manageUserGroups addUserGroup

Output:

Buildfile: $ORACLE_HOME/owsm/bin/../scripts/manageusergroups.xml

set-classpath-oracle:
[echo] Setting Oracle Classpath

manage-add-user-group:
[java] SUCCESS : Mapping between user "admin" and group "su1-grp" successfully added into the database.

BUILD SUCCESSFUL
Total time: 1 second

For more information Metalink note: 428513.1

Change Database Name and ID

Changing the DBID and Database Name is possible since version 9.2.0.

The following steps describe how to change the DBID of a database. Optionally, you can change the database name as well.
1. Ensure that you have a recoverable whole database backup.
2. Ensure that the target database is mounted but not open, and that it was shut down consistently prior to mounting.
For example:
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;

3. Invoke the DBNEWID utility on the command line, specifying a valid user with the SYSDBA privilege.
For example:
nid TARGET=SYS/oracle@test_db

To change the database name in addition to the DBID, specify the DBNAME parameter. This example changes the name to test_db2:
nid TARGET=SYS/oracle@test DBNAME=test_db2

The DBNEWID utility performs validations in the headers of the datafiles and control files before attempting I/O to the files. If validation is successful, then DBNEWID prompts you to confirm the operation (unless you specify a log file, in which case it does not prompt), changes the DBID for each datafile (including offline normal and read-only datafiles), and then exits. The database is left mounted but is not yet usable.
For example:
DBNEWID: Release 9.2.0.1.0
(c) Copyright 2002 Oracle Corporation. All rights reserved.
Connected to database TEST_DB (DBID=3942195360)
Control Files in database:
/oracle/dbs/cf1.f
/oracle/dbs/cf2.f
Change database id of database SOLARIS? (Y/[N]) => y
Proceeding with operation
Datafile oracle/dbs/tbs_01.f - changed
Datafile /oracle/dbs/tbs_02.f - changed
Datafile /oracle/dbs/tbs_11.f - changed
Datafile /oracle/dbs/tbs_12.f - changed
Datafile /oracle/dbs/tbs_21.f - changed
New DBID for database TEST_DB is 3942196782.
All previous backups and archived redo logs for this database are unusable
Proceed to shutdown database and open with RESETLOGS option.
DBNEWID - Database changed.

If validation is not successful, then DBNEWID terminates and leaves the target database intact. You can open the database, fix the error, and then either resume the DBNEWID operation or continue using the database without changing its DBID.

4. After DBNEWID successfully changes the DBID, shut down the database:

SHUTDOWN IMMEDIATE;

5. Mount the database. For example:
STARTUP MOUNT

6. Open the database in RESETLOGS mode and resume normal use. For example:
ALTER DATABASE OPEN RESETLOGS;

Make a new database backup. Because you reset the online redo logs, the old backups and archived logs are no longer usable in the current incarnation of the database.

Changing Only the Database Name

The following steps describe how to change the database name without changing the DBID.
1. Ensure that you have a recoverable whole database backup.
2. Ensure that the target database is mounted but not open, and that it was shut down
consistently prior to mounting. For example:
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;

3. Invoke the utility on the command line, specifying a valid user with the SYSDBA privilege. You must specify both the DBNAME and SETNAME parameters. This example changes the name to test_db2:
nid TARGET=SYS/oracle@test_db DBNAME=test_db2 SETNAME=YES

DBNEWID performs validations in the headers of the control files (not the datafiles) before attempting I/O to the files. If validation is successful, then DBNEWID prompts for confirmation, changes the database name in the control files, and exits. After DBNEWID completes successfully, the database is left mounted but is not yet usable.
DBNEWID: Release 9.2.0.1.0
(c) Copyright 2002 Oracle Corporation. All rights reserved.
Connected to database TEST_DB (DBID=3942196782)
Control Files in database:
/oracle/dbs/cf1.f
/oracle/dbs/cf2.f
Change database name of database TEST_DB to TEST_DB2? (Y/[N]) => Y

Proceeding with operation


Database name changed from TEST_DB to TEST_DB2 - database needs to be shutdown.

Modify parameter file and generate a new password file before restarting.
DBNEWID - Successfully changed database name

If validation is not successful, then DBNEWID terminates and leaves the target database intact. You can open the database, fix the error, and then either resume the DBNEWID operation or continue using the database without changing the database name.
4. Shut down the database. For example:
SHUTDOWN IMMEDIATE;

5. Set the DB_NAME initialization parameter in the initialization parameter file to the new database name.
6. Create a new password file.
7. Start up the database and resume normal use. For example:
STARTUP;

Reference: http://download.oracle.com/docs/cd/B10500_01/server.920/a96652/ch14.htm

Automatic deployment BPEL's

Two possible ways to deploy BPEL's. With the GUI and by copying the *.jar to the $ORACLE_HOME/bpel/domains/default/deploy directory. In this case the deployment of the BPEL's is in de default BPEL domain. When you want to deploy to an other domain you should replace default in the path with the name of the other group
(for example: $ORACLE_HOME/bpel/domains/new_group/deploy )

If the deployment fails the *.jar file will be renamed to *.jar.failed. The log file of the OC4J container where the ORABPEL application is installed shows the error (default location: $ORACLE_HOME/opmn/logs/).

It is also possible to automatically redeploy the default BPEL's of the SOA suite by copying the following files to the directory: $ORACLE_HOME/bpel/domains/default/deploy:

cp $ORACLE_HOME/bpel/install/extensions/bpel_TaskActionHandler_1.0.jar $ORACLE_HOME/bpel/domains/default/deploy

cp $ORACLE_HOME/bpel/install/extensions/bpel_TaskManager_1.0.jar $ORACLE_HOME/bpel/domains/default/deploy

Monday, June 2, 2008

Change hostname, ip address of an Oracle Application Server SOA suite (chgiphost.sh)

It is possible to change the hostname ip address from a linux server where Oracle Application Server SOA suite (10.1.3.3.x) is installed.
The following steps need to be executed:
1. Stop the Oracle Application Server
opmnctl shutdown

2. Change the network linux server settings
Change hostname/ip address in /etc/hosts
Change hostname/ip address in /etc/sysconfig/network
Change ip address in /etc/sysconfig/network-scripts/ifcfg-eth0

Execute command hostname:
hostname {HOST_NAME_NEW}

3. Execute script chgiphost.sh
$ORACLE_HOME/chgip/scripts/chgiphost.sh

4. Find and replace the hostname in all the files of the ORACLE_HOME. These files can be found with the following command:
find ./ -type f -name '*' -print0  xargs -0 grep -li -e "{HOST_NAME_ORG}"

I created a script to do this for me: searchreplace


#!/bin/sh

if [ $# != 2 ];
then
echo "Start op: $0 "
exit 1
fi

REPLACE_WORD=${1}
WORD=${2}


for FILE in `find ./ -type f -name '*' -print0 | xargs -0 grep -li -e "${REPLACE_WORD}"`
do
echo "In the ${FILE} the word ${REPLACE_WORD} is replaced by ${WORD}."
cat ${FILE} | sed 's/'${REPLACE_WORD}'/'${WORD}'/g' > ${FILE}_TMP
mv ${FILE}_TMP ${FILE}
done

exit 0


5. Start Oracle Database which is used for the SOA metadata repository and Update table ORAESB.ESB_PARAMETER en DT_OC4J_HOST:

sqlplus oraesb
update oraesb.esb_parameter
set param_value='$HOST_NAME_NEW.$HOST_DOMAIN_NEW'
where param_name ='DT_OC4J_HOST';

6. Start Oracle Application Server:
opmnctl startall

Friday, May 30, 2008

Some Linux commando's Redhat

Tar and zip file:
tar zcf oblog.tar.gz *

Get RedHat release:
cat /etc/redhat-release

Get the processor information:
cat /proc/cpuinfo

Get memory information:
cat /proc/meminfo

Determine if an machine is 32bit or 64bit:
uname -a
64 bit:
Linux hostname 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:58:43 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux

32 bit:
uname -a
Linux hostname 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:12 EDT 2008 i686 i686 i386 GNU/Linux

What is LISTING on a specific port:
netstat -a | grep {PORT_NUMBER}

or

lsof -i tcp:{PORT_NUMBER}

ssh to another host without a password:
#Generate a key pair
cd $HOME/.ssh/
ssh-keygen -t rsa

#copy the key pair to the server from which you want to log in:
cat id_rsa.pub | ssh host 'cat>>.ssh/authorized_keys'


What is the biggest file in a directory:
du --max-depth=1 /home/ | sort -n -r


Size of multiple directories
du -sH *

Friday, May 23, 2008

bash one liners

Kill all processes form a user:
pkill -u [USER_NAME]

Automatic start by linux startup check
chkconfig -l [APP_NAME]

Automatic start by linux startup add application, in runlevel 3,5
chkconfig -add [APP_NAME] -level 3,5


Which linux OS:
cat /etc/issue

To remove the ^M characters at the end of all lines in vi, use:
:1,$s/^V^M//g

Want to know which file contains specific words in a directory tree:
find ./ -type f -name '*' -print0  ¦ xargs -0 grep -li -e "word1" -e "word2" -e "word3"

When you want an user typing a password in a shell script you do not want to see this password on the screen. You can use read -s to do this:
echo "Please type the administrator password:
read -s PASSWORD

Get the file name from an string with a whole path this can be done with the basename function.
For example, the path /oracle/product/10.2.0/bin/emca and you only want emca you can do this
EMCA=`basename /oracle/product/10.2.0/bin/emca`

And if you want the directory this is also simple:
ORACLE_BIN=`dirname /oracle/product/10.2.0/bin/emca`

If you want to query some value from an Oracle database and put this value in a variable in the shell script. Make a function which does the login on sqlplus and the query. This function can be called and put in an variable:
execsql_silent()
{
$ORACLE_HOME/bin/sqlplus -s $ORACLE_CREDENTIALS <<SQL
whenever sqlerror exit
set heading off
set feedback off
$*;
exit
SQL
}

STATUS_DB=$(execsql_silent "SELECT status FROM v\$instance")

Waiting cursor function

When you want to animate a sleep in a shell script you can use the following function:
waiting_cursor()
{
echo "In 5 seconds ..., cancel with CTRL-C"
sleep 5
pid=$!
printf "Waiting: |"
rotate='|/-\'
while kill -n 0 $pid 2>/dev/null;
do
rotate="${rotate#?}${rotate%???}"
printf '\b%.1s' "$rotate"
sleep 1
done
echo " "
wait $pid
echo " "
}

Thursday, May 22, 2008

Drop database

Removing a 10g database is really simple with the commando drop database. All files are removed from the OS.
shutdown abort;
startup mount exclusive restrict;
drop database;

Begin Blog

This is my first post on my blog. I want to use this blog as an notepad for all my knowledge about Oracle software.

I hope this blog will help you solving your problems.