X

News, tips, partners, and perspectives for the Oracle Solaris operating system

DevOps Hands on Lab - Installing Oracle WebLogic Server in a Solaris Zone

As one of the Hands on Lab sessions at Oracle OpenWorld this year participants ran through the install of a simple DevOps toolchain, where at the end they had a fully functioning toolchain from Netbeans with a Git repository, through Jenkins and Maven, the automatically deployed their sample application onto a WebLogic instance every time they committed and pushed a change to Git. It looked like this:

Because the session at two hours was pretty long I've decided to split the Hands on Lab out over several blog posts. Also because the VirtualBox image with Oracle Solaris 11.3 in it had a bunch of things it that were prebuilt to save time. In these blog posts we'll walk through the full install.

This blog post will cover the first step they made: Installing and configuring Oracle WebLogic Server inside a Solaris Zone.

Prework

In order to use this Hands on Lab you will need to have a Oracle Solaris 11.3 image installed on a system somewhere, either bare metal or inside something like VirtualBox. Using VirtualBox and the Oracle Solaris 11.3 VM Template prebuilt image might be the easiest option. You can download that and then import it into your local VirtualBox install.

If you want to run Firefox from the Global Zone, you will also need to install the desktop environment by installing the group/system/solaris-desktop package and this will pull in all the necessary packages. To do this as root simply run:

# pkg install solaris-desktop

If you're using the VirtualBox VM Template mentioned above this should already be installed. If not it's easy to add.

The other element you need to have is a local IPS repository. This will be necessary for both installing Solaris Zones as well as certain additional packages we need like the JDK 8 and Git. If you don't have a repository up and running you could for example create another VirtualBox image, install the full IPS repository and then configure it according to the Oracle Solaris 11.3 documentation.

A final note to make is around networking, IP addresses and if you're using DHCP or not are very dependent on your local situation. These docs will stay consistent with the situation the lab was set up on inside the local VirtualBox install here but this can and will of course vary. So take note of the IP addresses the host OS (Global Zone) and the zones will get and if you're using DHCP or not. By default Oracle Solaris will use DHCP for both the Global Zone as well as the other zones. If you use VirtualBox and choose NAT as your network connection, the network will remain contained inside the instance and the IP addresses will be on the 10.0.2.0/24 network.

1. Installing the Zone

Before we can get to installing WebLogic Server we will first need to install a Solaris Zone to run it in called wls_zone. We do this to simulate it running on a different server, plus as Solaris Zones are a form of OS Container it allows you to fully isolate the WebLogic Server installation.

First configure the zone:

root@solaris:~# zonecfg -z wls_zone
Use 'create' to begin configuring a new zone.
zonecfg:wls_zone> create
create: Using system default template 'SYSdefault'
zonecfg:wls_zone> set autoboot=true
zonecfg:wls_zone> set zonepath=/zones/wls_zone
zonecfg:wls_zone> verify
zonecfg:wls_zone> commit
zonecfg:wls_zone> exit

Note: We've set the autoboot to true to make the zone automatically boot every time you reboot the system. If the zone is something that you'll only create or boot when needed you'd leave this off.

Then install the zone:

root@solaris:~# zoneadm -z wls_zone install
The following ZFS file system(s) have been created:
    rpool/zones
    rpool/zones/wls_zone

...

Log saved in non-global zone as /zones/wls_zone/root/var/log/zones/zoneadm.20170911T063323Z.wls_zone.install

Note: The output above is cut down for brevity. I'll do this in each case where the output is very long.

Then boot the zone and run through the initial configuration on the zone console:

root@solaris:~# zoneadm -z wls_zone boot; zlogin -C wls_zone
[Connected to zone 'wls_zone' console]
Loading smf(5) service descriptions: 127/127

This will then go into a text-based configuration screen where you fill in things like hostname, root password, and others. Once this is done the screen will come back to the terminal and look like this:

SC profile successfully generated as:
/etc/svc/profile/sysconfig/sysconfig-20170911-064305/sc_profile.xml

Exiting System Configuration Tool. Log is available at:
/system/volatile/sysconfig/sysconfig.log.4705
Hostname: wls_zone

wls_zone console login:

At this point the zone is installed and up and running. To break out of the console use ~. and this should bring you back to the terminal in the Global Zone. If you're root in the Global Zone you can very easily become root or any other user in a zone by using zlogin wls_zone. This will give you a shell (as root) in the zone which you can run your commands as normal.

