Search This Blog

Wednesday, June 22, 2011

Adding Source Code to a Blog

http://codeshode.blogspot.com/2010/06/format-my-source-code-for-blogging.html

Copy the following Code

  • Copy the following code and paste it into your Blogger Template just above the </head> tag

 

<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/> 

<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> 

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'></script

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'></script

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'></script

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'></script

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'></script

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'></script

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'></script

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'></script

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'></script

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'></script

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'></script

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'></script

<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'></script

<script language='javascript'

SyntaxHighlighter.config.bloggerMode = true;

SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';

SyntaxHighlighter.all();

</script>

 

  • Save the template
  • Then you can start creating code blocks in your existing or new Blog entries.
  • There are 2 ways to add a code block using syntaxhighlighter

Add the following cdoe ,

<pre class="brush: java">
// Comment
public class Testing
{
public Testing() {
}
public void Method()
{
/* Another Comment
on multiple lines */
int x = 9;
}
}
</pre>

How to use AQ with WebLogic Server

Create the jmsuser user for accessing the AQ
sqlplus SYS/manager1@ORCL AS SYSDBA

grant connect,resource,aq_administrator_role to jmsuser identified by jmsuser;
grant select on sys.DBA_PENDING_TRANSACTIONS to jmsuser;
grant execute on sys.dbms_aqadm to jmsuser;
grant execute on sys.dbms_aq to jmsuser;
grant execute on sys.dbms_aqin to jmsuser;
grant execute on sys.dbms_aqjms to jmsuser;
exec dbms_aqadm.grant_system_privilege('ENQUEUE_ANY','jmsuser');
exec dbms_aqadm.grant_system_privilege('DEQUEUE_ANY','jmsuser');


package webserv1;

import java.util.Hashtable;

import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;

import javax.naming.Context;
import javax.naming.InitialContext;

public class SendMsgQueue {
public SendMsgQueue() {
}

public static void main(String argv[]) throws Exception {

Hashtable env = new Hashtable();
// Standalone OC4J connection details
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "weblogic");
env.put(Context.SECURITY_CREDENTIALS, "welcome1");
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
// env.put(Context.PROVIDER_URL, "t3://ceiacb5.us.oracle.com:7001");
InitialContext context = new InitialContext(env);


// The producer and consumer need to get a connection factory and use it to set up
// a connection and a session

QueueConnectionFactory connFactory = (QueueConnectionFactory) context.lookup("AQJMS_XAConnectionFactory");
QueueConnection conn = connFactory.createQueueConnection();
// This session is not transacted, and it uses automatic message acknowledgement
QueueSession session = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue q = (Queue) context.lookup("jms/JMSDEMO_QUEUE1");
// Sender
QueueSender sender = session.createSender(q);
// Text message
TextMessage msg = session.createTextMessage();
msg.setText("Hello Test123");
System.out.println("Sending the message: "+msg.getText());
sender.send(msg);

session.close();
conn.close();
}
}


Program for Receving the Message


package webserv1;

import java.util.Hashtable;

import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;

import javax.naming.Context;
import javax.naming.InitialContext;

public class RecvMsgQueue {
public RecvMsgQueue() {
super();
}

public static void main(String argv[]) throws Exception {

Hashtable env = new Hashtable();
// Standalone OC4J connection details
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "weblogic");
env.put(Context.SECURITY_CREDENTIALS, "welcome1");
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
// env.put(Context.PROVIDER_URL, "t3://ceiacb5.us.oracle.com:7001");
InitialContext context = new InitialContext(env);

// The producer and consumer need to get a connection factory and use it to set up
// a connection and a session

// QueueConnectionFactory connFactory = (QueueConnectionFactory) context.lookup("jms/oc4jQueueConnFactory");
QueueConnectionFactory connFactory =(QueueConnectionFactory) context.lookup("AQJMS_XAConnectionFactory");


QueueConnection conn = connFactory.createQueueConnection();
// This session is not transacted, and it uses automatic message acknowledgement
QueueSession session = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

Queue q = (Queue) context.lookup("jms/JMSDEMO_QUEUE1");
// Queue q = (Queue) context.lookup("jms/oc4jQueue");
/* // Sender
QueueSender sender = session.createSender(q);
// Text message
TextMessage msg = session.createTextMessage();
msg.setText("Hello there!");
System.out.println("Sending the message: "+msg.getText());
sender.send(msg);

*/
// Receiver
QueueReceiver receiver = session.createReceiver(q);
conn.start();
Message m = receiver.receive();
if(m instanceof TextMessage) {
TextMessage txt = (TextMessage) m;
System.out.println("Message Received: "+txt.getText());
}
session.close();
conn.close();
}
}

