Skip to content

Commit 7f1d1c1

Browse files
mriccellbrunoborges
authored andcommitted
New Multi Host workshop using the Apache Plugin Web Tier (oracle#93)
* Use Webtier in multi host env and create workshop Add a new script start-webtier to start a Apache Plugin Webtier container and load balance requests to a WLS cluster in a multi host env. Create multi host workshop. * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Update README.md * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Update README.md * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io * Saved README.md with Dillinger.io
1 parent 0874347 commit 7f1d1c1

32 files changed

+270
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
# Create overlay Docker Multihost Network and set Docker environment pointing to Machine
3+
. ./setenv.sh
4+
5+
# Save existing defined image to a file to be loaded later into the registry created above
6+
eval "$(docker-machine env -u)"
7+
docker save $image > _tmp_docker.img
8+
echo "image saved to tmp_docker.img"
9+
10+
# Load, tag, and publish the image set in setenv.sh
11+
eval "$(docker-machine env $orchestrator)"
12+
docker load -i _tmp_docker.img && rm _tmp_docker.img
13+
docker tag $image 127.0.0.1:5000/$image
14+
docker push 127.0.0.1:5000/$image
15+
echo "image hed to repository"
16+
17+
18+
# Call post-bootstrap.sh if present and executable
19+
if [ -x ./post-bootstrap.sh ]; then
20+
. ./post-bootstrap.sh
21+
fi
22+

OracleWebLogic/samples/1221-multihost/create-container.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
. ./setenv.sh
88

99
uuid=$(uuidgen)
10-
name=$prefix-instance-$uuid
10+
name=$prefix-instance-$(echo $uuid | cut -c1-8)
1111
machine=$1
1212
swarm=""
1313

@@ -23,6 +23,8 @@ fi
2323
eval "$(docker-machine env $swarm $machine)"
2424

2525
docker run -d $DOCKER_CONTAINER_INSTANCE_OPTIONS \
26+
-e MS_HOST=$name\
27+
-e MS_NAME=$name\
2628
--name=$name \
2729
--hostname=$name \
2830
--net=$network \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
4+
#
5+
# Author: Monica Riccelli <[email protected]>
6+
#
7+
echo "Creating the Apache WebTier to load balance requests to a WLS cluster for Multi Host Environment ..."
8+
echo ""
9+
machine=$1
10+
swarm=""
11+
webtierimage=webtier
12+
wlscluster=""
13+
. ./setenv.sh
14+
15+
if [ "$machine" = "" ]; then
16+
echo "No machine specified. Going to use the Swarm then."
17+
machine="${prefix}-master"
18+
swarm="--swarm"
19+
echo "Running webtier container with config to instance $name on specific Docker Machine $machine ..."
20+
else
21+
echo "Running webtier container with iconfig to instance $name on specific Docker Machine $machine ..."
22+
fi
23+
24+
# Get Managed Server Container IP Address running on machine
25+
eval "$(docker-machine env $swarm $machine)"
26+
27+
for HOST in $(docker ps -a --format "{{.Names}}" | grep -i weblogic-instance )
28+
do
29+
n=$(expr $(expr index $HOST /) + 1)
30+
length=$(expr "$HOST" : '.*')
31+
HOST=$(echo $HOST | cut -c$n-$length)
32+
wlscluster=$wlscluster"$HOST:7001,"
33+
done
34+
35+
wlscluster=$(echo $wlscluster | sed 's/.$//')
36+
37+
# Save existing defined image to a file to be loaded later into the registry created above
38+
eval "$(docker-machine env -u)"
39+
docker save $webtierimage > _tmp_docker.img
40+
41+
# Load, tag, and publish the webtier image
42+
eval "$(docker-machine env $orchestrator)"
43+
docker load -i _tmp_docker.img && rm _tmp_docker.img
44+
docker tag $webtierimage 127.0.0.1:5000/$webtierimage
45+
docker push 127.0.0.1:5000/$webtierimage
46+
47+
# Run Webtier container on weblogic-master
48+
eval "$(docker-machine env $prefix-master)"
49+
docker run -d \
50+
-e WEBLOGIC_CLUSTER=$(echo $wlscluster) \
51+
-p 80:80 \
52+
--net=$network \
53+
$registry/$webtierimage
54+
55+
echo ""
56+
echo "WebTier Container now running in $prefix-master."
57+
echo ""
58+
echo "You may now access the sample application deployed to the DockerCluster http://$(docker-machine ip $prefix-master):80/sample"
59+
+186
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
# Workshop Guide: Docker Multi Host
2+
## Background Knowledge Required / Suggested
3+
* WebLogic Architecture
4+
* WebLogic Scripting Tool (WLST)
5+
* Linux
6+
7+
## Feature Overview
8+
9+
Docker is a platform that enables users to build, package, ship and run distributed applications. Docker users package up their applications, and any dependent libraries or files, into a Docker image. Docker images are portable artifacts that can be distributed across Linux environments. Images that have been distributed can be used to instantiate containers where applications can run in isolation from other applications running in other containers on the same host operating system. Docker 1.9 introduced the overlay network, this provides the ability to network together containers running in different hosts or VM.
10+
11+
## Workshop Overview
12+
13+
As part of the Docker Multi-Host Workshop, in this document you will see how to create a WebLogic domain with servers running in Docker containers distributed in different VMs. In this Docker environment the WebLogic servers running in the cluster have all the HA properties of a WebLogic Server cluster like session replication, singleton service migration to name two. We will create two Docker images using the WebLogic install image and WebLogic domain image created in the previous workshop. We will use a couple of custom Dockerfiles, the WebLogic domain image will be extended to create an application image. We will use some Docker tools to help us in the creation of this environment Docker Machine, Docker Swarm, Consul, Docker Overlay Network, and Registry. The Docker Machine will start a Virtual Box with the Docker Engine running inside. Every Docker Machine will participate in a Docker Swarm cluster which are all networked with the Docker Overlay network. The Registry allows us to push our images and then very easily from outside the VM using scripts run containers from these images. All this will be achieved using custom scripts and Dockerfiles.
14+
15+
### Requirements / Prerequisites
16+
* Computer with 8GB RAM and 2-4 cores
17+
* VirtualBox 4.2.4+
18+
* Linux VM with Docker 1.9+ and Git installed
19+
20+
### Tips
21+
* Allocate at least 4GB RAM to the VM, if not more
22+
* Allocate at least 2 cores to the VM, if not more
23+
24+
## Steps
25+
### Get Oracle Docker Images
26+
This lab document assumes you have created the WebLogic 12.2.1 Install image and the WebLogic Domain Image as described in the workshop. Feel free to use any location you prefer.
27+
28+
$ git clone --depth=1 https://github.com/oracle/docker-images.git
29+
30+
#### WebLogic Install image and WebLogic Domain image
31+
You should have 3 images already running in your machine the Oracle Linux Image, WebLogic Install image, and the WebLogic Domain image. These images have been created following the instructions from the workshop.
32+
33+
We now have a new image **oracle/jdk:8b**, this image is built by extending the Oracle Linux image. The WebLogic install image will extend the **oracle/jdk:8b**.
34+
35+
![](images/02_oracle_jdk_buildimage.png)
36+
37+
To see the base images used in this workshop run the command,
38+
39+
$ docker images
40+
41+
![](images/03_WLS_images.png)
42+
43+
44+
### Dockerfiles
45+
Under the **samples** directory we have subdirectories that contain Dockerfiles that serve as examples to build WebLogic Domain images, WebLogic Application Images, Apache Webtier Images, and scripts to build a WebLogic Domain in a multi host environment.
46+
47+
![](images/05_samples_dir_ls.png)
48+
49+
This project offers a couple of Dockerfiles to create the Application image. The Application image **1221-appdeploy** extends a WebLogic Domain image to deploy the application **sample** to servers running in a WebLogic 12.2.1 domain. This Dockerfile can be easily change to extend a WebLogic 12.1.3 Domain image.
50+
51+
### Application Images
52+
To give users an idea on how to create the Application images from a custom Dockerfile to extend the WebLogic Domain image, we provide samples under the folder '~/docker-images/OracleWebLogic/samples/1221-appdeploy'. The best way to create your own, or extend domains is by using WebLogic Scripting Tool. The WLST script used to deploy the **sample** application and create the **1221-appdeploy** image is '~/docker-images/OracleWebLogic/samples/1221-appdeploy/container-scripts/app-deploy.py'. This script by default deploys the sample application to all servers in the domain. You can deploy your own applications by modifying the WLST scripts, or create a new one with WLST.
53+
54+
To try building the WebLogic **appdeploy** Application image:
55+
56+
$ cd ~/docker-images/OracleWebLogic/samples/1221-appdeploy
57+
$ docker build -t 1221-appdeploy .
58+
59+
Like before, you can open the Dockerfile in another terminal window to see the definition of the build steps Docker is running.
60+
61+
![](images/04_appdeploy.png)
62+
63+
In steps 1 through 4 above, we extend the **1221-domain** image, define application name, name of the war file, and location where it should be copied.
64+
Like before, you can open the Dockerfile in another terminal window to see the definition of the build steps Docker is running.
65+
66+
### Apache Plugin Web Tier Images
67+
The Apache Plugin will provide us the ability to load balance traffic to WebLogic Managed servers in a WebLogic cluster. Each Managed server is running in its own Docker container, the Apache Plugin Web tier is also running inside of its own Docker container. In this project we take advantage of the Apache Plugin Web tier to load balance traffic to Managed servers running in containers in a multi host environment.
68+
69+
To give users an idea on how to create the Apache Plugin Web tier images from a custom Dockerfile, we provide samples under the folder '~/docker-images/OracleWebLogic/samples/1221-webtier-apache'. The best way to create your own, is edit the Dockerfile and the weblogic.conf file to fit your environment.
70+
In the Dockerfile we extend the **httpd:2.4** image, and install the Apache Plugin. To try building the WebLogic **webtier** image:
71+
72+
$ cd ~/docker-images/OracleWebLogic/samples/1221-webtier-apache
73+
$ docker build -t webtier .
74+
75+
Like before, you can open the Dockerfile in another terminal window to see the definition of the build steps Docker is running.
76+
77+
![](images/06_webtier_image.png)
78+
79+
The image is successfully built, belonging to the repository **webtier**, and tag **latest**. When the image is created, it will be reflected when we do a `docker images`
80+
81+
![](images/07_all_images.png)
82+
83+
### Building WebLogic Multi Host Environment
84+
To make it easy to build a multi host environment we take advantage of the following tools Docker Machine, Docker Swarm, Docker Overlay Network, Docker Compose, Docker Registry, and Consul.
85+
86+
**Docker Machine**: Docker Machine is a tool that lets you install Docker Engine on virtual hosts, and manage the hosts with docker-machine commands.
87+
88+
**Docker Swarm**: Docker Swarm is native clustering for Docker. It turns a pool of Docker hosts into a single, virtual Docker host. Because Docker Swarm serves the standard Docker API, any tool that already communicates with a Docker daemon can use Swarm to transparently scale to multiple hosts.
89+
90+
**Docker Overlay Network**: Dockers Overlay network driver supports multi-host networking natively out-of-the-box, while still providing better container isolation.
91+
92+
**Docker Compose**: Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a Compose file to configure your application services. Then, using a single command, you create and start all the services from your configuration.
93+
94+
**Docker Registry**: The Registry is a stateless, highly scalable server side application that stores and lets you distribute Docker images.
95+
96+
**Consul**: Consul makes it simple for services to register themselves and to discover other services via a DNS or HTTP interface.
97+
98+
To give users an idea on how to create a WebLogic Server Domain in a Multi Host environment we have scripts under '~/docker-images/OracleWebLogic/samples/1221-multihost' directory. The **bootstrap.sh** script starts 2 Docker Machines the **weblogic-orchestrator** and **weblogic-master** . The **weblogic-orchestrator** Docker Machine has the **Docker Registry** running, where we register the images we need to run containers from, and the **Consul** to help us start services. The **weblogic-master** Docker Machine has the **Docker Swarm, the Overlay Network, and the WebLogic Admin Server container** running in the VM.
99+
After starting the two Docker machines, the **1221-appdeploy** image is pushed into the registry running in the **weblogic-orchestrator** machine. Finally the bootstrap script calls post-bootstrap script.
100+
101+
![](images/09_bootstrap_vi.png)
102+
103+
The '~/docker-images/OracleWebLogic/samples/1221-multihost/post-bootstrap.sh' script runs an Admin server Docker Container in the weblogic-master machine from the **app-deploy** image that has been pushed to the registry.
104+
105+
![](images/10_post_bootstrap_vi.png)
106+
107+
After running the bootstrap.sh script successfully, we can see the two Docker machines running using the `docker-machine ls` command.
108+
109+
![](images/11_docker_machine_after_bootstrap.png)
110+
111+
If we ssh into the weblogic-orchestrator machine by running `docker-machine ssh weblogic-orchestrator` command we can see the registry, consul images, and containers running in this machine. Use the commands `docker images` to see images and `docker ps` to see containers.
112+
113+
![](images/12_orchestrator.png)
114+
115+
116+
If we ssh into the weblogic-master machine by running `docker-machine ssh weblogic-master` command and do `docker ps` we see the Admin server container running and the swarm.
117+
118+
![](images/13_master.png)
119+
120+
Every virtual machine that is part of the Docker Swarm will be networked together with the **Overlay network**. Every container running in the VM will be able to communicate with any other container running in a different VM in the Docker Swarm. This allows us to run the WebLogic servers in many different VMs and distribute the WLS domain or cluster across several VMs. Let's take a look at the Docker networks and we can inspect the **Overlay network** by running `docker inspect` using the overlay network name. Run commands:
121+
122+
$ docker network ld
123+
$ docker network inspect weblogic-net
124+
125+
![](images/14_network_inspect.png)
126+
127+
Open the Admin Console by using the ip address of the weblogic-master machine and port 8001, http://192.168.99.101:8001/consolee. View the Admin server running, and the deployed **sample** application.
128+
129+
![](images/15_console_login.png)
130+
![](images/16_console_admin_server.png)
131+
![](images/17_console_deployment.png)
132+
133+
Next we will start a new VM where the managed servers will run. Simply call the '~/docker-images/OracleWebLogic/samples/1221-multihost/create-machine.sh' script. This script will create a new Docker machine, in this project we will run two WebLogic Managed servers. The new Docker machine will be part of the Docker Swarm and the Managed server containers running in this VM will be able to network via the Overlay network with other containers in the Swarm. After running the **create-machine.sh** script we see the Docker Machines running by invoking `docker-machine ls`, we can see a third Docker Machine **weblogic-gv082o**.
134+
135+
![](images/18_create_machine.png)
136+
137+
Now that the machine is up, we will start Managed Server containers from the app-deploy image. Invoke '~/docker-images/OracleWebLogic/samples/1221-multihost/create-container.sh' script. If you want the Managed server container to be started in a particular Docker machine provide the machine name as parameter `./create-container.sh weblogic-gv082o`, otherwise the container will be started in any of the Docker Machines in the Swarm.
138+
139+
![](images/19_create_container.png)
140+
141+
![](images/21_start_managed_servers.png)
142+
143+
144+
Look at the Managed server container running on Docker Machine weblogic-gv082o, ssh onto the machine `docker-machine ssh weblogic-gv082o` and do `docker ps` to see the containers running on the machine.
145+
146+
![](images/20_ms_containers.png)
147+
148+
The entire WebLogic domain has been started and the **sample** application is deployed to the cluster. We will start the **Apache Plugin Web tier** running in its own container. The Apache Plugin will load balance invocations to the **sample** application across Managed servers in the cluster.
149+
The '~/docker-images/OracleWebLogic/samples/1221-multihost/start-webtier.sh' script discovers all Managed servers running in the Swarm, creates the string WEBLOGIC_CLUSTER, pushes the **webtier** image to the registry, and starts a webtier container on the **weblogic-master** machine. The WEBLOGIC_CLUSTER string is set as an environment parameter, when starting the Apache Web tier container the value is set in the **weblogic.conf** file. Also note that the Apache Web tier container is bound to port 80 of the **weblogic-master** machine.
150+
151+
![](images/22_start_webtier.png)
152+
![](images/23_start_webtier2.png)
153+
154+
After invoking the script '~/docker-images/OracleWebLogic/samples/1221-multihoststart-webtier.sh', find the **Apache Web tier** container running in the **weblogic-master** machine.
155+
156+
![](images/24_start_webtier_running.png)
157+
158+
Go into **weblogic-master** machine `docker-machine ssh weblogic-master` and run `docker ps`, see the newly created **Apache Web tier** container running.
159+
160+
![](images/25_webtier_container_onmaster.png)
161+
162+
Call the sample application deployed to the WebLogic cluster via the **Apache Web tier**, in your browser use the ip address of the **weblogic-master** machine and port 80, http://192.168.99.101:80/sample.
163+
164+
![](images/26_call_sample.png)
165+
166+
### Clean Up
167+
Clean Docker Machines running, call script '~/docker-images/OracleWebLogic/samples/1221-multihost/destroy-all-machines.sh'
168+
169+
$ ./destroy-all-machines.sh
170+
171+
Verify the Docker images that exist currently:
172+
173+
$ docker images
174+
175+
176+
Use the `docker rmi` command to delete each of these Docker images
177+
178+
$ docker rmi <IMAGE ID>
179+
180+
### More Information
181+
* [New WebLogic Server Running on Docker in Multi-Host Environments ](https://blogs.oracle.com/WebLogicServer/entry/new)
182+
183+
* [White Paper - Oracle WebLogic Server on Docker Containers](http://www.oracle.com/technetwork/middleware/weblogic/overview/weblogic-server-docker-containers-2491959.pdf)
184+
185+
* [Docker on Oracle Linux](https://docs.docker.com/engine/installation/linux/oracle/)
186+
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)