November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Docker creates Tomcat/Weblogic cluster

Install Tomcat image

Prepare the required jdk, tomcat and other software into the home directory, start a container
docker run -t -i -v /home:/opt/data -name mk_tomcat Ubuntu /bin/bash

This command mounts the local home directory to the /opt/data directory of the container. If the container directory does not exist, it will be automatically created. The next step is the basic configuration of tomcat. After setting the jdk environment variable, place the tomcat program in /opt/apache-tomcat. Edit the /etc/supervisor/conf.d/supervisor.conf file and add the tomcat item.

[supervisord]
nodaemon=true

[program:tomcat]
command=/opt/apache-tomcat/bin/startup.sh

[program:sshd]
command=/usr/sbin/sshd -D
docker commit ac6474aeb31d tomcat

Create a new tomcat folder and create a new Dockerfile.
FROM mk_tomcat EXPOSE
22 8080
CMD [“/usr/bin/supervisord”]

Create an image based on the Dockerfile.
Docker build tomcat tomcat

Install weblogic image

The steps and tomcat basically the same, posted here configuration file
supervisor.conf
[supervisord]
nodaemon=true

[program:weblogic]
command=/opt/Middleware/user_projects/domains/base_domain/bin/startWebLogic.sh

[program:sshd]
command=/usr/sbin/sshd -D
dockerfile
FROM weblogic EXPOSE
22 7001
CMD [“/usr/bin/supervisord”]

Use of the tomcat/weblogic image

Use of storage

At startup, use the -v parameter
-v, –volume=[] Bind mount a volume (eg from the host: -v /host:/container, from docker: -v /container)

Map the local disk to the inside of the container, it changes in real time between the host and the container, so we only need to update the directory of the physical host to update the program and upload the code.

Implementation of tomcat and weblogic clusters

Tomcat just need to open multiple containers
docker run -d -v -p 204:22 -p 7003:8080 -v /home/data:/opt/data -name tm1 tomcat /usr/bin/supervisord
docker run -d -v -p 205:22 -p 7004:8080 -v /home/data:/opt/data –name tm2 tomcat /usr/bin/supervisord
docker run -d -v -p 206:22 -p 7005:8080 -v /home/data:/opt/data –name tm3 tomcat /usr/bin/supervisord

Here to talk about weblogic configuration, we all know that weblogic has a domain concept. If you want to deploy using the normal administrator +node method, you need to write the startup scripts for the administrator and server in supervisord respectively. The advantages of doing this are:

  • You can use weblogic clustering, synchronization and other concepts
  • To deploy a clustered application, you only need to install the application once on the cluster.

weakness is:

  • Docker configuration is complicated
  • There is no way to automatically expand the computing capacity of the cluster. If you need to add nodes, you need to first create a node on the administrator, then configure a new container supervisor startup script, and then start the container

Another method is to install all the programs on the adminiserver. When you need to expand, you can start multiple nodes. Its advantages and disadvantages are the opposite of the previous methods. (It is recommended to use this method to deploy the development and test environment)
docker run -d -v -p 204:22 -p 7001:7001 -v /home/data:/opt/data -name node1 weblogic /usr/bin/ Supervisord
docker run -d -v -p 205:22 -p 7002:7001 -v /home/data:/opt/data -name node2 weblogic /usr/bin/supervisord
docker run -d -v -p 206:22 -p 7003:7001 -v /home/data:/opt/data –name node3 weblogic /usr/bin/supervisord

In this way, using nginx as the load balancer in the front end can complete the configuration.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>