On line project configuration of Linux system cluster architecture (3)

Time:2021-1-21

On line project configuration of Linux system cluster architecture (1)

On line project configuration of Linux Cluster Architecture (2)

The configuration operations of distribution file management, front-end reverse proxy and management background server were introduced in the front. Today, the configuration operations of front-end load and app server (users and businesses), official website and FTP server are introduced

1. Front end load balancing configuration

Install the required dependency packages

yum install pcre-devel zlib-devle openssl-devel gcc-c++ –y

Compile and install nginx

cd /download/tools/

wget http://nginx.org/download/nginx-1.12.1.tar.gz

tar zxf nginx-1.12.1.tar.gz

cd nginx-1.12.1

./configure --prefix=/app/nginx-1.12.1

make && make install

[[email protected] ~]# cd /app/

[[email protected] app]# ln -s nginx-1.12.1 nginx

[[email protected] ~]# cd /app/nginx/conf/

[[email protected] conf]# mkdir extra

[[email protected] conf]# cp nginx.conf nginx.conf.bak

stay nginx.conf Add the following configuration after the file

include extra/*.conf;

  

[[email protected] conf]# cd extra/

 [[email protected] extra]# vim user.app.conf

#

# HTTPS server configuration

#

upstream userapp {

      server 10.0.0.4:8080;

      server 10.0.0.4:8081;

}

server {

    listen       80;

    server_name app.mingongge.com;

    location / {

        proxy_pass http://userapp;

        proxy_connect_timeout 600;

        proxy_read_timeout 600;

        proxy_send_timeout 600;

  

}
[[email protected] conf]# cd extra/

[[email protected] conf]# vim sj.app.conf

#

# HTTPS server configuration

#

upstream sjapp {

      server 10.0.0.5:8080;

      server 10.0.0.5:8081;

}

  

server {

    listen       80;

    server\_name sjapp.mingongge.com;

    location / {

        proxy_pass http://sjapp;

        proxy_connect_timeout 600;

        proxy_read_timeout 600;

        proxy_send_timeout 600;

}

}

2. Back end app server configuration

Installation and configuration of Java environment of back end app server

[[email protected] tools]# ll

total 181168

-rw-r--r-- 1 root root 185515842 Sep 20 15:52 jdk-8u144-linux-x64.tar.gz

[[email protected] tools]# tar zxf jdk-8u144-linux-x64.tar.gz -C /usr/local/

[[email protected] tools]# ln -s /usr/local/jdk1.8.0_144 /usr/local/jdk

[[email protected] tools]# cat >>/etc/profile<<EOF

export JAVA_HOME=/usr/local/jdk

export CLASSPATH=.CLASSPATH:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$JAVA_HOME/bin:$PATH

EOF

[[email protected] tools]# tail -3 /etc/profile

export JAVA_HOME=/usr/local/jdk

export CLASSPATH=.CLASSPATH:/lib/dt.jar:/lib/tools.jar

export PATH=$JAVA_HOME/bin:$PATH

[[email protected] tools]# source /etc/profile

[[email protected] tools]# 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)

Back end Tomcat configuration

wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz

[[email protected] tools]# tar zxf apache-tomcat-8.5.20.tar.gz -C /usr/local/

[[email protected] tools]# ln -s /usr/local/apache-tomcat-8.5.20 /usr/local/tomcat

[[email protected] tools]# cd /usr/local/apache-tomcat-8.5.20/conf/

[[email protected] conf]# vim server.xml

-------------Omit n lines here--------------

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"

   prefix="localhost_access_log" suffix=".txt"

   pattern="%h %l %u %t &quot;%r&quot; %s %b" />

**<Context path="" docBase="/www/userapp" debug="0" reloadable="true" crossContext="true" />**
#Add the above site directory  

[[email protected] conf]# mkdir /www/userapp -p

echo "this is the frist userapp server" >/www/userapp/index.html
[[email protected] conf]# ../bin/startup.sh

Using CATALINA_BASE:   /usr/local/apache-tomcat-8.5.20

Using CATALINA_HOME:   /usr/local/apache-tomcat-8.5.20

Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.5.20/temp

Using JRE_HOME:  /usr/local/jdk

Using CLASSPATH: /usr/local/apache-tomcat-8.5.20/bin/bootstrap.jar:/usr/local/apache-tomcat-8.5.20/bin/tomcat-juli.jar

Tomcat started.

[[email protected] conf]# lsof -i :8080

COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

java 1587 root 48u IPv6 18137 0t0 TCP *:webcache (LISTEN)

Another user app server is configured as above

[[email protected] conf]# mkdir /www/userapp -p

echo "this is the second userapp ">/www/userapp/index.html

On line project configuration of Linux system cluster architecture (3)

Please refer to the above configuration for business app environment configuration

[[email protected] conf]# mkdir /www/sjapp -p

echo "this is the frist sjapp ">/www/userapp/index.html

echo "this is the second sjapp ">/www/userapp/index.html

Next, test load balancing

Front end load balancing test

[[email protected] conf]# curl http://10.0.0.1

this is the userapp server

[[email protected] conf]# curl http://10.0.0.1

this is the second userapp

[[email protected] conf]# curl http://app.mingongge.com

this is the userapp server

[[email protected] conf]# curl http://app.mingongge.com

this is the second userapp

[[email protected] extra]# curl http://sjapp.mingongge.com

this is the first sjapp server

[[email protected] extra]# curl http://sjapp.mingongge.com

this is the second sjapp

Browser access test

The hosts file needs to be configured for local browser testing

10.0.0.1 app.mingongge.com

10.0.0.1 sjapp.mingongge.com

On line project configuration of Linux system cluster architecture (3)

On line project configuration of Linux system cluster architecture (3)

3. Configuration of official website and image server

The basic architecture also uses reverse proxy to expand the overall architecture

The installation of nginx FTP is no longer described. It’s too simple and tiring

The reverse proxy configuration is as follows


[[email protected] extra]# vim web.mingongge.conf
#

# HTTPS server configuration

# 

server {

    listen       80;

    server_name www.mingongge.com;

    location / {

        proxy_pass http://10.0.0.8;

        proxy_connect_timeout 600;

        proxy_read_timeout 600;

        proxy_send_timeout 600;  

}

}
[[email protected] extra]# vim ftp.mingongge.com
#
# HTTPS server configuration
#

server {

    listen       80;

    server\_name ftp.mingongge.com;

    location / {

        proxy_pass http://10.0.0.8:88;

        proxy_connect_timeout 600;

        proxy_read_timeout 600;

        proxy_send_timeout 600;  

}

}

Back end web server configuration

[[email protected] html]# vim index.html

welcome to mingongge.s web stie!!!!!!!!!!!!!

[[email protected] ~]# /usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

[[email protected] ~]# /usr/local/nginx/sbin/nginx

[[email protected] ~]# curl 10.0.0.8

welcome to mingongge.s web stie!!!!!!!!!!!!!

FTP configuration is actually the management background uploading pictures through the application program. The front users can access the correct page through nginx. Because of the offline test environment, it is impossible to do experiments with production code, so the management background uploading pictures can not be simulated. The process is that the background uploading pictures are uploaded to the specified directory through FTP function, and then the front end is uploaded through nginx To call this image to display

Therefore, you can access the picture under the configuration

[[email protected] conf]# cd extra/

[[email protected] extra]# vim ftp.mingongge.conf

server {

   listen       88;

    server_name  localhost;  

 location / {

    root   /www/ftp;

      }

Upload pictures for testing

On line project configuration of Linux system cluster architecture (3)

Through the front-end reverse proxy direct access to the domain name to read the map, to achieve the function of calling the picture application in other front page display function

On line project configuration of Linux system cluster architecture (3)

Discovery can also be accessed normally