Monday, July 22, 2013

Weblogic Installation

Simple Weblogic Installation

Environment Details:
OS: Linux Server 5.8 64bit
Version: Weblogic Server 10.3.6
Installation location: /u01/app/oracle/product/fmw
User: oraem(We can have any user)

Steps to be executed as oraem user:

Step 1: First install 64 bit java of the desired version, here in our installation we are using Java 6u32 64 bit

execute the command ./jdk-6u32-linux-x64.bin, it will install the java in the particular directory 




Step 2: Invoke the command java -jar -d64 wls1036_generic.jar (here -d64 option installs 64bit version of weblogic)


Step 3: Click Next on the "Welcome Screen"


Step 4: Give the complete location where we are going to install the weblogic server and click Next



Step 5: In these screen the installer asks for the Oracle Support username password, which can be skipped by un checking the box and confirming to remained uninformed of critical issues by clicking Yes. Then click Next


Step 6: Click Custom and click Next


Step 7: This screen shows what all components we are going to install. Click Next



Step 8: Select the Java Home which we installed and uncheck the other java which was mentioned, and click Next


Step 9: Choose the Product Installation Directory, we can keep them as default and click Next


Step 10: Review the Installation Summary and click Next



Step 11: Installation Progress Screen



Step 12: The installation is over, uncheck the Run Quickstart box and click Done.




Note: After the installation is over the base domain can be created by invoking the config.sh script from location /u01/app/oracle/product/fmw/wlserver_10.3/common/bin.


Installation Issues/Error:

1. Sometime if there is a space issue on the server we may get the below mentioned error 
Fatal error encountered during self-extraction.[No space left on device]


To Resolve this we need to find a mount point where there is space available and then use the -Djava.io.tmpdiroption while doing the installation

[oraem@Linux1 stage]$ java -d64 -Djava.io.tmpdir=/u03/stage/temp -jar wls1036_generic.jar


2. In windows machine the -d64 option doesn't work and we may get the error: Could not create the Java virtual machine.

Simply invoke the installer by omitting that option(-d64)



Friday, July 12, 2013

Public Yum Configuration | Oracle Linux

Public Yum Configuration.

Operating System: Oracle Linux 5.8

Install the yum repos as follows:

Step 1. Login as a root user to the linux box and go to the location /etc/yum.repos.d

[root@host1 ~]# cd /etc/yum.repos.d/
[root@host1 yum.repos.d]# 

Step 2. Get the public yum file using the below mentioned command

[root@host1 yum.repos.d]#  wget http://public-yum.oracle.com/public-yum-el5.repo

Step 3. Open the file using a text editor (here I am using vi editor).

[root@host1 yum.repos.d]# vi /etc/yum.repos.d/public-yum-el5.repo

Step 4. Search for the below mentioned parameters 

ol5_u8_base and el5_addons and set the value for "enabled=1"





Step 5. This step is optional.

Type the following commands in a shell to check that your yum repository is configured correctly:

[root@host1 ~]#sudo yum repolist

The output should look like this:

el5_addons              |  951 B     00:00    
ol5_u8_base             |  1.1 kB    00:00    
repo id       repo name                             status
base          Red Hat Linux - Base                  enabled:3,024
el5_addons    Enterprise Linux 5 - x86_64 - addons  enabled:   93
ol5_u8_base   Oracle Linux 5 - U8 - x86_64 - base   enabled:4,551

Make sure that both the el5_addons and ol5_u8_base repos are listed. The list of repos can be different depending on the Linux version and current user's configuration of yum.

Thursday, July 11, 2013

Database auto start on server reboot: Solaris

The objective of this script is to capture whatever databases and listeners were running prior to server reboot and stop and start them automatically.

Environment:
OS: Solaris

Note: We are placing all the scripts at location /u01/app/oracle/scripts

Version:
Applicable to Oracle database version 9i, 10g, 11g

Steps to be executed as oracle user:

