Skip to content

Commit 3bed6a9

Browse files
Hemastutibrunoborges
authored andcommitted
Enhancement : OHS Docker Solution with Docker Data Volume (#175)
Now user can provide custom Oracle Weblogic Proxy Plugin file containing directives as per their weblogic environments . This file will need to be placed in docker data volume , which in turn will be mounted during OHS container creation. In this way, the same OHS docker solution can be used to route applications running on either Weblogic Admin Server or Weblogic cluster or set of individual Managed Servers .
1 parent 5c80afc commit 3bed6a9

File tree

5 files changed

+202
-69
lines changed

5 files changed

+202
-69
lines changed

OracleHTTPServer/README.md

+31-19
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ Before you can build these WebLogic images, you must download the Oracle Server
1313
## How to Build and Run
1414
This project offers sample Dockerfiles for Oracle HTTP Server 12cR2 (12.2.1) in standalone mode. To assist in building the images, you can use the buildDockerImage.sh script. See below for instructions and usage
1515

16-
The **buildDockerImage.sh** script is just a utility shell script that performs MD5 checks and is an easy way for beginners to get started. Expert users are welcome to directly call docker build with their prefered set of parameters.
16+
The **buildDockerImage.sh** script is just a utility shell script that performs MD5 checks and is an easy way for beginners to get started. Expert users are welcome to directly call docker build with their preferred set of parameters.
1717

1818
### Building OHS Docker Install Images
1919
IMPORTANT: You have to download the binaries of OHS and Oracle JDK and put them in place (see .download files inside dockerfiles/).
2020

2121
Download the required packages (see .download files) and drop them in the folder of your distribution version of choice. Then go into the **dockerfiles** folder and run the **buildDockerImage.sh** script as root.
2222

23+
$ sh buildDockerImage.sh -v 12.2.1
24+
2325
IMPORTANT: the resulting images will NOT have a domain pre-configured.
2426
You must extend the image with your own Dockerfile, and create your domain using WLST. You might take a look at the use case samples as well below.
2527

@@ -42,11 +44,11 @@ The best way to create your own, or extend domains is by using WebLogic Scriptin
4244
## Building a sample Docker Image of a OHS Domain
4345
To try a sample of a OHS standalone image with a domain configured, follow the steps below:
4446

45-
Make sure you have oracle/ohs:12.2.1-sa image built. If not go into **dockerfiles/12.2.1** and call:
47+
Make sure you have **oracle/ohs:12.2.1-sa** image built. If not go into **dockerfiles/12.2.1** and call:
4648

4749
$ sh buildDockerImage.sh -v 12.2.1
4850

49-
### How to Build Image
51+
### How to Build OHS domain Image
5052
Go to folder **samples/1221-OHS-domain**
5153

5254
Run the following command:
@@ -58,36 +60,46 @@ Verify you now have this image in place with
5860
$ docker images
5961

6062
### How to run container
61-
1. Edit the env.list file with relevant data from Weblogic container like Admin Server host, port, cluster info etc.
63+
1. As prerequisite run the below command to create a docker data volume.
64+
65+
Eg:$ docker volume create --name volume
6266

63-
For example:
67+
_This volume will be created in "/var/lib/docker" directory or the location where "/var/lib/docker" points to._
6468

65-
WEBLOGIC_HOST=myhost
66-
WEBLOGIC_PORT=7001
67-
WEBLOGIC_CLUSTER=myhost:9001,myhost:9002
6869

70+
2. Depending on your weblogic environment , create a **custom_mod_wl_ohs.conf** file by referring to container-scripts/mod_wl_ohs.conf.sample and section 2.4 @ [OHS 12c Documentation](http://docs.oracle.com/middleware/1221/webtier/develop-plugin/oracle.htm#PLGWL553)
6971

70-
The values of WEBLOGIC_HOST, WEBLOGIC_PORT and WEBLOGIC_CLUSTER must be valid, existing containers running WebLogic servers.
72+
3. Place the custom_mod_wl_ohs.conf file in docker data volume directory . e.g /var/lib/docker/volume
7173

72-
2. Run this image by calling
74+
4. To start the OHS Container with above sampleohs:12.2.1 image , run command from docker voume directory
7375

74-
$ docker run -d --env-file ./env.list -p 7777:7777 sampleohs:12.2.1 configureWLSProxyPlugin.sh
76+
For e.g.
77+
$ cd /var/lib/docker/volume
78+
$ docker run -v `pwd`:/volume -w /volume -d --name ohs -p 7777:7777 sampleohs:12.2.1 configureWLSProxyPlugin.sh
7579

7680

7781
The **configureWLSProxyPlugin.sh** script will be the first script to be run inside the OHS container .
7882
This script will perform the following actions:
79-
- Starts the Node Manager and OHS server
80-
- Edits the mod_wl_ohs.conf.sample with values passed via env.list
81-
- Copies the mod_wl_ohs.conf file under INSTANCE home
82-
- Restarts OHS server
83+
- Start the Node Manager and OHS server
84+
- Fetch the custom_mod_wl_ohs.conf file from mounted shared data volume
85+
- Place the custom_mod_wl_ohs.conf file under OHS INSTANCE home
86+
- Restart OHS server
87+
88+
_NOTE: If custom_mod_wl_ohs.conf is not provided or not found under mounted shared data volume, then configureWLSProxyPlugin.sh will still start OHS server which will be accessible @ http://localhost:7777/index.html._
89+
90+
_Later you can login to running container and configure Weblogic Server proxy plugin file and run restartOHS script._
8391

84-
3. Sanity URLs check for OHS server
92+
93+
5. Sanity URLs check for OHS server
8594
- Now you can access the OHS index page @ http://localhost:7777/index.html
8695
- Static html page @ URL http://localhost:7777/helloWorld.html
8796

88-
4. Weblogic Cluster : Now you will be able to access all URLS via the OHS Listen Port 7777
89-
- Weblogic Console : http://myhost:7777/console
90-
- Applications deployed on Weblogic Cluster : http://myhost:7777/$application_url_endpoint
97+
6. All applications should now be routed via the OHS port 7777.
98+
99+
100+
## Support
101+
Currently Oracle HTTP Server on Docker is NOT supported by Oracle. Use these files at your own discretion.
102+
91103

92104
## License
93105
To download and run Oracle HTTP Server 12c Distribution regardless of inside or outside a Docker container, and regardless of the distribution, you must download the binaries from Oracle website and accept the license indicated at that page.
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,46 @@
11
Example of Oracle HTTP Server with Weblogic Proxy Plugin
22
===============
3-
This Dockerfile extends the Oracle HTTP Install image by creating a sample OHSdomain and configures Oracle WebLogic Server Proxy Plug-In in order to load balance a WebLogic cluster, from inside a container in the same network as the Weblogic Cluster.
3+
This Dockerfile extends the Oracle HTTP Install image by creating a sample OHSdomain .
4+
During OHS container creation Oracle WebLogic Server Proxy Plug-In can be configured in order to load balance applications deployed onto either the Weblogic Admin Server, the Managed Servers or the WebLogic cluster running on docker containers within the same network.
45

56
## How to build image and run container
67
First make sure you have the Oracle HTTP install image (oracle/ohs:12.2.1-sa) ready by running following command as root user
78
$ docker images
89

9-
1.To build the domain image using this sample Dockerfile, run command:
10+
1.To build the OHS domain image using this sample Dockerfile, run command:
1011

11-
$ docker build --force-rm=true --no-cache=true --rm=true -t sampleohs:12.2.1 --build-arg NM_PASSWORD=welcome1 .
12+
$ docker build --force-rm=true --no-cache=true --rm=true -t sampleohs:12.2.1 --build-arg NM_PASSWORD=welcome1 .
1213

13-
2.To start the Container with above image , run command :
14+
2. Run the below command to create a docker data volume.
1415

15-
$ docker run -d --env-file ./env.list -p 7777:7777 sampleohs:12.2.1 configureWLSProxyPlugin.sh
16+
Eg:$ docker volume create --name volume
17+
18+
_This data volume will be created in "/var/lib/docker" directory or the location where "/var/lib/docker" points to._
19+
20+
3. Depending on your Weblogic environment , create a **custom_mod_wl_ohs.conf** file by referring to container-scripts/mod_wl_ohs.conf.sample and section 2.4 @ [OHS 12c Documentation](http://docs.oracle.com/middleware/1221/webtier/develop-plugin/oracle.htm#PLGWL553)
21+
22+
4. Place the custom_mod_wl_ohs.conf file in docker data volume directory . e.g /var/lib/docker/volume
23+
24+
4. To start the OHS Container with above sampleohs:12.2.1 image , run command from data volume directory:
25+
26+
$ cd /var/lib/docker/volume
27+
$ docker run -v `pwd`:/volume -w /volume -d --name ohs -p 7777:7777 sampleohs:12.2.1 configureWLSProxyPlugin.sh
28+
29+
5. All applications will now be accessible via the OHS port 7777.
30+
31+
######NOTE: If custom_mod_wl_ohs.conf is not provided, then configureWLSProxyPlugin.sh will just start OHS which will be accessible @ http://localhost:7777/index.html. Later you can login to running container and configure Weblogic Server proxy plugin file and run restartOHS script.
1632

17-
######Note : env.list file should have valid values of WEBLOGIC_HOST, WEBLOGIC_PORT and WEBLOGIC_CLUSTER from existing containers running WebLogic servers.
1833

1934
## Configuring the Oracle WebLogic Server Proxy Plug-In with Oracle HTTP Server
35+
2036
Oracle WebLogic Server Proxy Plug-In (mod_wl_ohs)is used for proxying requests from Oracle HTTP Server to Oracle WebLogic Server.
21-
The Oracle WebLogic Server Proxy Plug-In is included in the Oracle HTTP Server 12c (12.2.1) installation.
22-
Refer https://docs.oracle.com/middleware/1221/webtier/develop-plugin/oracle.htm#PLGWL553
37+
The Oracle WebLogic Server Proxy Plug-In is included in the Oracle HTTP Server 12c (12.2.1) installation by default.
38+
39+
A sample WebLogic Server Proxy Plug-In file has been provided @ **samples/1221-ohs-domain/container-scripts/mod_wl_ohs.conf.sample**
40+
Refer [OHS 12c Documentation](http://docs.oracle.com/middleware/1221/webtier/develop-plugin/oracle.htm#PLGWL553) for more details and examples
41+
42+
Depending on the nature of your applications create your own "custom_mod_wl_ohs.conf" file.
2343

24-
To configure OHS server with WLS Proxy Plugin, a sample file mod_wl_ohs.conf.sample has been provided under **samples/1221-ohs-domain/container-scripts** folder.
25-
The values for WEBLOGIC_HOST, WEBLOGIC_PORT and WEBLOGIC_CLUSTER will be used from values provided by user during docker run via the env.list
2644

2745
### Example with WLS Docker Container
2846

@@ -32,32 +50,58 @@ The values for WEBLOGIC_HOST, WEBLOGIC_PORT and WEBLOGIC_CLUSTER will be used fr
3250
- http://myhost:7001/console
3351

3452
2. Two WLS Containers with Managed Servers running on 9001 and 9002 ports (inside same weblogic cluster).
35-
Assume some sample application is deployed on the each managed server and are accessible via URLs
36-
- http://myhost:9001/sample1
37-
- http://myhost:9002/sample2
53+
Assume some "sample" application is deployed on the weblogic cluster and are accessible via URLs
54+
- http://myhost:9001/sample
55+
- http://myhost:9002/sample
3856

3957
##### To configure Oracle WebLogic Server Proxy Plug-In inside OHS container
4058

41-
1.Edit the env.list file and provide values
42-
43-
WEBLOGIC_HOST=myhost
44-
WEBLOGIC_PORT=7001
45-
WEBLOGIC_CLUSTER=myhost:9001,myhost:9002
46-
47-
2. As part of docker run command provide the env.file
48-
49-
$ docker run -d --env-file ./env.list -p 7777:7777 sampleohs:12.2.1 configureWLSProxyPlugin.sh
50-
51-
The **configureWLSProxyPlugin.sh** script will
59+
1. Create the custom_mod_wl_ohs.conf file by referring to container-scripts/mod_wl_ohs.conf.sample
60+
61+
For e.g
62+
LoadModule weblogic_module "/u01/oracle/ohssa/ohs/modules/mod_wl_ohs.so"
63+
<IfModule mod_weblogic.c>
64+
WebLogicHost myhost
65+
WebLogicPort 7001
66+
</IfModule>
67+
#
68+
# Directive for weblogic admin console deployed on Admin Server
69+
<Location /console>
70+
WLSRequest On
71+
WebLogicHost myhost
72+
WeblogicPort 7001
73+
</Location>
74+
#
75+
# Directive for all application deployed on weblogic cluster with prepath /weblogic
76+
<Location /weblogic>
77+
WLSRequest On
78+
WebLogicCluster myhost:9001,myhost:9002
79+
PathTrim /weblogic
80+
</Location>
81+
82+
83+
2. Place it in docker data volume directory say /var/lib/docker/volume
84+
85+
3. From docker data volume directory run following docker run command
86+
87+
For e.g
88+
$ cd /var/lib/docker/volume
89+
$ docker run -v `pwd`:/volume -w /volume -d --name ohs -p 7777:7777 sampleohs:12.2.1 configureWLSProxyPlugin.sh
90+
91+
The **configureWLSProxyPlugin.sh** script will be the first script to be run inside the OHS container .
92+
This script will perform the following actions:
5293
- Start the Node Manager and OHS server
53-
- Edit the mod_wl_ohs.conf.sample with right directives (based on values passed via env.list)
54-
- Copy the mod_wl_ohs.conf file under INSTANCE home
94+
- Fetch the custom_mod_wl_ohs.conf file from mounted shared data volume
95+
- Place the custom_mod_wl_ohs.conf file under OHS INSTANCE home
5596
- Restart OHS server
5697

57-
3. Now you will be able to access all the URLS via the OHS Listen Port 7777
58-
- http://myhost:7777/console
59-
- http://myhost:7777/sample1
60-
- http://myhost:7777/sample2
98+
4. Now you will be able to access all the URLS via the OHS Listen Port 7777
99+
- http://localhost:7777/console
100+
- http://localhost:7777/weblogic/sample
101+
102+
_NOTE: If custom_mod_wl_ohs.conf is not provided or not found under mounted shared data volume, then configureWLSProxyPlugin.sh will still start OHS server which will be accessible @ http://localhost:7777/index.html._
103+
_Later you can login to running container and configure Weblogic Server proxy plugin file and run restartOHS script._
104+
61105

62106
# Copyright
63107
Copyright (c) 2016-2017 Oracle and/or its affiliates. All rights reserved.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
# Author: hemastuti.baruah@oracle.com
3+
#
4+
# Copyright (c) 2016-2017 Oracle and/or its affiliates. All rights reserved.
5+
#
6+
#*************************************************************************
7+
#This script will configure Oracle WebLogic Server Proxy Plug-In (mod_wl_ohs),
8+
#in order to enable the Oracle HTTP Server instances to route applications
9+
#deployed on the Oracle WebLogic Server Multi Host
10+
#Refer to Section 2.4 @ http://docs.oracle.com/middleware/1221/webtier/develop-plugin/oracle.htm#PLGWL553
11+
#
12+
#Prerequisite: Setup environment for Weblogic MultiHost by referring to samples in
13+
# https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/1221-multihost
14+
#
15+
#MW_HOME - The root directory of your OHS standalone install
16+
#DOMAIN_NAME - Env Value set by Dockerfile , default is "ohsDOmain"
17+
#OHS_COMPONENT_NAME - Env Value set by Dockerfile , default is "ohs_sa1"
18+
#WEBLOGIC_HOST, WEBLOGIC_PORT, WEBLOGIC_CLUSTER - Env values passed from env.list
19+
#*************************************************************************
20+
echo "MW_HOME=${MW_HOME:?"Please set MW_HOME"}"
21+
echo "DOMAIN_NAME=${DOMAIN_NAME:?"Please set DOMAIN_NAME"}"
22+
echo "OHS_COMPONENT_NAME=${OHS_COMPONENT_NAME:?"Please set OHS_COMPONENT_NAME"}"
23+
echo "WEBLOGIC_HOST=${WEBLOGIC_HOST:?"Please provide Weblogic Admin Server hostname"}"
24+
echo "WEBLOGIC_PORT=${WEBLOGIC_PORT:?"Please provide Weblogic Admin Server Port"}"
25+
echo "WEBLOGIC_CLUSTER=${WEBLOGIC_CLUSTER:?"Please provide the Weblogic Cluster details"}"
26+
27+
DOMAIN_HOME=${MW_HOME}/user_projects/domains/${DOMAIN_NAME}
28+
INSTANCE_CONFIG_HOME=$DOMAIN_HOME/config/fmwconfig/components/OHS/${OHS_COMPONENT_NAME}
29+
export INSTANCE_CONFIG_HOME
30+
echo "INSTANCE_CONFIG_DIR=${INSTANCE_CONFIG_HOME}"
31+
32+
#Start NodeManager and OHS server
33+
echo "Starting Node Manager and OHS server"
34+
/u01/oracle/container-scripts/startNMandOHS.sh
35+
36+
37+
#Modify the variables in the mod_wl_ohs.conf.sample file with values provided in the env.file
38+
cp /u01/oracle/container-scripts/mod_wl_ohs.conf.sample /u01/oracle/container-scripts/mod_wl_ohs.conf.sample.WLSMultiHost
39+
sed -i -e "s/WEBLOGIC_HOST/$WEBLOGIC_HOST/g" -e "s/WEBLOGIC_PORT/$WEBLOGIC_PORT/g" -e "s/WEBLOGIC_CLUSTER/$WEBLOGIC_CLUSTER/g" mod_wl_ohs.conf.sample.WLSMultiHost
40+
41+
# Rename the original file and copy the sample file to instance config location
42+
echo "Configuring Oracle WebLogic Server Proxy Plug-In for WLS MultiHost sample"
43+
cd ${INSTANCE_CONFIG_HOME}
44+
mv mod_wl_ohs.conf mod_wl_ohs.conf.ORIGINAL
45+
echo "Copying plugin file to INSTANCE_CONFIG_DIR=${INSTANCE_CONFIG_HOME}"
46+
cp /u01/oracle/container-scripts/mod_wl_ohs.conf.sample.WLSMultiHost ${INSTANCE_CONFIG_HOME}/mod_wl_ohs.conf
47+
48+
# Restart ohs server
49+
echo "Restarting OHS server "
50+
/u01/oracle/container-scripts/restartOHS.sh
51+
52+
#Tail all server logs
53+
tail -f ${DOMAIN_HOME}/nodemanager/nodemanager.log ${DOMAIN_HOME}/servers/*/logs/*.out

OracleHTTPServer/samples/1221-ohs-domain/container-scripts/configureWLSProxyPlugin.sh

+26-15
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@
55
#
66
#*************************************************************************
77
#This script will configure Oracle WebLogic Server Proxy Plug-In (mod_wl_ohs),
8-
#in order to enable the Oracle HTTP Server instances to route to applications
9-
#deployed on the Oracle WebLogic Server clusters
8+
#in order to enable the Oracle HTTP Server instances to route applications
9+
#deployed on the Admin Server, Single Managed Server or the Oracle WebLogic Server clusters
1010
#Refer to Section 2.4 @ http://docs.oracle.com/middleware/1221/webtier/develop-plugin/oracle.htm#PLGWL553
1111
#
12-
#Prerequisite: Provide WLS Host, Port and Cluster info in the env.list during docker run
12+
#Prerequisite:
13+
#1.Create docker volume e.g docker volume create --name volume
14+
#2.Create "custom_mod_wl_ohs.conf" as per your environment by referring to mod_wl_ohs.conf sample file and OHS document above
15+
#3.Place the "custom_mod_wl_ohs.conf" inside the docker volume
16+
#4.During OHS container creation mount the docker volume which contains the "custom_mod_wl_ohs.conf"
17+
#
18+
# Note :
19+
# If custom_mod_wl_ohs.conf is not provided, WebLogic Server Proxy Plug-In will not be configured. But OHS server will be still running.
20+
# User may login to OHS container and manually configure the WebLogic Server Proxy Plug-In later
1321
#
1422
#MW_HOME - The root directory of your OHS standalone install
1523
#DOMAIN_NAME - Env Value set by Dockerfile , default is "ohsDOmain"
@@ -19,31 +27,34 @@
1927
echo "MW_HOME=${MW_HOME:?"Please set MW_HOME"}"
2028
echo "DOMAIN_NAME=${DOMAIN_NAME:?"Please set DOMAIN_NAME"}"
2129
echo "OHS_COMPONENT_NAME=${OHS_COMPONENT_NAME:?"Please set OHS_COMPONENT_NAME"}"
22-
echo "WEBLOGIC_HOST=${WEBLOGIC_HOST:?"Please provide Weblogic Admin Server hostname in the env.list file"}"
23-
echo "WEBLOGIC_PORT=${WEBLOGIC_PORT:?"Please provide Weblogic Admin Server Port in the env.list file"}"
24-
echo "WEBLOGIC_CLUSTER=${WEBLOGIC_CLUSTER:?"Please provide the Weblogic Cluster details in the env.list file"}"
2530

2631
DOMAIN_HOME=${MW_HOME}/user_projects/domains/${DOMAIN_NAME}
2732
INSTANCE_CONFIG_HOME=$DOMAIN_HOME/config/fmwconfig/components/OHS/${OHS_COMPONENT_NAME}
2833
export INSTANCE_CONFIG_HOME
2934
echo "INSTANCE_CONFIG_DIR=${INSTANCE_CONFIG_HOME}"
3035

3136
#Start NodeManager and OHS server
37+
echo "Starting Node Manager and OHS server"
3238
/u01/oracle/container-scripts/startNMandOHS.sh
3339

3440

35-
#Modify the variables in the mod_wl_ohs.conf.sample file with values provided in the env.file
36-
cp /u01/oracle/container-scripts/mod_wl_ohs.conf.sample /u01/oracle/container-scripts/mod_wl_ohs.conf.sample.without_substitution
37-
sed -i -e "s/WEBLOGIC_HOST/$WEBLOGIC_HOST/g" -e "s/WEBLOGIC_PORT/$WEBLOGIC_PORT/g" -e "s/WEBLOGIC_CLUSTER/$WEBLOGIC_CLUSTER/g" mod_wl_ohs.conf.sample
41+
#Search for the customized mod_wl_ohs.conf file
42+
modwlsconfigfile=`find / -name 'custom_mod_wl_ohs.conf' 2>&1 | grep -v 'Permission denied'`
43+
export modwlsconfigfile
3844

39-
# Rename the original file and copy the sample file to instance config lcoation
45+
# Check and copy custom_mod_wl_ohs.conf to OHS Instance Home
46+
if [[ -n "${modwlsconfigfile/[ ]*\n/}" ]]; then
4047
cd ${INSTANCE_CONFIG_HOME}
4148
mv mod_wl_ohs.conf mod_wl_ohs.conf.ORIGINAL
42-
echo "Copying plugin file to INSTANCE_CONFIG_DIR=${INSTANCE_CONFIG_HOME}"
43-
cp /u01/oracle/container-scripts/mod_wl_ohs.conf.sample ${INSTANCE_CONFIG_HOME}/mod_wl_ohs.conf
44-
45-
# Restart ohs server
49+
echo "Copying ${modwlsconfigfile} to ${INSTANCE_CONFIG_HOME} and restarting OHS server"
50+
cp ${modwlsconfigfile} ${INSTANCE_CONFIG_HOME}/mod_wl_ohs.conf
51+
echo "Restarting OHS server after successful configuration of WebLogic Server Proxy Plug-In "
4652
/u01/oracle/container-scripts/restartOHS.sh
53+
echo "You may now access the the application deployed to the DockerCluster @ http://myhost:7777/weblogic/application_end_url"
54+
else
55+
echo "Customized mod_wl_ohs.conf file not found in mounted volume!!! WebLogic Server Proxy Plug-In has not been configured, but OHS is running "
56+
echo "You may now access OHS @ http://myhost:7777/index.html"
57+
fi
4758

48-
#Tail all servr logs
59+
#Tail all server logs
4960
tail -f ${DOMAIN_HOME}/nodemanager/nodemanager.log ${DOMAIN_HOME}/servers/*/logs/*.out

0 commit comments

Comments
 (0)