2. Install WebLogic Server Inside the Zone

To aid with the install of WebLogic Server I've used the scripts published on GitHub for installing WebLogic inside a Docker instance. (A special thanks to Monica Riccelli and other for building and maintaining these pages.)

The both the script files in there (create-wls-domain.py and createAndStartEmptyDomain.sh) will be used. In practice the second calls the first.

I've also downloaded the WebLogic binaries from the Oracle Technical Network website. The version I used was the Quick Installer (fmw_12.2.1.2.0_wls_quick_Disk1_1of1.zip) which I guess has now been superseded by version 12.2.1.3.

I've copied all of these into the wls_zone so I can go through the following steps as user root inside the zone. First I need to install a few packages:

root@wls_zone:~# pkg install jdk-8 gnu-sed gnu-coreutils

The gnu-sed and gnu-coreutils packages are added because the scripts mentioned above use the GNU versions of tools like sed. Below we also make sure that /usr/gnu/bin is set in the PATH before /usr/bin and /usr/sbin so the GNU version gets picked up and used.

Then I can create a user oracle and edit it's .profile file to prepare it for WebLogic:

root@solaris:~# zlogin wls_zone
[Connected to zone 'wls_zone' pts/4]
Last login: Tue Sep 12 14:28:36 2017 on pts/2
Oracle Corporation      SunOS 5.11      11.3    July 2017
root@wls_zone:~# mkdir -p /u01 && chmod a+xr /u01
root@wls_zone:~# groupadd oracle && useradd -d /u01/oracle -g oracle -m oracle
80 blocks
root@wls_zone:~# passwd oracle
New Password: 
Re-enter new Password: 
passwd: password successfully changed for oracle
root@wls_zone:~# su - oracle
Oracle Corporation      SunOS 5.11      11.3    July 2017
oracle@wls_zone:~$ vi .profile

The lines I've added to the end of .profile are:

# Added lines for Oracle WebLogic Server
export JAVA_HOME=/usr/java
export ORACLE_HOME=/u01/oracle
export USER_MEM_ARGS="-Djava.security.egd=file:/dev/./urandom"
export SCRIPT_FILE=/u01/oracle/createAndStartEmptyDomain.sh
export PATH=/usr/gnu/bin:/usr/java/bin:/u01/oracle/oracle_common/common/bin:/u01/oracle/wlserver/common/bin:$PATH
export DOMAIN_NAME="${DOMAIN_NAME:-base_domain}"
export DOMAIN_HOME=/u01/oracle/user_projects/domains/${DOMAIN_NAME:-base_domain}
export ADMIN_PORT="${ADMIN_PORT:-7001}"
export ADMIN_USERNAME="${ADMIN_USERNAME:-weblogic}"
export ADMIN_NAME="${ADMIN_NAME:-AdminServer}"
export ADMIN_PASSWORD="${ADMIN_PASSWORD:-"welcome1"}"
export DEBUG_FLAG=true
export PRODUCTION_MODE=dev

These extra environment variables are for WebLogic and are essentially either to correctly set the path and home for various things as well as set certain defaults for the domain creation scripts mentioned above.

The next step is to copy the WebLogic zip file into a directory user oracle can see, and then unzip it. In this case we've copied it into /u01 and the resulting jar file is fmw12.2.1.2.0wls_quick.jar. So log back in as user oracle and run this:

root@wls_zone:~# su - oracle
Oracle Corporation      SunOS 5.11      11.3    July 2017
oracle@wls_zone:~$ pwd
/u01/oracle
oracle@wls_zone:~$ cd ..
oracle@wls_zone:/u01$ $JAVA_HOME/bin/jar xf /u01/fmw_12.2.1.2.0_wls_quick_Disk1_1of1.zip

Now to install WebLogic:

oracle@wls_zone:~$ cd ~
oracle@wls_zone:~$ pwd
/u01/oracle
oracle@wls_zone:~$ $JAVA_HOME/bin/java -jar /u01/fmw_12.2.1.2.0_wls_quick.jar -invPtrLoc /u01/oraInst.loc -jreLoc $JAVA_HOME -ignoreSysPrereqs -force -novalidation ORACLE_HOME=$ORACLE_HOME
Launcher log file is /var/tmp/OraInstall2017-09-11_07-14-18AM/launcher2017-09-11_07-14-18AM.log.
Extracting the installer . . . . . . Done
Checking if CPU speed is above 300 MHz.   Actual 3396 MHz    Passed
Checking swap space: must be greater than 512 MB.   Actual 7532 MB    Passed
Checking if this platform requires a 64-bit JVM.   Actual 64    Passed
Checking temp space: must be greater than 300 MB.   Actual 62776 MB    Passed