Step 1. Create the scripts 1-7 and keep them at location /u01/app/oracle/scripts
(once you have created the scripts go the directory /u01/app/oracle/scripts and execute the command chmod a+x *.sh)

Step 2. Create a crontab job to run the Script logcapture.sh at a particular time stamp. This script will capture the listener and database running at that particular time.

Command for crontab Entry: 

[oracle@host1 ~]$ export EDITOR=vi
[oracle@host1 ~]$ crontab -e 

and add the lines mentioned below from the oracle userid.
-- we are capturing the logs every night at 8 PM

0 20 * * * sh /u01/app/oracle/scripts/logcapture.sh >> /dev/null 2>&1

save it

Steps to be executed as root user:

Step 3. create a file with the name dbora at location /etc/init.d   (Content are given below)

Step 4. Change the Permission of the dbora file
chmod 775 /etc/init.d/dbora

Step 5. create links to this script to be executed under different run levels using given commands:

ln -s /etc/init.d/dbora /etc/rc0.d/K01dbora
ln -s /etc/init.d/dbora /etc/rc1.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc2.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora

Scripts:

Script 1. startdb.sh
#!/bin/bash
# SCRIPT: startdb.sh
# PURPOSE: Automatically starts all the databases which were running prior to server reboot.
# Owner: Samrat
FILENAME=/u01/app/oracle/scripts/dbrunning.log
export FILENAME
cat $FILENAME | while read LINE
do
ORACLE_SID=${LINE}
export ORACLE_SID
echo $ORACLE_SID
ORACLE_HOME=`cat /var/opt/oracle/oratab|grep $ORACLE_SID:|cut -f2 -d':'`
export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH
export PATH
sqlplus -S "/as sysdba" @/u01/app/oracle/scripts/startdb.sql
done

Script 2. stopdb.sh
#!/bin/bash
# SCRIPT: stopdb.sh
# PURPOSE: Automatically stops all the databases which were running prior to server reboot.
# Owner: Samrat
FILENAME=/u01/app/oracle/scripts/dbrunning.log
export FILENAME
cat $FILENAME | while read LINE
do
ORACLE_SID=${LINE}
export ORACLE_SID
echo $ORACLE_SID
ORACLE_HOME=`cat /var/opt/oracle/oratab|grep $ORACLE_SID:|cut -f2 -d':'`
export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH
export PATH
sqlplus -S "/as sysdba" @/u01/app/oracle/scripts/stopdb.sql
done

Script 3. listenerstart.sh
#!/bin/bash
# SCRIPT: listenerstart.sh
# PURPOSE: Automatically starts all the listeners which were running prior to server reboot.
# Owner: Samrat
FILENAME=/u01/app/oracle/scripts/lsnrup.log
cat $FILENAME | while read LINE
do
ORACLE_HOME=`echo $LINE | cut -f1 -d' '`
export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH
export PATH
LISTENER=`echo $LINE|cut -f2 -d' '`
export LISTENER
echo $LISTENER
lsnrctl start $LISTENER
done

Script 4. listenerstop.sh
#!/bin/bash
# SCRIPT: listenerstop.sh
# PURPOSE: Automatically stops all the listeners which were running prior to server reboot.
# Owner: Samrat
FILENAME=/u01/app/oracle/scripts/lsnrup.log
cat $FILENAME | while read LINE
do
ORACLE_HOME=`echo $LINE | cut -f1 -d' '`
export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH
export PATH
LISTENER=`echo $LINE|cut -f2 -d' '`
export LISTENER
echo $LISTENER
lsnrctl stop $LISTENER
done

Script 5. startdb.sql
startup;
select * from global_name;
exit;

Script 6. stopdb.sql
select * from global_name;
shutdown immediate;
exit;

Script 7. logcapture.sh (add this script to run as crontab job)
/usr/ucb/ps -wwxaa| grep smon| grep -v grep | awk '{print $5}' | cut -f3 -d'_' > /u01/app/oracle/scripts/dbrunning.log

