+ Version of the software infrastructure:
1,3 units centos7 systems, which have been configured the jdk environment, the version of jdk
[root@node03 bin]# java -version java version "1.8.0_144" Java(TM) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
The specific configuration of linux jdk seen other articles
2, extract the linux version of tomcat, version as follows:
[root @ node02 soft] # ll total volume of 191220 -rw-R & lt - r--. 1 the root the root 10.29122 million. 11 dated 26 15:44 apache-tomcat-8.5.49.tar.gz
3、
[root@node02 soft]# ll
The total amount of 182.06 thousand drwxr -XR-X. . 8 10 143 255 . 7 dated 22 is 2017 jdk1. . 8 .0_144 -rw-R & lt - r--. . 1 the root the root 185 515 842 . 9 dated . 4 . 17 : 09 JDK-8u144 Linux-- x64-. the tar.gz drwxr -XR-X . 9 Nginx Nginx 186 . 11 dated 26 is 16 : 58 nginx- 1.10 . 2 -rw-R & lt - r-- the root the root. 1 910 812 dated 10 18 2016 nginx-1.10.2.tar.gz
Centos three aliases and ip is: The following is three virtual machines
192.168.27.202 node02
192.168.27.203 node03
192.168.27.204 node04
Which node02 and node03 is to install two tomcat, tomcat cluster built with
node04 is to build nginx load balancing server
1. Configure tomcat jdk environment to build a cluster of two servers
step:
2, node02 above installation tomcat:
[Root @ node02 soft] # tar zxfapache-tomcat-8.5.49.tar.gz
After unpacking is completed
Create a jsp page in the tomcat webapps ROOT following decompression directory for testing whether tomcat installation is successful
The creation of specific jsp and validation process is as follows:
Command in the ROOT directory of tomcat:
[root @ node03 ROOT] # vim test.jsp write a test page
[root@node03 ROOT]# cat test.jsp
[root@node03 ROOT]# more test.jsp
server03:the time is: <%=new java.util.Date()%>
[root@node03 ROOT]#
[root@node03 ROOT]# ll 总用量 184 -rw-r----- 1 root root 27235 11月 18 02:48 asf-logo-wide.svg -rw-r----- 1 root root 713 11月 18 02:46 bg-button.png -rw-r----- 1 root root 1918 11月 18 02:46 bg-middle.png -rw-r----- 1 root root 1401 11月 18 02:46 bg-nav.png -rw-r----- 1 root root 3103 11月 18 02:46 bg-upper.png -rw-r----- 1 root root 21630 11月 18 02:46 favicon.ico -rw-r----- 1 root root 12219 11月 18 02:48 index.jsp -rw-r----- 1 root root 7136 11月 18 02:48 RELEASE-NOTES.txt -rw-r--r-- 1 root root 48 11月 26 16:24 test.jsp -rw-r----- 1 root root 5581 11月 18 02:48 tomcat.css -rw-r----- 1 root root 2066 11月 18 02:46 tomcat.gif -rw-r----- 1 root root 5103 11月 18 02:46 tomcat.png -rw-r----- 1 root root 2376 11月 18 02:46 tomcat-power.gif -rw-r----- 1 root root 67795 11月 18 02:48 tomcat.svg drwxr-x--- 2 root root 21 11月 26 15:52 WEB-INF [root@node03 ROOT]# pwd /opt/soft/apache-tomcat-8.5.49/webapps/ROOT [root@node03 ROOT]#
After on your local machine, the browser test,
Tomcat that enter the installation of these machines ip: 8080 / test.jsp if we can enter the page, it means that the configuration is successful
test.jsp page test results are as follows:
Node03 same configuration and performs the same detection
2, nginx server environment node04 to build:
Compile nginx load balancing configuration:
[root @ node04] # tar zxf nginx- 1.10 . 2 Tar.gz
After unzipping is complete:
I did not sticky configuration module, this is a person by means of pictures online, ha ha, I forgot to screenshot
Make the following configuration changes after installation
[root @ node04 nginx-1.10.2] # vim Auto / CC / gcc 179 # CFLAGS = " $ CFLAGS -g " ## comment out this line, ignored by the compiler information, installed capacity less.
[@ node04 Nginx the root-1.10.2] # yum the install GCC PCRE OpenSSL-devel-devel - Y
[@ node04 Nginx the root-1.10.2] # # Note that this latter ./configure parameters may be found in: prefix and other parameters such as, in particular meaning of parameters: see link: https: //blog.csdn.net/qq_32907349/article/details/53814194
Then
[@ node04 Nginx the root-1.10.2] # yum the install GCC PCRE OpenSSL-devel-devel - Y [@ node04 Nginx the root-1.10.2] # ./configure
# parameters may specify:
[root@server6 nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-threads --user=nginx --group=nginx --add-module=/root/nginx-sticky-module-ng
But I did not specify:
[root @ node04 nginx-1.10.2] # the make the make install && compiled trilogy
[root @ node04 nginx- 1.10 . 2 ] # useradd-establish nginx user [root @ node04 sbin] # cd / usr / local / nginx / sbin / nginx following sbin directory below nginx command, you can start by nginx ./nginx ,
############### important to note that the above process of installing the nginx: configuration
After entering the address http in the browser of this machine: //192.168.27: 80 /
If you see the following page, that is, the installation was successful
that is, nginx welcome success
After that you need to configure nginx integrated tomcat cluster:
Configuration is as follows
Note nginx.conf is / usr / local / nginx / conf of nginx.conf, rather than under the conf, no nginx.conf nginx files in the installation directory under the installation directory conf below
[root@node04 nginx]# ll
总用量 4
drwx------ 2 nobody root 6 11月 26 17:14 client_body_temp
drwxr-xr-x 2 root root 4096 11月 26 17:42 conf
drwx------ 2 nobody root 6 11月 26 17:14 fastcgi_temp
drwxr-xr-x 2 root root 40 11月 26 17:03 html
drwxr-xr-x 2 root root 58 11月 26 17:14 logs
drwx------ 2 nobody root 6 11月 26 17:14 proxy_temp
drwxr-xr-x 2 root root 19 11月 26 17:03 sbin
drwx------ 2 nobody root 6 11月 26 17:14 scgi_temp
drwx------ 2 nobody root 6 11月 26 17:14 uwsgi_temp
[root@node04 nginx]# cd conf
[root@node04 conf]# pwd
/usr/local/nginx/conf
[root@node04 conf]#
具体的配置如下:
[root@node04 conf]# ll 总用量 64 -rw-r--r-- 1 root root 1077 11月 26 17:03 fastcgi.conf -rw-r--r-- 1 root root 1077 11月 26 17:03 fastcgi.conf.default -rw-r--r-- 1 root root 1007 11月 26 17:03 fastcgi_params -rw-r--r-- 1 root root 1007 11月 26 17:03 fastcgi_params.default -rw-r--r-- 1 root root 2837 11月 26 17:03 koi-utf -rw-r--r-- 1 root root 2223 11月 26 17:03 koi-win -rw-r--r-- 1 root root 3957 11月 26 17:03 mime.types -rw-r--r-- 1 root root 3957 11月 26 17:03 mime.types.default -rw-r--r-- 1 root root 2731 11月 26 17:42 nginx.conf -rw-r--r-- 1 root root 2656 11月 26 17:24 nginx.conf.bak -rw-r--r-- 1 root root 2656 11月 26 17:03 nginx.conf.default -rw-r--r-- 1 root root 636 11月 26 17:03 scgi_params -rw-r--r-- 1 root root 636 11月 26 17:03 scgi_params.default -rw-r--r-- 1 root root 664 11月 26 17:03 uwsgi_params -rw-r--r-- 1 root root 664 11月 26 17:03 uwsgi_params.default -rw-r--r-- 1 root root 3610 11月 26 17:03 win-utf [root@node04 conf]# vim nginx.conf listen 80; server_name tomcat; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 location ~ \.jsp$ { proxy_pass http://tomcat; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # 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 8000; # 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 HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }
配置完毕之后:
在本机中的浏览器中输入nginx服务器的地址:+80端口+test.jsp见到 下面的界面则是成功了
第一次刷新和第二次,就会进入不同的tomcat服务器了
完毕!