...

Percent Complete : 100

The installation of Oracle Fusion Middleware 12c WebLogic and Coherence Developer 12.2.1.2.0 completed successfully.
Logs successfully copied to /u01/oracle/cfgtoollogs/oui.

At this point WebLogic is installed, this means all the binaries are in their correct location and ready to be used. At this point you can copy the create-wls-domain.py and createAndStartEmptyDomain.sh files into /u01/oracle so they can easily be used and everything is in place.

As a side note, all the steps that are related to unpacking and installing the WebLogic files are essentially copied from the Dockerfile on the GitHub page mentioned above. This includes the use of options certain like -ignoreSysPrereqs, -force, and -novalidation. Of course it is your choice if you want to use them or not. Also it is always good to check these Dockerfiles to see if their use has changed.

3. Configuring and Starting WebLogic Server

Now going back to the environment variables we set in .profile, those that start with DOMAIN and ADMIN are most important for the configuration scripts. In short their functions are:

  • DOMAIN_NAME and DOMAIN_HOME set what the newly created WebLogic domain will be called and where it will be installed.
  • ADMIN_USERNAME and ADMIN_PASSWORD as you would expect set the username and password of the administrator of this WebLogic domain.

The base_domain was already created at install but for the Hands on Lab we want to create a new domain. This would for example allow us to set the things like admin username and password if we want (If we'd want to do this we'd set the related environment variables accordingly.

In this example we'll change the domain to abc_domain and use the createAndStartEmptyDomain.sh script to get the domain up and running:

oracle@wls_zone:~$ export DOMAIN_NAME=abc_domain
oracle@wls_zone:~$ export DOMAIN_HOME=/u01/oracle/user_projects/domains/abc_domain
oracle@wls_zone:~$ ./createAndStartEmptyDomain.sh
      ----> 'weblogic' admin password: welcome1

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

domain_name     : [abc_domain]
admin_port      : [7001]
domain_path     : [/u01/oracle/user_projects/domains/abc_domain]
production_mode : [dev]
admin password  : [welcome1]
admin name      : [AdminServer]
admin username  : [weblogic]


Exiting WebLogic Scripting Tool.

...

<Sep 15, 2017, 5:45:39,575 AM PDT> <Notice> <WebLogicServer> <BEA-000331> <Started the WebLogic Server Administration Server "AdminServer" for domain "abc_domain" running in development mode.> 
<Sep 15, 2017, 5:45:39,577 AM PDT> <Notice> <WebLogicServer> <BEA-000360> <The server started in RUNNING mode.> 
<Sep 15, 2017, 5:45:39,608 AM PDT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING.> 

At this point the new domain is up and running and we can check if we can log in as the administrator through the BUI. For this you'll need to find the IP Address of the wls_zone, this can easily be done by running ipadm inside the zone. If you're root in the Global Zone you can use zlogin to run it directly in the context of the zone:

root@solaris:~# zlogin wls_zone ipadm
NAME              CLASS/TYPE STATE        UNDER      ADDR
lo0               loopback   ok           --         --
   lo0/v4         static     ok           --         127.0.0.1/8
   lo0/v6         static     ok           --         ::1/128
net0              ip         ok           --         --
   net0/v4        dhcp       ok           --         10.0.2.16/24
   net0/v6        addrconf   ok           --         fe80::8:20ff:fe35:d14/10

 

To do this start Firefox in Global Zone and point it to http://<wls_zone-IP_address>:7001/console to point it to port 7001 of the wls_zone. Then use weblogic and welcome1 to login:

Which should give you the WebLogic Server admin home page:

At this point the WebLogic Server instance is up and running. Of course you can have a look as the createAndStartEmptyDomain.sh script and alter it to fit your needs. At this point all the regular WebLogic commands will work in the ways you'd expect them to.

This ends the first part of the Hands on Lab, stay tuned for more in the near future.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services