/usr/ucb/ps -wwxaa| grep tnslsnr| grep -v grep | awk '{print $5" " $6}' | sed 's/\/bin\/tnslsnr//' |grep -v tnslsnr > /u01/app/oracle/scripts/lsnrup.log

Script. dbora

#!/bin/bash
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
# Owner: Samrat
# Set ORA_OWNER to the user id of the owner of the oracle software

ORA_OWNER=oracle

case "$1" in
'start')
                su - $ORA_OWNER -c /u01/app/oracle/scripts/startdb.sh > /u01/app/oracle/scripts/startup_db.log 2>&1
su - $ORA_OWNER -c /u01/app/oracle/scripts/listenerstart.sh > /u01/app/oracle/scripts/startup_lsnr.log 2>&1
                touch /var/lock/subsys/dbora
                ;;
'stop')
                su - $ORA_OWNER -c /u01/app/oracle/scripts/stopdb.sh > /u01/app/oracle/scripts/shutdown_db.log 2>&1
su - $ORA_OWNER -c /u01/app/oracle/scripts/listenerstop.sh > /u01/app/oracle/scripts/shutdown_lsnr.log 2>&1
                rm -f /var/lock/subsys/dbora
                ;;
esac

Database auto start on server reboot: Linux

The objective of this script is to capture whatever databases and listeners were running prior to server reboot and stop and start them automatically.

Environment:
OS: Linux Server

Note: We are placing all the scripts at location /u01/app/oracle/scripts

Version:
Applicable to Oracle database version 9i, 10g, 11g

Steps to be executed as oracle user:

Step 1. Create the scripts 1-7 and keep them at location /u01/app/oracle/scripts
(once you have created the scripts go the directory /u01/app/oracle/scripts and execute the command chmod a+x *.sh)

Step 2. Create a crontab job to run the Script logcapture.sh at a particular time stamp.

Command for crontab Entry: 

[oracle@host1 ~]$ export EDITOR=vi
[oracle@host1 ~]$ crontab -e 

and add the lines mentioned below from the oracle userid.
-- we are capturing the logs every night at 8 PM

0 20 * * * sh /u01/app/oracle/scripts/logcapture.sh >> /dev/null 2>&1

save it

Steps to be executed as root user:

Step 3. create a file with the name dbora at location /etc/init.d   (Content are given below)

Step 4. Change the Permission of the dbora file
chmod 775 /etc/init.d/dbora

Step 5. create links to this script to be executed under different run levels using given commands:

ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc1.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc2.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc4.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc6.d/K01dbora

Step 6. Add this to chkconfig and verify the same.

chkconfig –-add dbora

chkconfig –-list dbora (to verify its added to the run levels)


Scripts:

Script 1. startdb.sh
#!/bin/bash
# SCRIPT: startdb.sh
# PURPOSE: Automatically starts all the databases which were running prior to server reboot.
# Owner: Samrat
FILENAME=/u01/app/oracle/scripts/dbrunning.log
cat $FILENAME | while read LINE
do
ORACLE_SID=$LINE
export ORACLE_SID
echo $ORACLE_SID
ORACLE_HOME=`cat /etc/oratab|grep ^$ORACLE_SID:|cut -f2 -d':'`
export ORACLE_HOME
export PATH=$ORACLE_HOME/bin:$PATH
sqlplus -S "/as sysdba" @/u01/app/oracle/scripts/startdb.sql
done

Script 2. stopdb.sh
#!/bin/bash
# SCRIPT: stopdb.sh
# PURPOSE: Automatically stops all the databases which were running prior to server reboot.
# Owner: Samrat
FILENAME=/u01/app/oracle/scripts/dbrunning.log
cat $FILENAME | while read LINE
do
ORACLE_SID=$LINE
export ORACLE_SID
echo $ORACLE_SID
ORACLE_HOME=`cat /etc/oratab|grep ^$ORACLE_SID:|cut -f2 -d':'`
export ORACLE_HOME
export PATH=$ORACLE_HOME/bin:$PATH
sqlplus -S "/as sysdba" @/u01/app/oracle/scripts/stopdb.sql
done