Monday, June 20, 2011

How to Install multiple Linux Distributions in the same Machine

My requirement is to have the following OS's in my computer.

Windows 7
Redhat Linux 4
Oracle Enterprise Linux 5


First install Windows 7.

Using Windows 7 Disk Manager, create 3 partitions
say
hda5 => 50 GB (For RedHat Linux)
hda6 => 6 GB (For the Swap , we can use the same Swap for other linux install also)
hda7 => 50GB ((For Oracle Linux)

Now this install Redhat Linux 5 , select the root(/) partition as hda5
and swap as hda6. In the install screen please select the option to install the grub.

Now install Oracle Linux 5 , here select the root(/) partition as hda7
and swap as hda6.

In the install do not choose to install the grub option as you already have grub installed
by the first install.

Now Boot the machine in to Redhat Linux and mount the hda7 partition.

mount /dev/hda7 /test

Find out the files under the directory /test/boot directory ,

ls vm* init*

initrd-2.6.18-194.el5.img     vmlinuz-2.6.18-194.el5
initrd-2.6.18-194.el5PAE.img  vmlinuz-2.6.18-194.el5PAE

Now edit the /etc/grub.cong file and add the following entries

title Enterprise Linux (2.6.18-194.el5PAE)
        root (hd0,7)
        kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/ rhgb quiet
        initrd /boot/initrd-2.6.18-194.el5PAE.img
title Enterprise Linux-base (2.6.18-194.el5)
        root (hd0,7)
        kernel /boot/vmlinuz-2.6.18-194.el5 ro root=LABEL=/ rhgb quiet
        initrd /boot/initrd-2.6.18-194.el5.img

After this restart the machine and now you will see OEL , Windows 7 and Redhat in the grub boot screen.

Saturday, June 18, 2011

Changing the SOA Suite database Username etc in 10g

Changing the SOA Suite database Username etc in 10g

SOA 10g by default installs to orabpel and oraesb user. In a testing environment you may want to create more then one SOA 10g instance in one db. This procedure explains how to do that

1. First run the irca to create the necessary schemas.

./irca.sh all "xxxx.xxx.oracle.com 1521 xxx.xxx.oracle.com" welcome1 -overwrite ORABPEL welcome1  ORAESB welcome1 ORAWSM welcome1

Then run irca gaian with a different username's for example ORABPEL_OracleAS_3 , ORAESB_OracleAS_3 and ORAWSM_OracleAS_3.

./irca.sh all "xxx.xxx.oracle.com 1521 xxx.xxx.oracle.com" welcome1 -overwrite ORABPEL_OracleAS_3 welcome1  ORAESB_OracleAS_3 welcome1 ORAWSM_OracleAS_3 welcome1

2. Install the SOA Suite normally. SOA Suite 10g by default install in the orabpel and oraesb schema's only.

3. Now open the ${SOA_HOME}\j2ee\home\config\data-sources.xml file ,

and change the username and password etc for the data-sources. You can also use the EM Application Server control
for this purpose.


4.  From the ${SOA_HOME}\bpel\install\extensions directory, copy the following files to ${SOA_HOME}\bpel\domains\default\deploy:

    bpel_TaskActionHandler_1.0.jar
    bpel_TaskManager_1.0.jar

5. Connect to the oraesb schema  and run the following sql script ,

SQL> spool params.sql
SQL> SELECT 'INSERT INTO esb_parameter VALUES (''' || param_name || ''', ''' || param_value || ''');' FROM esb_parameter;
SQL> spool off
SQL> quit

Take the params.sql file and run it against the schema ORAESB_OracleAS_3.


6. Now apply the latest SOA 10g patch set ,
and run the schema upgrade scripts on the new schemans i.e ORABPEL_OracleAS_3 , ORAESB_OracleAS_3

If your SOA Suite is 10.1.3.3 or later, you will have to also run an additional script that updates the BPEL schema. This is documented in the install guides for each version, but in summary, the script is:

    ${SOA_HOME}\bpel\system\database\scripts\upgrade_10131_10135_oracle.sql


7. For OWSM open the file ,
${SOA_HOME}\owsm\bin\install_properties

Scroll down to the section that contains the install.db.* properties. After backing up the existing settings, modify them for your environment:

    install.db.type=oracle
    install.db.driver.type=thin
    install.db.host=localhost
    install.db.port=1521
    install.db.name=xe
    install.db.userid=oraowsm_OracleAS_1
    install.db.password=oraowsm

8. Run the command ,

${SOA_HOME}\owsm\bin\wsmadmin.bat install

9. Restart all the oc4j containers and check whether every thing is working fine or not.

Saturday, June 11, 2011

How to Add Shared Folders in VmWare Player

First Install the VMWare tools on the Guest OS.

With out the vmware tools the sharing feature may not work.

Launch VMWare Player. Confirm that the virtual machine that you want to modify the settings for it powered off, then right click it and click "Edit VM."

Click the "Options" tab on the top of the window, then click the "Shared Folders" category below.

Click the radio button labeled "Enabled." And add the directories you want to share.

Thursday, June 09, 2011

Search Oracle Forums

http://myforums.oracle.com/jive3/forum.jspa?forumID=3150 (integration_ww@oracle.com)
http://myforums.oracle.com/jive3/forum.jspa?forumID=3209 (helpwls_ww@oracle.com)
http://myforums.oracle.com/jive3/forum.jspa?forumID=3213 OC4J (helpj2ee_us@oracle.com)
http://myforums.oracle.com/jive3/forum.jspa?forumID=3208 Oracle Application Server (helpias_us@oracle.com)

SOA PS3 Purging Scripts With the Debug Option

spool soainfra_purge_n2_output3.txt
set serveroutput on
set pages 1000
ALTER PROCEDURE debug_purge  COMPILE PLSQL_CCFLAGS = 'debug_on:TRUE' REUSE SETTINGS;
ALTER PROCEDURE log_info COMPILE PLSQL_CCFLAGS = 'debug_on:TRUE' REUSE SETTINGS;

DECLARE

   MAX_CREATION_DATE timestamp;
   MIN_CREATION_DATE timestamp;
   batch_size integer;
   max_runtime integer;
   retention_period timestamp;

BEGIN

   MIN_CREATION_DATE := to_timestamp('2011-02-01 10:00:00','YYYY-MM-DD HH24:MI:SS');
  MAX_CREATION_DATE := to_timestamp('2011-07-08 09:00:00','YYYY-MM-DD HH24:MI:SS');
  max_runtime := 60;
   retention_period := to_timestamp('2011-07-08','YYYY-MM-DD');
    --batch_size := 10000;
    batch_size := 100000;
      soa.delete_instances(
      min_creation_date => MIN_CREATION_DATE,
      max_creation_date => MAX_CREATION_DATE,
      batch_size => batch_size,
      max_runtime => max_runtime,
      retention_period => retention_period,
      purge_partitioned_component => false);
   END;
   /

ALTER PROCEDURE debug_purge COMPILE PLSQL_CCFLAGS = 'debug_on:false' REUSE SETTINGS;
ALTER PROCEDURE log_info COMPILE PLSQL_CCFLAGS = 'debug_on:false' REUSE SETTINGS;
spool off

How to add swap space in linux

http://www.thegeekstuff.com/2010/08/how-to-add-swap-space/

 

dd if=/dev/zero of=/extraswap bs=1M count=512
mkswap /extraswap
cp /etc/fstab /etc/fstab.mybackup
Add this line at the end of the file
/extraswap   none   swap   sw   0   0
or
swapon /extraswap

Verify whether the newly created swap area is available for your use.
swapon -s

Tuesday, June 07, 2011

Create RAC Instance using Oracle VM

First Install the Oracle VM Server on a new machine.

On Some other linux machine (or an vmware instance) install the Oracle VM manager.

Extract the Oracle VM manager zip file and mount the iso file on a unix machine.
Install the Oracle VM manager by running the command ,
sh runInstaller.sh 

The Oracle VM manager asks a series of questions like db connect info etc
after this it will install Oracle XE and OC4J etc. If you have an existing DB you can use that
database instead of XE.

On the Oracle VM Server , create a HDD partion say about 100GB in /dev/sdb6
(ensure that you have atleast you have 80GB partition else the RAC install will fail)

and run the following commands to create the storage repository ,

mkfs.ext3 /dev/sdb6
/opt/ovs-agent-2.3/utils/repos.py -n /dev/sdb6
/opt/ovs-agent-2.3/utils/repos.py -i
/opt/ovs-agent-2.3/utils/repos.py -l
/opt/ovs-agent-2.3/utils/repos.py -r 90ab429e-a00f-488d-9680-91dd878e3f48

Output of the above commands ,

[root@oraclevm ~]# /opt/ovs-agent-2.3/utils/repos.py -n /dev/sdb6
[ NEW ] 90ab429e-a00f-488d-9680-91dd878e3f48 => /dev/sdb6
[root@oraclevm ~]# /opt/ovs-agent-2.3/utils/repos.py -i
*** Storage repositories initialized.
[root@oraclevm ~]# /opt/ovs-agent-2.3/utils/repos.py -l
[   ] 90ab429e-a00f-488d-9680-91dd878e3f48 => /dev/sdb6
[root@oraclevm ~]# /opt/ovs-agent-2.3/utils/repos.py -r 90ab429e-a00f-488d-9680-91dd878e3f48
[ R ] 90ab429e-a00f-488d-9680-91dd878e3f48 => /dev/sdb6

In the VM manager create a server pool and assign the Oracle VM Server to this pool.

Copy the RAC Vmware template file to /OVS/seed_pool and extract the file ,

After this run the following commands ,

# cd /OVS/seed_pool
# unzip -q /tmp/OVM_EL5U5_X86_11107RAC_PVM.zip
# tar xzf OVM_EL5U5_X86_11107RAC_PVM.tgz (or X86_64 for the 64-bit version)
(You may now delete the ZIP & TGZ files)
This will create the following, e.g.on 32bit:
/OVS/seed_pool/OVM_EL5U5_X86_11107RAC_PVM (or X86_64 for the 64-bit version)
|- System.img (OS image file)
|- Oracle11107RAC_x86-xvdb.img (database software image file)
|- vm.cfg (VM configuration file)
|- README
|- These PDF documents
|- lsinventory-sample.crs-32bit lsinventory-sample.rac-asm-32bit (or 64bit)

Now create 5 shared disks i.e say ASM1 to ASM5 each of 2GB.

Import the template using Oracle VM manager

Create 2 Virtual Machines using the imported template

Add the shared disks in the exact same order to both VMs.

Power ON both virtual machines

Complete the boot interview questions like private IP , public IP , VIP IP and hostnames etc.
For the private IP use 10.10.10.201 ,

If you have only one network card then use eth0:1 for the private interface.


Now Install Oracle RAC
First login as root user , (password is ovsroot) and run the command ,
cd /u01/clone/buildcluster.sh

This will install the RAC software.

For the command line tools , please download the following rpm’s

wget http://public-yum.oracle.com/repo/EnterpriseLinux/EL5/oracle_addons/x86_64/ovmcli-2.2-9.el5.noarch.rpm

wget http://public-yum.oracle.com/repo/EnterpriseLinux/EL5/addons/x86_64/python-ZSI-2.1-a1.el5.noarch.rpm

Run the command to configure the ovm client

ovm config

run the command ,

ovm -u admin -p welcome1 vm ls
Name    Size(MB) Mem  VCPUs Status  Server_Pool
fmwrac1 29086    1400 1     Running oraclevm1_test
fmwrac2 29086    1400 1     Running oraclevm1_test