Abstract

Taking the Mall swarm project as an example, this paper mainly introduces how an e-commerce project with micro-service architecture is deployed under Docker container, which involves the deployment of a large number of system components and the deployment of several Spring Cloud micro-service applications, based on CentOS7.6.

Environment set up

Basic Environment Deployment

The system components required for the operation of mall-swarm are as follows. The method of installing these components in Docker container can be directly referred to the article: The deployment of mall in Linux environment (based on Docker container).

component The version number
JDK 1.8
Mysql 5.7
Redis 3.2
Elasticsearch 6.4.0
MongoDb 3.2
RabbitMq 3.7.15
Nginx 1.10

Image package upload

A total of 8 application services need to be packaged into Docker images. For details, please refer to building Docker images using Maven plug-ins. Note that if you cannot find mall-common, mall- MBG, or mall- Security during the package process, install these modules to the local Maven repository first and then package them.

application The version number
mall-registry 1.8
mall-config 5.7
mall-monitor 3.2
mall-gateway 6.4.0
mall-admin 3.2
mall-portal 3.7.15
mall-search 1.10
mall-demo 1.10

After the image is packaged and uploaded, the complete docker warehouse image diagram is as follows:

Application deployment

Deploy the mall – registry

  • Run the registry with the following commandmall-registry:
docker run -p 8001:8001 --name mall-registry \
-v /etc/localtime:/etc/localtime \
-v /mydata/app/mall-registry/logs:/var/logs \
-dMall/mall - registry: 1.0 the SNAPSHOTCopy the code
  • After the success of the operation, by visiting the address to view the registry console: http://192.168.6.132:8001/

Deploy the mall – config

  • Run the configuration center using the following commandmall-config:
docker run -p 8301:8301 --name mall-config \
--link mall-registry:mall-registry \
-v /etc/localtime:/etc/localtime \
-v /mydata/app/mall-config/logs:/var/logs \
-dMall/mall - config: 1.0 the SNAPSHOTCopy the code
  • After the success of the operation, by visiting the address can view the mall – admin in the prod environment configuration information: http://192.168.6.132:8301/master/admin-prod.yml

  • It is important to note that in the proD environment, the git repository configuration is obtained from the configuration center. If you want to change the git repository configuration, you need to change the configuration file application. Yml of the mall-config module to your own.

spring:
  cloud:
    config:
      server:
        git: Git repository storage
          uri: https://gitee.com/macrozheng/mall-config.git Change to your own configuration
          username: macro
          password: 123456
          clone-on-start: true
          search-paths: '{application}'
Copy the code

Deploy the mall – monitor

  • Run the following command to run the monitoring centermall-monitor:
docker run -p 8101:8101 --name mall-monitor \ --link mall-registry:mall-registry \ -v /etc/localtime:/etc/localtime \ -v  /mydata/app/mall-monitor/logs:/var/logs \-dMall/mall - monitor: 1.0 the SNAPSHOTCopy the code
  • After running, you can use this address to view the monitoring center information. The account password ismacro:123456:http://192.168.6.132:8101

Deploy the mall – gateway

  • Run the following command to run the gateway servicemall-gateway:
docker run -p 8201:8201 --name mall-gateway \ --link mall-registry:mall-registry \ -v /etc/localtime:/etc/localtime \ -v  /mydata/app/mall-gateway/logs:/var/logs \-dMall/mall - gateway: 1.0 the SNAPSHOTCopy the code
  • Run after the completion of the can look at dynamic routing rules by the address: http://192.168.6.132:8201/actuator/gateway/routes

Deploy the mall – admin

  • Run the following command to run the background servicemall-admin:
docker run -p 8180:8180 --name mall-admin \
--link mysql:db \
--link mall-registry:mall-registry \
-v /etc/localtime:/etc/localtime \
-v /mydata/app/mall-admin/logs:/var/logs \
-dMall/mall - admin: 1.0 the SNAPSHOTCopy the code
  • throughmall-gatewayGateway Service Access Interface documentation:http://192.168.6.132:8201/mall-admin/swagger-ui.html

Deploy the mall – portal

  • Run the foreground service with the following commandmall-portal:
docker run -p 8085:8085 --name mall-portal \
--link mysql:db \
--link redis:redis \
--link mongo:mongo \
--link rabbitmq:rabbit \
--link mall-registry:mall-registry \
-v /etc/localtime:/etc/localtime \
-v /mydata/app/mall-portal/logs:/var/logs \
-dMall/mall - portal: 1.0 the SNAPSHOTCopy the code
  • throughmall-gatewayGateway Service Access Interface documentation:http://192.168.6.132:8201/mall-portal/swagger-ui.html

Deploy the mall – search

  • Run the following command to run the search servicemall-search:
docker run -p 8081:8081 --name mall-search \
--link mysql:db \
--link elasticsearch:es \
--link mall-registry:mall-registry \
-v /etc/localtime:/etc/localtime \
-v /mydata/app/mall-search/logs:/var/logs \
-dMall/mall - search: 1.0 the SNAPSHOTCopy the code
  • throughmall-gatewayGateway Service Access Interface documentation:http://192.168.6.132:8201/mall-search/swagger-ui.html

Deploy the mall – demo

  • Run the test service with the following commandmall-demo:
docker run -p 8082:8082 --name mall-demo \
--link mysql:db \
--link mall-registry:mall-registry \
-v /etc/localtime:/etc/localtime \
-v /mydata/app/mall-demo/logs:/var/logs \
-dMall/mall - demo: 1.0 the SNAPSHOTCopy the code
  • throughmall-gatewayGateway Service Access Interface documentation:http://192.168.6.132:8201/mall-demo/swagger-ui.html

Run to complete the effect display

  • Registry Console information:

  • Monitoring center application information:

Visual management tool

Portainer is a lightweight application, it provides a graphical interface for convenient management of Docker environment, including standalone environment and cluster environment, we will use Portainer to manage Docker container applications.

  • Official website: github.com/portainer/p…

  • Docker image file:

docker pull portainer/portainer
Copy the code
  • Run Portainer with docker container:
docker run -p 9000:9000 -p 8000:8000 --name portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /mydata/portainer/data:/data \
-d portainer/portainer
Copy the code
  • To view Portainer’s DashBoard information:

  • View information about all running containers:

  • View all Docker images that have been downloaded:

  • To viewmall-portalApplication statistics:

  • To viewmall-portalLogs generated during application running:

  • Enter themall-portalTo operate the container’s internal system:

The project address

Github.com/macrozheng/…

The public,

Mall project full set of learning tutorials serialized, attention to the public number the first time access.