Script 3. listenerstart.sh
#!/bin/bash
# SCRIPT: listenerstart.sh
# PURPOSE: Automatically starts all the listeners which were running prior to server reboot.
# Owner: Samrat
FILENAME=/u01/app/oracle/scripts/lsnrup.log
cat $FILENAME | while read LINE
do
ORACLE_HOME=`echo $LINE | cut -f1 -d' '`
export ORACLE_HOME
export PATH=$ORACLE_HOME/bin:$PATH
LISTENER=`echo $LINE|cut -f2 -d' '`
export LISTENER
echo $LISTENER
lsnrctl start $LISTENER
done

Script 4. listenerstop.sh
#!/bin/bash
# SCRIPT: listenerstop.sh
# PURPOSE: Automatically stops all the listeners which were running prior to server reboot.
# Owner: Samrat
FILENAME=/u01/app/oracle/scripts/lsnrup.log
cat $FILENAME | while read LINE
do
ORACLE_HOME=`echo $LINE | cut -f1 -d' '`
export ORACLE_HOME
export PATH=$ORACLE_HOME/bin:$PATH
LISTENER=`echo $LINE|cut -f2 -d' '`
export LISTENER
echo $LISTENER
lsnrctl stop $LISTENER
done

Script 5. startdb.sql
startup;
select * from global_name;
exit;

Script 6. stopdb.sql
select * from global_name;
shutdown immediate;
exit;

Script 7. logcapture.sh (add this script to run as crontab job)
ps aux | awk '{print $11}' | grep pmon | cut -f3 -d'_' > /u01/app/oracle/scripts/dbrunning.log
ps aux | awk '{print $11" " $12}' |grep -i tns |grep -v grep |sed 's/\/bin\/tnslsnr//' > /u01/app/oracle/scripts/lsnrup.log

Script. dbora

#!/bin/bash
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
# Owner: Samrat
# Set ORA_OWNER to the user id of the owner of the oracle software

ORA_OWNER=oracle

case "$1" in
'start')
                su - $ORA_OWNER -c /u01/app/oracle/scripts/startdb.sh > /u01/app/oracle/scripts/startup_db.log 2>&1
su - $ORA_OWNER -c /u01/app/oracle/scripts/listenerstart.sh > /u01/app/oracle/scripts/startup_lsnr.log 2>&1
                touch /var/lock/subsys/dbora
                ;;
'stop')
                su - $ORA_OWNER -c /u01/app/oracle/scripts/stopdb.sh > /u01/app/oracle/scripts/shutdown_db.log 2>&1
su - $ORA_OWNER -c /u01/app/oracle/scripts/listenerstop.sh > /u01/app/oracle/scripts/shutdown_lsnr.log 2>&1
                rm -f /var/lock/subsys/dbora
                ;;

esac

Weblogic Clustering

If you have already installed Oracle Weblogic, please follow the below steps to make a cluster else use this link Weblogic Installation to install weblogic first on both the servers.

Environment:

We have two linux servers: host1.com & host2.com
Installation Requirement: One Admin Server on Host1.com & one Managed Server in cluster in Host1.com & Host2.com

Weblogic Software Version:

10.3.6

We need to create a domain in the first server and use the pack/unpack command to have it in the second server.


Step 1. Go to the location $MW_HOME/wlserver_10.3/common/bin (in host1.com)


Step 2. Execute config.sh file to create a domain

        ./config.sh


Step 3. You will get a window similar to below to create a domain


Select Create a new Weblogic doamin and click Next



Select Domain Source and click Next


Give a name to your weblogic Domain and specify the location for domain



