In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to achieve load balancing under the Windows system by nginx+tomcat". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to achieve load balancing under the Windows system by nginx+tomcat".
First of all, install two tomcat, either the same copy into two, or you can download two different versions of tomcat, I just downloaded two different versions.
This is version 8.0, just find two versions that are not very old.
Then start two tomcat, before starting, change the port number of one of them, so that when the two tomcat start up, there will be no port conflict, one is its own port 8080, the other is changed to port 9080. After the configuration is completed, open the cmd command window, put one of my tomcat in the d:\ software\ apache-tomcat-8.5.24 directory, and start it according to the following command. If you start successfully, another window will pop up, as shown below:
Open the browser, type http://localhost:9080/, and the following interface appears, that is, tomcat starts successfully. The other can take the same steps.
Figure 1:tomcat8 figure 2:tomcat7
After that, install a nginx. I installed a stable version of nginx. Download address: http://nginx.org/download/nginx-1.12.2.zip. Decompress it and use it.
Before starting, you must configure nginx to achieve load balancing. Open the conf folder and there is a nginx.conf file below. The configuration is as follows:
# user nobody;worker_processes 1 the errorless log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;} http {include mime.types;default_type application/octet-stream # log_format main'$remote_addr-$remote_user [$time_local] "$request" #'$status $body_bytes_sent "$http_referer" #'"$http_user_agent"$http_x_forwarded_for"'; # access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0keepalivekeeper timeout 65gzip on
# the following four lines are newly added. Two ip are the access addresses of two tomcat. Weight represents the proportion of requests allocated to the server. If both are 1, they will be assigned according to 1:1.
Upstream netitcast.com {server 127.0.0.1 weight=1;server 8080 weight=1;server 127.0.0.1 weight=1;server 9080 weight=2;} server {listen 80th serverkeeper name localhost;#charset koi8-r;#access_log logs/host.access.log main
# the following two lines are modified, and the http://netitcast.com should be consistent with the one added above
Location / {proxy_pass http://netitcast.com; proxy_redirect default;} # error_page 404 / 404.htmlX # redirect server error pages to the static page / 50x.html#error_page 500502 503504 / 50x.htmlShield location = / 50x.html {root html;} # proxy the php scripts to apache listening on 127.0.0.1:80##location ~\. Php$ {# proxy_pass http://127.0.0.1; #} # pass the php scripts to fastcgi server listening on 127.0.0.1:9000##location ~\. Php$ {# root html;# fastcgi_pass 127.0.0.1 fastcgi_index index.php;# fastcgi_param script_filename / scripts$fastcgi_script_name;# include fastcgi_params;#} # deny access to .htaccess files, if apache's document root# concurs with nginx's one##location ~ /\ .ht {# deny all #}} # another virtual host using mix of ip-, name-, and port-based configuration##server {# listen 8000X # listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;#} #} # https server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:ssl:1m;# ssl_session_timeout 5m # ssl_ciphers highlyanullrizationmd5position # ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;#} #}}
Or open the cmd window, enter the above directory, execute the command: start nginx starts successfully, and then enter the URL: http://localhost/index.jsp, continue to visit, you will find that figure 1 and figure 2 shown above are displayed interactively. Because the above configuration weight is allocated by the proportion of 1:2, so the proportion of port 9080 is larger, the probability of accessing figure 1 (port 9080) is larger, and the probability of accessing figure 2 (port 8080) is relatively small, one is 2/3 and the other is 1/3.
At this point, I believe you have a deeper understanding of "how to achieve load balancing under the Windows system by nginx+tomcat". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.