{"id":7347,"date":"2018-04-13T09:23:37","date_gmt":"2018-04-13T01:23:37","guid":{"rendered":"http:\/\/rmohan.com\/?p=7347"},"modified":"2018-04-13T09:23:37","modified_gmt":"2018-04-13T01:23:37","slug":"docker-creates-tomcat-weblogic-cluster","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7347","title":{"rendered":"Docker creates Tomcat\/Weblogic cluster"},"content":{"rendered":"<p><strong>Install Tomcat image<\/strong><\/p>\n<p>Prepare the required jdk, tomcat and other software into the home directory, start a container<br \/>\ndocker run -t -i -v \/home:\/opt\/data -name mk_tomcat\u00a0<a title=\"Ubuntu\" href=\"https:\/\/www.linuxidc.com\/topicnews.aspx?tid=2\" target=\"_blank\" rel=\"noopener\">Ubuntu<\/a>\u00a0\/bin\/bash<\/p>\n<p>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.\u00a0The 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.<\/p>\n<p>[supervisord]<br \/>\nnodaemon=true<\/p>\n<p>[program:tomcat]<br \/>\ncommand=\/opt\/apache-tomcat\/bin\/startup.sh<\/p>\n<p>[program:sshd]<br \/>\ncommand=\/usr\/sbin\/sshd -D<br \/>\ndocker commit ac6474aeb31d tomcat<\/p>\n<p>Create a new tomcat folder and create a new Dockerfile.<br \/>\nFROM mk_tomcat EXPOSE<br \/>\n22 8080<br \/>\nCMD [&#8220;\/usr\/bin\/supervisord&#8221;]<\/p>\n<p>Create an image based on the Dockerfile.<br \/>\nDocker build tomcat tomcat<\/p>\n<p>Install weblogic image<\/p>\n<p>The steps and tomcat basically the same, posted here configuration file<br \/>\nsupervisor.conf<br \/>\n[supervisord]<br \/>\nnodaemon=true<\/p>\n<p>[program:weblogic]<br \/>\ncommand=\/opt\/Middleware\/user_projects\/domains\/base_domain\/bin\/startWebLogic.sh<\/p>\n<p>[program:sshd]<br \/>\ncommand=\/usr\/sbin\/sshd -D<br \/>\ndockerfile<br \/>\nFROM weblogic\u00a0EXPOSE<br \/>\n22 7001<br \/>\nCMD [&#8220;\/usr\/bin\/supervisord&#8221;]<\/p>\n<p>Use of the tomcat\/weblogic image<\/p>\n<p>Use of storage<\/p>\n<p>At startup, use the -v parameter<br \/>\n-v, &#8211;volume=[] Bind mount a volume (eg from the host: -v \/host:\/container, from docker: -v \/container)<\/p>\n<p>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.<\/p>\n<p>Implementation of tomcat and weblogic clusters<\/p>\n<p>Tomcat just need to open multiple containers<br \/>\ndocker run -d -v -p 204:22 -p 7003:8080 -v \/home\/data:\/opt\/data -name tm1 tomcat \/usr\/bin\/supervisord<br \/>\ndocker run -d -v -p 205:22 -p 7004:8080 -v \/home\/data:\/opt\/data &#8211;name tm2 tomcat \/usr\/bin\/supervisord<br \/>\ndocker run -d -v -p 206:22 -p 7005:8080 -v \/home\/data:\/opt\/data &#8211;name tm3 tomcat \/usr\/bin\/supervisord<\/p>\n<p>Here to talk about weblogic configuration, we all know that weblogic has a domain concept.\u00a0If 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:<\/p>\n<ul>\n<li>You can use weblogic clustering, synchronization and other concepts<\/li>\n<li>To deploy a clustered application, you only need to install the application once on the cluster.<\/li>\n<\/ul>\n<p>weakness is:<\/p>\n<ul>\n<li>Docker configuration is complicated<\/li>\n<li>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<\/li>\n<\/ul>\n<p>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.\u00a0(It is recommended to use this method to deploy the development and test environment)<br \/>\ndocker run -d -v -p 204:22 -p 7001:7001 -v \/home\/data:\/opt\/data -name node1 weblogic \/usr\/bin\/ Supervisord<br \/>\ndocker run -d -v -p 205:22 -p 7002:7001 -v \/home\/data:\/opt\/data -name node2 weblogic \/usr\/bin\/supervisord<br \/>\ndocker run -d -v -p 206:22 -p 7003:7001 -v \/home\/data:\/opt\/data &#8211;name node3 weblogic \/usr\/bin\/supervisord<\/p>\n<p>In this way, using nginx as the load balancer in the front end can complete the configuration.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install Tomcat image<\/p>\n<p>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<\/p>\n<p>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 [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7347"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7347"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7347\/revisions"}],"predecessor-version":[{"id":7348,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7347\/revisions\/7348"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}