Docker配置1台Nginx+3台Tomcat做负载均衡.docx

上传人:A*** 文档编号:142725256 上传时间:2020-08-22 格式:DOCX 页数:6 大小:172.34KB
返回 下载 相关 举报
Docker配置1台Nginx+3台Tomcat做负载均衡.docx_第1页
第1页 / 共6页
Docker配置1台Nginx+3台Tomcat做负载均衡.docx_第2页
第2页 / 共6页
Docker配置1台Nginx+3台Tomcat做负载均衡.docx_第3页
第3页 / 共6页
Docker配置1台Nginx+3台Tomcat做负载均衡.docx_第4页
第4页 / 共6页
Docker配置1台Nginx+3台Tomcat做负载均衡.docx_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《Docker配置1台Nginx+3台Tomcat做负载均衡.docx》由会员分享,可在线阅读,更多相关《Docker配置1台Nginx+3台Tomcat做负载均衡.docx(6页珍藏版)》请在金锄头文库上搜索。

1、Docker配置1台Nginx+3台Tomcat做负载均衡环境&结构1台Nginx最新版本的Docker容器,3台Tomcat8的Docker容器准备Docker环境如果不是最新版的Docker的话,如果版本差别太大的话,可能会出问题,所以大家要把Docker升级到最新版,或者直接安装最新版。可以参考:Centos7-Docker卸载旧的更新到新版本拉取相应的镜像准备镜像:1、tomcat 2、nginx拉取相应的对象:rootzh # docker pull tomcat:jdk8-adoptopenjdk-hotspotrootzh # docker pull nginx:latestro

2、otzh # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmysql 5.7.29 d5cea958d330 40 hours ago 440MBtomcat jdk8-adoptopenjdk-hotspot ae9ec2a81228 10 days ago 324MBnginx latest 2073e0bcb60e 2 weeks ago 127MBrootzh # 启动容器启动Tomcat:rootzh # docker run -d -p 8081:8080 -name myt1 -privileged=true ae9ec2a8

3、1228rootzh # docker run -d -p 8082:8080 -name myt2 -privileged=true ae9ec2a81228rootzh # docker run -d -p 8083:8080 -name myt3 -privileged=true ae9ec2a81228正在运行的结果:rootzh # docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESc33dde60b4ac ae9ec2a81228 catalina.sh run 7 hours ago Up 7 hours

4、0.0.0.0:8083-8080/tcp myt39397416d13b0 ae9ec2a81228 catalina.sh run 7 hours ago Up 7 hours 0.0.0.0:8082-8080/tcp myt2bf6b880e1398 ae9ec2a81228 catalina.sh run 7 hours ago Up 7 hours 0.0.0.0:8081-8080/tcp myt1rootzh # 启动Nginx:在启动之前呢有必要跟大家说一下:因为后来咱们需要编辑nginx的配置文件,也为了后来咱们好看日志文件,咱们可以做一个配置文件的映射首先呢,准备文件:r

5、ootzh # mkdir /data/nginx/rootzh # mkdir /data/nginx/conf/rootzh # mkdir /data/nginx/logs/rootzh # touch /data/nginx/conf/nginx.conf 然后我们先把配置文件nginx.conf配置好:# For more information on configuration, see:# * Official English Documentation: http:/nginx.org/en/docs/# * Official Russian Documentation: ht

6、tp:/nginx.org/ru/docs/user nginx;worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;# Load dynamic modules. See /usr/share/nginx/README.dynamic.include /usr/share/nginx/modules/*.conf;events worker_connections 1024;http log_format main $remote_addr - $remote_user $time_local

7、 $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for; access_log /var/log/nginx/access.log main;/data/nginx/conf/nginx.conf 68L, 1836C# For more information on configuration, see:# * Official English Documentation: http:/nginx.org/en/docs/# * Official Russian Docum

8、entation: http:/nginx.org/ru/docs/user nginx;worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;# Load dynamic modules. See /usr/share/nginx/README.dynamic.include /usr/share/nginx/modules/*.conf;events worker_connections 1024;http log_format main $remote_addr - $remote_user

9、 $time_local $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-st

10、ream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http:/nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server listen 80 default_server; listen :80 default_server; server_name 182.254.161.54; root /usr/share/

11、nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / proxy_pass http:/pic; error_page 404 /404.html; location = /40x.html error_page 500 502 503 504 /50x.html; location = /50x.html upstream pic server :8081 weight=5; server :8082 weight

12、=5; server :8083 weight=5; 重点是修改:upstream pic server ip:port weight=5; server ip:port weight=5; server ip:port weight=5;如果不知道ip的话,可以利用下面的命令查看:查看所有的ip地址rootzh # docker inspect $(docker ps -qa) | grep IPAddress SecondaryIPAddresses: null, IPAddress: 172.17.0.5, IPAddress: 172.17.0.5, SecondaryIPAddresses: null, IPAddress: , IPAddress

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > IT计算机/网络 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号