Provide Administrator username & Password and click Next



Verify the Java Location & click Next



Check box Administration Server & Managed Server, Clusters and Machines and click Next




Give the name of the admin Server and Listen Port Address (In our case its AdminServer & 7001)



Provide the names of Managed Servers, since its in cluster, we need to add two Managed Servers
In our case its ManagedServer_1 & ManagedServer_2, provide the hostname in the respective Listen address space and Provide the Listen Port, we 7003 for both.



Add a cluster with unicast messaging mode




Assign both the Managed Server to the cluster, to configure it in cluster.





Choose Unix Machine and provide the Name(Machine Name), Hostname and port



Since our configuration is Admin Server & Managed Server in first Host & a Managed Server in Cluster in Second Host. Assign the same accordingly.




Verify the details & click Create.









The domain is created.


[oraem@host1 bin]$ pwd
/u01/app/oracle/product/fmw/wlserver_10.3/common/bin

Use the pack command

[oraem@host1 bin]$ ./pack.sh -managed=true -domain=/u01/app/oracle/product/fmw/user_projects/domains/base_domain -template=base_domain.jar -template_name=base_domain

Output of the above command=>
<< read domain from "/u01/app/oracle/product/fmw/user_projects/domains/base_domain"
>>  succeed: read domain from "/u01/app/oracle/product/fmw/user_projects/domains/base_domain"
<< set config option Managed to "true"
>>  succeed: set config option Managed to "true"
<< write template to "/u01/app/oracle/product/fmw/wlserver_10.3/common/bin/base_domain.jar"
....................................................................................................
>>  succeed: write template to "/u01/app/oracle/product/fmw/wlserver_10.3/common/bin/base_domain.jar"
<< close template
>>  succeed: close template


Now copy this template base_domain.jar from server host1.com to server host2.com

[oraem@host1 bin]$ scp base_domain.jar oraem@host2:/u01/app/oracle/product/fmw/wlserver_10.3/common/bin


[oraem@Host2 bin]$ pwd
/u01/app/oracle/product/fmw/wlserver_10.3/common/bin

Use the unpack command now

[oraem@Host2 bin]$ ./unpack.sh -domain=/u01/app/oracle/product/fmw/user_projects/domains/base_domain -template=base_domain.jar

Output of the above Command=>
<< read template from "/u01/app/oracle/product/fmw/wlserver_10.3/common/bin/base_domain.jar"
>>  succeed: read template from "/u01/app/oracle/product/fmw/wlserver_10.3/common/bin/base_domain.jar"
<< set config option DomainName to "base_domain"
>>  succeed: set config option DomainName to "base_domain"
<< write Domain to "/u01/app/oracle/product/fmw/user_projects/domains/base_domain"
...............................................................................................
>>  succeed: write Domain to "/u01/app/oracle/product/fmw/user_projects/domains/base_domain"
<< close template
>>  succeed: close template


Now Modify the nodemanager.properties file at location /u01/app/oracle/product/fmw/wlserver_10.3/common/nodemanager on both the servers
Change the parameter StartScriptEnabled=true

Start the Node manager on both the servers.
[oraem@Host1 ]$ cd /u01/app/oracle/product/fmw/wlserver_10.3/server/bin

[oraem@Host1 bin]$ nohup ./startNodeManager.sh >> nodemgr.log &

[oraem@Host2 ]$ cd /u01/app/oracle/product/fmw/wlserver_10.3/server/bin

[oraem@Host2 bin]$ nohup ./startNodeManager.sh >> nodemgr.log &

Start the Admin Server

[oraem@Host1 ]$ cd /u01/app/oracle/product/fmw/user_projects/domains/base_domain/bin

[oraem@Host1 bin]$ nohup ./startWebLogic.sh >> weblogic.log & 

From the console page start the Managed Server

Environment--> Server--> Control--> (Select the Managed Servers) --> Start