In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Start with the architecture, as shown in the figure:
1. The front-end export service is Ali SLB
The 2.Zookeeper cluster provides a registry for the entire microservice environment, and the IP of each znode in the Zookeeper cluster is fixed and is also configured by the config-service service.
3. Centralized configuration service config-service, configuration files are centrally managed by git, and config-service configuration maps to a directory of the host. If you need to modify the configuration directly in the Git, trigger the git pull operation in the directory mapped by the host, and then restart the corresponding provider, and the configuration will take effect.
4.facade acts as a distributor for distribution services.
Micro-service workflow:
1) provider starts, reads the dead config-service configuration service, obtains the Zookeeper address from the configuration service, and registers.
2) the request is distributed by Ali SLB to the corresponding microservice facade, and the gateway goes to the Zookeeper cluster registry to obtain available services.
3) after obtaining the available provider, facade distributes the request, and the policy is polling.
4) if the backend provider fails to provide the service, the Zookeeper will automatically delete the registration of the service.
Establish micro-service basic running environment, gateway gateway, Zookeeper registry, config-service configuration basic running environment. Start building the above basic operating environment:
First, create zookeeper3.4.10 cluster service
Need to include jdk and configured environment variables of the image, jdk1.8 image.
Jdk1.8 image is delivered to Aliyun Docker Registry repository
Docker Rancher host
1. Download the jdk1.8.0_25.tar package and download it yourself.
Create jdk to build build directory
Mkdir-p / data/docker/ms-jdkll-rw-r--r-- 1 root root 155 Dec 29 15:11 dockerfiledrwxr-xr-x 9 root root 268 Nov 17 2017 jdk1.8.0_25
two。 Write dockfile
Cat dockerfile
FROM centosMAINTAINER jdk1.8 "name@alaxiaoyou.com" ADD jdk1.8.0_25/ / usr/local/jdk1.8ENV JAVA_HOME/ usr/local/jdk1.8ENV PATH $JAVA_HOME/bin:$PATH
3. Construction
[root@rancher-qa ms-jdk] # docker build-t ms/jdk1.8:v1 .Sending build context to Docker daemon 308.6MBStep 1 1e1148e4cc2cStep 5: FROM centoslatest: Pulling from library/centosa02a4930cb5d: Pull complete Digest: sha256:184e5f35598e333bfa7de10d8fb1cebb5ee4df5bc0f970bf2b1e7c7345136426Status: Downloaded newer image for centos:latest-> 1e1148e4cc2cStep 2 yuhuanghui@alaxiaoyou.com 5: MAINTAINER jdk1.8 "yuhuanghui@alaxiaoyou.com"-> Running in 74ba397d2ab5-- > 57601effbcb9Removing intermediate container 74ba397d2ab5Step 3 Running in 74ba397d2ab5 5: ADD jdk1.8.0_25/ / usr/local/jdk1.8-- -> e960522c0399Removing intermediate container 9408672a94d9Step 4 JAVA_HOME/bin:$PATH 5: ENV JAVA_HOME/ usr/local/jdk1.8-- > Running in 42d9c2b3239c-> 9bb3badf22e0Removing intermediate container 42d9c2b3239cStep 5 00d3c71ae0beRemoving intermediate container d8af2f726409Successfully built 00d3c71ae0beSuccessfully tagged ms/jdk1.8:v1 5: ENV PATH $JAVA_HOME/bin:$PATH-- > Running in d8af2f726409-- > 00d3c71ae0beRemoving intermediate container d8af2f726409Successfully built 00d3c71ae0beSuccessfully tagged ms/jdk1.8:v1
Docker images View
4. Log in to Ali Cloud Container Image Service
Create image repository name ms-jdk1.8
5. Mirror push to Ali Cloud Docker Registry
Switch to rancher/server
Log in to Aliyun Docker Registry
Log in to Docker Registry-> type tag-> push to Docker Registry
[root@rancher-qa ms-jdk] # docker login-- username=name@alaxiaoyou.com registry.cn-hangzhou.aliyuncs.comPassword: * Login Succeeded [root@rancher-qa ms-jdk] # [root@rancher-qa ms-jdk] # docker tag 00d3c71ae0be registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/ms-jdk1.8:v1.0 [root@rancher-qa ms-jdk] # docker push registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/ms-jdk1 .8: v1.0The push refers to a repository [registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/ms-jdk1.8] 96f6833b8de8: Pushed 071d8bd76517: Pushed v1.0: digest: sha256:1c2f642e7e49cd607c36032612efcd875c191abc5edb642d7e86483d1d5b392d size: 742
View:
At this point, the ms-jdk1.8 image delivery is complete.
Create a zookeeper3.4.10 cluster and deliver the Zookeeper3.4.10 image to the Aliyun Docker Registry repository.
Preparation of 1.zookeeper3.4.10 cluster construction prerequisites:
The zookeeper3.4.10 cluster needs to specify the ip and port of each elected node in its configuration file, and in the datadir (zoo.cfg configuration: dataDir=/tmp/zookeeper) in the zookeeper cluster, you need to specify the myid of the node to complete the Zookeeper cluster construction. If you do not use the docker link feature, you need to solve the problem of containerizing Zookeeper clusters:
1) .myid problem.
2) .Zookeeper cluster node (leader, follower) election configuration.
You can use the built-in volume feature of docker to map the configuration file and the datadir of Zookeeper to the host for management.
For example, in rancher:
Therefore, the host must exist:
1) the zookeeper-config/, directory is all the configuration files of Zookeeper, including the election node IP and election port of the cluster, in the main zoo.cfg file.
Ll zookeeper-config/total 16 root root Jan 4 17:43 configuration.xsl-rw-r--r-- 1 root root 2161 Jan 4 17:43 log4j.properties-rw-r--r-- 1 root root 1012 Jan 4 17:43 zoo.cfg-rw-r--r-- 1 root root 922 Jan 4 17:43 zoo_sample.cf
2) the zookeeper-data01/, directory corresponds to the datadir in the zookeeper cluster, and a myid file is stored. The data generated after the startup of the Zookeeper cluster will also be persisted to this host directory. The Zookeeper cluster has three znode nodes, so datadir has:
Zookeeper-data02/
Zookeeper-data03/
Ll / data/docker/drwxr-xr-x 3 root root 48 Jan 5 17:25 ms-zookeeper3.4.10drwxr-xr-x 2 root root 92 Jan 5 16:54 zookeeper-configdrwxr-xr-x 2 root root 18 Jan 4 17:59 zookeeper-data01drwxr-xr-x 2 root root 18 Jan 4 18:02 zookeeper-data02drwxr-xr-x 2 root root 18 Jan 4 18:02 zookeeper-data03
two。 Mirror image construction
2.1 download the zookeeper-3.4.10.tar.gz package
Wget https://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
Create zookeeper-3.4.10 to build build directory
Mkdir-p / data/docker/ms-zookeeper3.4.10/-rw-r--r-- 1 root root 207Jan 4 18:58 dockerfiledrwxr-xr-x 10 root root 4096 Mar 23 2017 zookeeper-3.4.10
2.2 write dockfile
Vim / data/docker/ms-zookeeper3.4.10/dockerfile
FROM ms/jdk1.8:v1MAINTAINER zookeeper3.4.10 "name@alaxiaoyou.com" ADD zookeeper-3.4.10/ / usr/local/zookeeper/WORKDIR / usr/local/zookeeperENTRYPOINT. / bin/zkServer.sh start & & tail-f zookeeper.out
The zookeeper-3.4.10 directory is added to the image and delivered. However, it is only a template run by Zookeeper. You can overwrite the configuration in the image with the configuration of the host through volume.
2.3 build, mirror
Cd / data/docker/ms-zookeeper3.4.10docker build-t ms/zookeeper3.4.10:v1 .docker images | grep zookms/zookeeper3.4.10 v1 cb1bea8cf3d5 23 hours ago 567MBregistry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/tmp-zookeeper-ms v1 cb1bea8cf3d5 23 hours ago 567MB
The image runs, and the local docker itself command line starts the Zookeeper container
[root@rancher-qa docker] # docker run-- name zookeeper01-it-v / data/docker/zookeeper-config/:/usr/local/zookeeper/conf/-v / data/docker/zookeeper-data01/:/tmp/zookeeper/ ms/zookeeper3.4.10 / bin/bash
The above docker command line starts the volume mapping directory normally, and the host directory can be mapped to the container. However, when using the UI interface for volume mapping in rancher, it is found that the host mapped directory is not mapped to in the container. To be solved.
This problem is due to the fact that rancher has two hosts, and the container is running in a host with no mapping directory set up. This problem has been bothering us for nearly a week.
2.4 Log in to Ali Cloud Container Image Service
Create image repository name tmp-zookeeper-ms
2.5 zookeeper image push to Ali Cloud Docker Registry
Switch to rancher/server
Log in to Aliyun Docker Registry
Log in to Docker Registry-> type tag-> push to Docker Registry
[root@rancher-qa ms-zookeeper3.4.10] # docker login-- username=name@alaxiaoyou.com registry.cn-hangzhou.aliyuncs.comPassword: Login Succeeded [root@rancher-qa ms-zookeeper3.4.10] # [root@rancher-qa ms-zookeeper3.4.10] # docker tag cb1bea8cf3d5 registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/tmp-zookeeper-ms:v1 [root@rancher-qa ms-zookeeper3.4.10] # [root@rancher-qa ms-zookeeper3.4.10 ] # docker push registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/tmp-zookeeper-ms:v1The push refers to a repository [registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/tmp-zookeeper-ms] ed1b06ecb437: Pushed 96f6833b8de8: Mounted from xmbaby-tmp/ms-jdk1.8 071d8bd76517: Mounted from xmbaby-tmp/ms-jdk1.8 v1: digest: sha256:c55b36fb410d7db9409e3ca4fb27e0d8d2d05e1970d99270ff9d5a6d8ee25e0b size: 954 [root@rancher-qa ms-zookeeper3.4.10] # docker images | grep zookregistry.cn-hangzhou.aliyuncs.com/xmbaby -tmp/tmp-zookeeper-ms latest cb1bea8cf3d5 8 days ago 567MBregistry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/tmp-zookeeper-ms v1 cb1bea8cf3d5 8 days ago 567MBms/zookeeper3.4.10 latest cb1bea8cf3d5 8 days ago 567MBms/zookeeper3.4.10 v1 cb1bea8cf3d5 8 days ago 567MB
2.6 View
At this point, the tmp-zookeeper-ms image delivery is complete.
3. Rancher is selected to manage and orchestrate the docker cluster. In addition to launching the Zookeeper container using docker's own command line interface, it is recommended to use the rancher UI interface for container management and creation.
In rancher, add zk1, zk2, and zk3 container services:
Create a zk1:
Volume Management:
Set the container host:
The other two znode nodes, zk2 and zk3, operate in the same way, but the path and name are slightly changed.
Go to the Zookeeper container to view the startup information, and check that the znode2 of the Zookeeper machine is cluster leader:
2. Create config-service service
Centralized configuration of service config-service, as part of the basic running environment of the company's micro services, needs to be created separately.
In order to do a good job of centralized packaging in the later stage, you need to use the maven tool to create a maven image, which integrates the company's own nexus services. Any developer can use this image to quickly package the jar package of the local development environment.
Docker Rancher host
1. Download the apache-maven-3.3.9-bin.tar.gz package and download it yourself.
Create maven to build build directory
Mkdir-p / data/docker/maven3.3.9lldrwxr-xr-x 6 root root 99 Jan 13 15:36 apache-maven-3.3.9-rw-r--r-- 1 root root 8491533 Jan 13 15:34 apache-maven-3.3.9-bin.tar.gz-rw-r--r-- 1 root root 393 Jan 13 16:53 dockerfiledrwxr-xr-x 9 root root 268 Jan 13 15:43 jdk1.8.0_25-rwxr-xr-x 1 Root root 55 Jan 13 16:53 maven.sh
two。 Write dockfile
Cat dockerfile
FROM ms/jdk1.8:v1MAINTAINER maven-3.3.9 "name@alaxiaoyou.com" RUN mkdir / usr/local/maven-3.3.9/ # & & mkdir / usr/local/jdk1.8/ # because it is based on ms/jdk1.8:v1 image Existing jdk environment ADD apache-maven-3.3.9/ / usr/local/maven-3.3.9/#ADD jdk1.8.0_25/ / usr/local/jdk1.8/ADD maven.sh / tmp/ENV JAVA_HOME/ usr/local/jdk1.8ENV M2_HOME/ usr/local/maven-3.3.9ENV PATH $JAVA_HOME/bin:$M2_HOME/bin:$PATHCMD / tmp/maven.sh
Cat maven.sh
#! / bin/bashcd / data/httpd/$ {msname} mvn clean install
3. Construction
[root@rancher-qa maven3.3.9] # docker build-t ms/maven-3.3.9 .Sending build context to Docker daemon 327.2MBStep 1 80a6d05eae5aStep 9: FROM ms/jdk1.8:v1-- > 00d3c71ae0beStep 2 + 9: MAINTAINER maven-3.3.9 "yuhuanghui@alaxiaoyou.com"-- > Using cache-- > 80a6d05eae5aStep 3 RUN mkdir 9: RUN mkdir / usr/local/maven-3.3.9/ # & & mkdir / usr/local/jdk1.8/-- -> Using cache-- > 92ac17c859a8Step 4034053775e26Step 9: ADD apache-maven-3.3.9/ / usr/local/maven-3.3.9/-- > Using cache-- > fa81af79d732Step 5 tmp/ 9: ADD maven.sh / tmp/-> Using cache-> 034053775e26Step 6 usr/local/jdk1.8 9: ENV JAVA_HOME / usr/local/jdk1.8-- > Using cache-> ad8e78b5a021Step 7 Legend 9: ENV M2_HOME / usr/local/maven-3.3.9 -- > Running in cfae5d0a6e53-- > ccfcc8638e43Removing intermediate container cfae5d0a6e53Step 8 docker images 9: ENV PATH $JAVA_HOME/bin:$M2_HOME/bin:$PATH-> Running in 30b2f568c1a3-> 27e68ef34a42Removing intermediate container 30b2f568c1a3Step 9 tmp/maven.sh 9: CMD / tmp/maven.sh-> Running in db48895f5502-> 21c6f1a3b0cfRemoving intermediate container db48895f5502Successfully built 21c6f1a3b0cfSuccessfully tagged ms/maven-3.3.9:latest [root@rancher-qa maven3.3.9] # [root@rancher-qa maven3.3.9] # docker images | grep Mavenms/maven-3.3.9 latest 21c6f1a3b0cf 34 minutes ago 519MB
Run this maven image, package command example:
[root@rancher-qa maven3.3.9] # docker run-- rm-it-v / data/docker/ms-config/:/data/httpd/config-service/-e msname=config-service ms/maven-3.3.9
Description:-v host configuration directory / data/docker/ms-config/ is mapped to container / data/httpd/config-service/,-e definition maven.sh script ${msname} variable.
4. Log in to Ali Cloud Container Image Service
Create local warehouse name ms-maven-3.3.9
5. Mirror push to Ali Cloud Docker Registry
Switch to rancher/server
Log in to Aliyun Docker Registry
Log in to Docker Registry-> type tag-> push to Docker Registry
[root@rancher-qa ms-jdk] # docker login-- username=name@alaxiaoyou.com registry.cn-hangzhou.aliyuncs.comPassword: * Login Succeeded [root@rancher-qa ms-jdk] # [root@rancher-qa ms-jdk] # docker tag 21c6f1a3b0cf registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/ms-maven-3.3.9:latest [root@rancher-qa ms-jdk] # docker push registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp / ms-maven-3.3.9:latestThe push refers to a repository [registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/ms-maven-3.3.9] 607c588ba0d1: Pushed 2e4a77c00b58: Pushed 48c8f5464987: Pushed 96f6833b8de8: Mounted from xmbaby-tmp/tmp-zookeeper-ms 071d8bd76517: Mounted from xmbaby-tmp/tmp-zookeeper-ms latest: digest: sha256:9ceac47cffbf0c35ed66212a042ad10f3905cae924033caf4cbca8cbf4dbf4dd size: 1367
View:
At this point, the ms-maven-3.3.9 image delivery is complete. After the delivery of this image, there is basically no need to change it in the later stage, and the latest version will be directly available.
Service config-service image begins to be delivered:
1.1 prepare to centrally configure the project alaxiaoyou-config-service-0.0.1-SNAPSHOT.jar package, in the gitlab repository.
Create config-service to build build directory
Mkdir-p / data/httpd/ms-config-service-tmp-rw-r--r-- 1 root root 276 Jan 14 17:34 dockerfiledrwxr-xr-x 2 root root 58 Jan 14 17:31 target
1.2 write dockfile
Cat / data/httpd/ms-config-service-tmp/dockerfile
FROM ms/jdk1.8:v1MAINTAINER tmp-config-service "name@alaxiaoyou.com" RUN mkdir-p / data/httpd/ADD target/alaxiaoyou-config-service-0.0.1-SNAPSHOT.jar / data/httpd/WORKDIR / data/httpd/ENTRYPOINT java-Xmx128m-Xss512k-jar alaxiaoyou-config-service-0.0.1-SNAPSHOT.jar
Description: ENTRYPOINT enters the container to execute this jar package.
1.3 build, mirror
Docker build-t ms/config-service .Sending build context to Docker daemon 21.2MBStep 1 RUN mkdir 6: FROM ms/jdk1.8:v1-- > 00d3c71ae0beStep 2 Running in a3e0038610ff 6: MAINTAINER tmp-config-service "yuhuanghui@alaxiaoyou.com"-- > Running in a3e0038610ff-- > 75d7642e16ecRemoving intermediate container a3e0038610ffStep 3 RUN mkdir 6: RUN mkdir-p / data/httpd/-- > Running in 4b1ff33f58df-- > f43b916f6835Removing intermediate container 4b1ff33f58dfStep 4 RUN mkdir 6: ADD target/alaxiaoyou-config-service-0.0.1-SNAPSHOT. Jar / data/httpd/-> 99608e52e219Removing intermediate container 0bd4d9130dd0Step 5jar alaxiaoyou-config-service-0.0.1-SNAPSHOT.jar 6: WORKDIR / data/httpd/-> 656a442c7ac2Removing intermediate container d18fbdc1c6a6Step 6 jar alaxiaoyou-config-service-0.0.1-SNAPSHOT.jar 6: ENTRYPOINT java-Xmx128m-Xss512k-jar alaxiaoyou-config-service-0.0.1-SNAPSHOT.jar-> Running in 0371f9addb5d-> c7375c40286eRemoving intermediate container 0371f9addb5dSuccessfully built c7375c40286eSuccessfully tagged ms/config-service:latest [root@rancher-qa ms-config-service-tmp] # pwd/data/httpd/ms-config-service-tmp [root@rancher-qa Ms-config-service-tmp] # docker images | grep configms/config-service latest c7375c40286e 2 minutes ago 530MBregistry.cn-hangzhou.aliyuncs.com/xmbaby-pre/ms-config latest 51a4521d7581 24 months ago 578MB
1.4 Log in to Ali Cloud Container Image Service
Create image local warehouse name tmp-config-service-ms
1.5 Image push to Ali Cloud Docker Registry
Switch to rancher/server
Log in to Aliyun Docker Registry
Log in to Docker Registry-> type tag-> push to Docker Registry
[root@rancher-qa ms-config-service-tmp] # docker login-- username=name@alaxiaoyou.com registry.cn-hangzhou.aliyuncs.comPassword: * Login Succeeded [root@rancher-qa ms-config-service-tmp] # docker tag c7375c40286e registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/tmp-config-service-ms:latest [root@rancher-qa ms-config-service-tmp] # [root@rancher-qa ms-config-service-tmp] # docker push registry.cn -hangzhou.aliyuncs.com/xmbaby-tmp/tmp-config-service-ms:latestThe push refers to a repository [registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/tmp-config-service-ms] 76925e259a39: Pushed d31d3604ba1d: Pushed 96f6833b8de8: Mounted from xmbaby-tmp/ms-maven-3.3.9 071d8bd76517: Mounted from xmbaby-tmp/ms-maven-3.3.9 latest: digest: sha256:78c0489e045a1a9a7220ea941ca8b7fd6db348e5423e478a45ac2bbc2117c180 size: 1161
At this point, the tmp-config-service-ms image delivery is complete.
The tmp-config-service-ms image is started, and the rancher orchestration UI tool is used to start it.
The startup of the tmp-config-service-ms service depends on the host's directory, which is the local git repository project, git@xxxx.git in gitlab. The provider configuration is modified through gitlab, and it will be updated to the local directory. Restart the provider to take effect.
2.1 start the tmp-config-service-ms service and operate in rancher.
Create a service tmp-config-service-ms:
Set up the volume:
Set the container hostname:
2.2 start the tmp-config-service-ms container service. This provider will only look for config-service once at the beginning of startup, but this config-service service is a single point service. However, containers can be quickly destroyed and generated. Even if there is a problem with this config-service configuration service, you can automatically restart or manually destroy the problematic container immediately, and regenerate a new config-service service container. This process is seconds, and it is acceptable to configure the service as a single point.
Enter the config-service service container, check the startup status, and view the log:
3. Create gateway-service service
The gateway gateway-service service is the entrance to the entire micro-service architecture. Before building a provider, we must first create a gateway service.
Git clone Gateway Project Code, git@xxxx.git
1. Create the gateway project directory:
Mkdir-p / data/httpd/ms-api-gateway-tmp/alaxiaoyou-api-gateway
[root@rancher-qa ms-api-gateway-tmp] # git clone git@xxxxx.gitCloning into 'alaxiaoyou-api-gateway'...remote: Counting objects: 1198, done.remote: Compressing objects: 100% (552 delta), done.remote: Total 1198 (delta 423), reused 554 (delta 241) Receiving objects: 100% (1198 KiB), 108.00 KiB | 0 bytes/s, done.Resolving deltas: 100% (423 KiB) Done. [root@rancher-qa ms-api-gateway-tmp] # [root@rancher-qa ms-api-gateway-tmp] # lltotal 0drwxr-xr-x 4 root root 44 Jan 14 19:10 alaxiaoyou-api-gateway [root@rancher-qa ms-api-gateway-tmp] # pwd/data/httpd/ms-api-gateway-tmp [root@rancher-qa ms-api-gateway-tmp] # cd alaxiaoyou-api-gateway/ [root@rancher-qa alaxiaoyou-api-gateway] # [root@ Rancher-qa alaxiaoyou-api-gateway] # lltotal 8 [root@rancher-qa alaxiaoyou-api-gateway] # pwd/data/httpd/ms-api-gateway-tmp/alaxiaoyou-api-gateway-1 root root 4811 Jan 14 19:10 pom.xmldrwxr-xr-x 3 root root 18 Jan 14 19:10 src [root@rancher-qa alaxiaoyou-api-gateway] # [root@rancher-qa alaxiaoyou-api-gateway] #
Under the gateway-service project directory, run the gateway code packaging command:
Docker run-- rm-it-v / data/httpd/ms-api-gateway-tmp/alaxiaoyou-api-gateway:/data/httpd/gateway-service/-e msname=gateway-service ms/maven-3.3.9 [root@rancher-qa alaxiaoyou-api-gateway] # docker run-- rm-it-v / data/httpd/ms-api-gateway-tmp/alaxiaoyou-api-gateway:/data/httpd/gateway-service/-e msname=gateway-service ms/maven-3.3.9 [root@ Rancher-qa alaxiaoyou-api-gateway] # lltotal 58436 Jan RW root root 14 19:10 pom.xmldrwxr-xr-x 3 root root 18 Jan 14 19:27 alaxiaoyou-api-gateway-0.0.1-SNAPSHOT.jar-rw-r--r-- 1 root root 343 Jan 14 19:28 dockerfiledrwxr-xr-x 3 root root 20 Jan 14 19:28 gateway-service-rw-r--r-- 1 root root 4811 Jan 14 19:10 pom.xmldrwxr-xr-x 3 root root 18 Jan 14 19:10 src
This packaging command has not successfully typed out the package alaxiaoyou-api-gateway-0.0.1-SNAPSHOT.jar, which is cp from other machines. To be solved.
two。 Create a gateway project dockerfile
Vim / data/httpd/ms-api-gateway-tmp/alaxiaoyou-api-gateway/dockerfile
FROM ms/jdk1.8:v1MAINTAINER gateway-service "name@alaxiaoyou.com" RUN mkdir / data/httpd/-pADD gateway-service/target/alaxiaoyou-api-gateway-0.0.1-SNAPSHOT.jar / data/httpd/EXPOSE 80 # although port 80 mapping is enabled here, there is no link link WORKDIR / data/httpd/ENTRYPOINT java-jar alaxiaoyou-api-gateway-0.0.1-SNAPSHOT.jar
Description: ENTRYPOINT enters the container to execute this jar package.
3. Build, mirror
[root@rancher-qa alaxiaoyou-api-gateway] # docker build-t ms/tmp-gateway-service .Sending build context to Docker daemon 60.27MBStep 1 00d3c71ae0beStep 7: FROM ms/jdk1.8:v1-- > 00d3c71ae0beStep 2 yuhuanghui@alaxiaoyou.com 7: MAINTAINER gateway-service "yuhuanghui@alaxiaoyou.com"-- > Using cache-- > bf3f97f0bda2Step 3 yuhuanghui@alaxiaoyou.com 7: RUN mkdir-p / data/httpd/-- > Running in da244cb64552-- > 743c35c3c4d8Removing intermediate container da244cb64552Step 4max 7: ADD gateway-service/target/alaxiaoyou- Api-gateway-0.0.1-SNAPSHOT.jar / data/httpd/-> 9e45fe4b20a4Removing intermediate container 8e3022556068Step 5 jar alaxiaoyou-api-gateway-0.0.1-SNAPSHOT.jar 7: EXPOSE 80-> Running in e4dbaaa58778-> 299398d4af46Removing intermediate container e4dbaaa58778Step 6 c2f59d36052dRemoving intermediate container 8ce9968b7befSuccessfully built c2f59d36052dSuccessfully tagged ms/tmp-gateway-service:latest 7: WORKDIR / data/httpd/-> 2e6bc4bdf39dRemoving intermediate container 8428111522beStep 7: ENTRYPOINT java-jar alaxiaoyou-api-gateway-0.0.1-SNAPSHOT.jar-> Running in 8ce9968b7bef-- > c2f59d36052dRemoving intermediate container 8ce9968b7befSuccessfully built c2f59d36052dSuccessfully tagged ms/tmp-gateway-service:latest [root@ Rancher-qa alaxiaoyou-api-gateway] # [root@rancher-qa alaxiaoyou-api-gateway] # docker images | grep gatems/tmp-gateway-service latest c2f59d36052d 16 seconds ago 569MBregistry.cn-hangzhou.aliyuncs.com/xmbaby-test/test-gateway-ms latest d86bef9f01e9 14 months ago 617MB
4. Log in to Ali Cloud Container Image Service
Create local warehouse name: tmp-gateway-service-ms
5. Mirror push to Ali Cloud Docker Registry
Switch to rancher/server
Log in to Aliyun Docker Registry
Log in to Docker Registry-> type tag-> push to Docker Registry
[root@rancher-qa alaxiaoyou-api-gateway] # docker login-- username=name@alaxiaoyou.com registry.cn-hangzhou.aliyuncs.comPassword: Login Succeeded [root@rancher-qa alaxiaoyou-api-gateway] # docker tag c2f59d36052d registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/tmp-gateway-service-ms [root@rancher-qa alaxiaoyou-api-gateway] # [root@rancher-qa alaxiaoyou-api-gateway] # docker push registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/tmp-gateway-service- MsThe push refers to a repository [registry.cn-hangzhou.aliyuncs.com/xmbaby-tmp/tmp-gateway-service-ms] 29ffcfda7ded: Pushed 202759902df6: Pushed 96f6833b8de8: Mounted from xmbaby-tmp/tmp-config-service-ms 071d8bd76517: Mounted from xmbaby-tmp/tmp-config-service-ms latest: digest: sha256:825a0ec026c1f7c6eea01c2e5236c42dba11209b17ccd2ffad2b314c99b58b2d size: 1161
6. Mirror View:
At this point, the gateway-service-ms image delivery is complete.
Start gateway-service with the rancher orchestration UI tool:
1. Enter the rancher application stack to add services. Because the gateway gateway service needs to map port 80 to the host, create a container and select "always run an instance of this container on each host". Map port 80. Add the associated target service.
The gateway service gateway-service starts to connect the associated target service config-service,config-service through the config configuration project managed by git to obtain configuration information to the gateway service. Associate with the Zookeeper cluster registration service.
two。 Automatic restart Select "never (start only once)":
3. For gateway services, docker itself can be used to manage memory allocation, which can be adjusted dynamically:
4. Enter the container to view the startup of the gateway-service service.
Since then, the gateway service gateway-service has been added
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.