Automating Oracle Weblogic Server installation through shell script

Automation always saves your considerable time. Especially when you have to follow the similar step for hundreds of machine, automated scripts and tools have always been a great weapon for system administrators.Today I spent considerable time to setup Weblogic Server 10.3.6 on my CentOS 7.0 machine through shell script. This unattended script uses autoexpect rather than silent.xml or WLST as suggested by Oracle. Let me share the steps I followed to deploy the Weblogic Server:

Ensure you have the following software in place downloaded from Oracle Website.We can’t use wget for this as it requires Oracle Login for downloading these pieces of software.

Links for Software Downloads:

a. Download jdk-7u67-linux-i586.gz from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
b. Download wls1036_dev.zip from http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.html

Once you download the above software, create a directory called /softwaretmp/ and download the above software into this directory:

#mkdir /softwaretmp/

#cd /softwaretmp/

Weblogg

2. Create an empty file called prepare.sh and paste the following shell script (shown below):

#!/bin/bash
echo “Checking if WebLogic Server is already runing. If its running, stopping it and reinstalling it from scratch”
pkill -9 java
pkill -9 Weblogic
rm -fr /u01/oracle/wlsdomains/base_domain
rm -fr /u01/oracle/fmw/wlserver_10.3
rm -fr /u01/jdk/jdk7
pkill -9 java
echo “Initializing the Installation”
groupadd orainstall
useradd -g orainstall oracle
mkdir -p /u01/jdk
cd /u01/jdk
tar -zxvf /softwaretmp/jdk-7u67-linux-i586.gz
ln -s jdk1.7.0_67 jdk7
mkdir -p /u01/oracle/fmw/wlserver_10.3
cp -rf /softwaretmp/wls1036_dev.zip /u01/oracle/fmw/wlserver_10.3/
echo ”
MW_HOME=/u01/oracle/fmw/wlserver_10.3; export MW_HOME
JAVA_HOME=/u01/jdk/jdk7; export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH; export PATH
” >> ~/.bash_profile
cd ~
. ./.bash_profile
cd /u01/oracle/fmw/wlserver_10.3
unzip wls1036_dev.zip
./configure.sh
. $MW_HOME/wlserver/server/bin/setWLSEnv.sh
mkdir -p /u01/oracle/wlsdomains
cp -rf /softwaretmp/script.exp /u01/oracle/fmw/wlserver_10.3/wlserver/common/bin/
cd /u01/oracle/fmw/wlserver_10.3/wlserver/common/bin
./script.exp
echo ” Expect Script is well run”
cd /u01/oracle/wlsdomains/base_domain/
mkdir -p servers/AdminServer/security
mkdir -p servers/managedserver_1/security
cd servers/AdminServer/security
echo
“username=weblogic
password=Oracle9ias
” >> boot.properties
cd /u01/oracle/wlsdomains/base_domain/servers/managedserver_1/security
echo
“username=weblogic
password=Oracle9ias
” >> boot.properties
echo ” Weblogic Server 10.3.6 Configuration is all done !!”
echo “Starting the Weblogic Server”
cd /softwaretmp/
./startweblogic.sh
./startManagedServer.sh

3. You need to add two more scripts to the /softwaretmp directory:

Create a empty file called startweblogic.sh and paste the below content:

#!/usr/bin/expect -f
cd /u01/oracle/wlsdomains/base_domain/bin/
spawn ./startWebLogic.sh
expect “Enter username to boot WebLogic server: ”
send “weblogic\r”
expect “$ ”
expect “Enter password to boot WebLogic server: ”
send “Oracle9ias\r”
expect “$ ”
send “exit\r”

Also, create another empty file called startManagedServer.sh and paste the below lines:

#!/usr/bin/expect -f
cd /u01/oracle/wlsdomains/base_domain/bin/
spawn ./startManagedWebLogic.sh managedserver_1
expect “Enter username to boot WebLogic server: ”
send “weblogic\r”
expect “$ ”
expect “Enter password to boot WebLogic server: ”
send “Oracle9ias\r”
expect “$ ”
send “exit\r”

Save the file.

4. Now comes the important step. You need to create script.exp file through series of steps. You can always create script.exp through the following steps:

a. Ensure that the autoexpect software through the following command:

#yum install autoexpect

b. Start the autoexpect tool through the following command:

#autoexpect -s

It will output that autoexpect has already initiated and will be saved under script.exp

c. Now run the following command under /u01/oracle/fmw/wlserver_10.3/wlserver/common/bin

#cd /u01/oracle/fmw/wlserver_10.3/wlserver/common/bin

#./config.sh

Follow the general steps for selecting the right options as per your infrastructure.

Once completed, ensure you run the following command:

#exit

autoexpect stopped.

Once you have completed the above steps, a script.exp gets created which has to be copied to /softwaretmp directory.

Still finding difficulty? Post your questions at http://collabnix.com/forum

0
0
  • rajiv

    Hi ,

    Nice article. Really helps but where is script.exp and what does it contain?

  • Someone essentially help to make seriously posts I would state. This is the first time I frequented your website page and thus far? I amazed with the research you made to make this particular publish incredible. Great job!

  • Just want to say your article is as astonishing. The clearness in your publish is simply nice and i could think you are a professional in this subject. Fine together with your permission allow me to grab your RSS feed to stay up to date with coming near near post. Thanks a million and please continue the enjoyable work.

  • You need to take part in a contest for among the finest blogs on the web. I’ll suggest this web site!

  • Very nice post. I simply stumbled upon your weblog and wished to mention that I have really enjoyed surfing around your blog posts. In any case I will be subscribing on your feed and I’m hoping you write once more soon!

  • What’s up, every time i used to check webpage posts here in the early hours in the daylight, as i like to learn more and more.|

  • Good writing skills here, I like it 🙂

  • I am sure this piece of writing has touched all the internet users, its really
    really nice component of writing on strengthening new website.

  • Really good site, thanks you so much for your effort in written the post