JAVAEE - yicube mall 14: project deployment planning, Tomcat hot deployment, reverse agent configuration

Posted by tbeinc on Sun, 05 Jan 2020 06:10:16 +0100

1. Learning plan

1. System deployment

 

2. Project deployment

 

2.1. Explanation of project structure

 

 

 

2.2. network topology

 

 

 

2.3. System deployment

2.3.1. Deployment Analysis

e3-manager

e3-manager-web

e3-portal-web

e3-content

e3-search

e3-search-web

e3-item-web

e3-sso

e3-sso-web

e3-cart-web

e3-order

e3-order-web

 

 

 

A total of 48 servers are required.

 

Build pseudo distribution.

 

2.3.2. Server planning

 

 

2.3.3. Domain name planning

Serial number

project name

domain name

1

e3-manager-web

manager.e3mall.cn

2

e3-portal-web

www.e3mall.cn

3

e3-search-web

search.e3mall.cn

4

e3-item-web

item.e3mall.cn

5

e3-sso-web

sso.e3mall.cn

6

e3-cart-web

cart.e3mall.cn

7

e3-order-web

order.e3mall.cn

 

 

2.3.4. Tomcat hot deployment

You can use maven to implement Tomcat hot deployment. Deploy the project when Tomcat starts.

Tomcat has a background management function, which can realize project hot deployment.

Configuration method:

Step 1: you need to modify the conf/tomcat-users.xml configuration file of Tomcat. Add user name, password and permission.

<role rolename="manager-gui" />

<role rolename="manager-script" />

<user username="tomcat" password="tomcat" roles="manager-gui, manager-script"/>

Step 2: restart tomcat.

 

Use maven's tomcat plug-in to implement hot deployment:

Step 1: to configure the tomcat plug-in, you need to modify the pom file of the project.

 

<build>
        <plugins>
            <!-- To configure Tomcat Plug-in unit -->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <configuration>
                    <port>8081</port>
                    <path>/</path>
                    <url>http://192.168.25.135:8080/manager/text</url>
                    <username>tomcat</username>
                    <password>tomcat</password>
                </configuration>        
            </plugin>
        </plugins>
    </build>

 

 

Step 2: deploy using the maven command.
tomcat7:deploy

tomcat7:redeploy

The deployment path is "/" which will deploy the system to the webapps/ROOT directory.

Deployment project skip test:

clean tomcat7:redeploy -DskipTests

 

2.3.5. Project deployment

Each project runs on a different tomcat, changing the port number of Tomcat.

 

2.4. Configuration of reverse agent

The host file needs to be modified when the domain name is used to access the website during the test.

All domain names should point to the reverse proxy server.

 

To configure the hosts file:

192.168.25.141 manager.e3mall.cn

192.168.25.141 www.e3mall.cn

192.168.25.141 search.e3mall.cn

192.168.25.141 item.e3mall.cn

192.168.25.141 sso.e3mall.cn

192.168.25.141 cart.e3mall.cn

192.168.25.141 order.e3mall.cn

 

 

Configuration of reverse agent:

#user  nobody;
worker_processes  1;

#error_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  0;
    keepalive_timeout  65;

    #gzip  on;

    upstream manager.e3mall.cn {
    server 192.168.25.137:8080;
    }
    upstream www.e3mall.cn {
    server 192.168.25.137:8081;
    }
    upstream search.e3mall.cn {
    server 192.168.25.137:8082;
    }
    upstream item.e3mall.cn {
    server 192.168.25.138:8080;
    }
    upstream sso.e3mall.cn {
    server 192.168.25.138:8081;
    }
    upstream cart.e3mall.cn {
    server 192.168.25.139:8080;
    }
    upstream order.e3mall.cn {
    server 192.168.25.139:8081;
    }
    
   server {
        listen       80;
        server_name  manager.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://manager.e3mall.cn;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  www.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://www.e3mall.cn;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  search.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://search.e3mall.cn;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  item.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://item.e3mall.cn;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  sso.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://sso.e3mall.cn;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  cart.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://cart.e3mall.cn;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  order.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://order.e3mall.cn;
            index  index.html index.htm;
        }
    }
    
}

Topics: Java Tomcat Maven network xml