In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces docker how to deploy apollo, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
1. Preface
I will not say more about the details of apollo here. Https://github.com/ctripcorp/apollo has already made it very clear on the official website. I will not play tricks in this class. If you do not know it, you can go to the official website to learn about it.
Note: I started the deployment directly, and I completed the creation and initialization of the database according to the official website.
2. Source code compilation
2.1 Network Policy
The network strategy can be described directly on the official website, that is, edit apollo-configservice/src/main/resources/application.yml and apollo-adminservice/src/main/resources/application.yml respectively, and then add the network cards that need to be ignored.
For example, for apollo-configservice, the network cards of docker0 and veth.* are ignored when registering with Eureka.
Spring: application: name: apollo-configservice profiles: active: ${apollo_profile} cloud: inetutils: ignoredInterfaces:-docker0-veth.*
Note that you should be careful not to correct other information, such as spring.application.name, when modifying application.yml.
2.2 dynamically specify the registration network
When using docker to build a cluster, both adminservice and configservice need to register an address with the registry. If you do not specify a registration IP, you will register a network within the docker, resulting in network failure.
Add the following code to apollo-configservice/src/main/resources/bootstrap.yml and apollo-adminservice/src/main/resources/bootstrap.yml.
Eureka: instance: ip-address: ${eureka.instance.ip-address}
The value of this place is taken from the environment variable and configured outside the container, which brings more flexibility to the deployment.
To this source code modification has been completed, directly build packaging will be fine, get the corresponding three services zip package.
If you are too lazy to modify it, you can also download it directly from https://github.com/yuelicn/apollo. Drop down my modified source code and pack it directly.
3. Dockerfile writing
Apollo's Dockerfile is very simple and can be directly used by the official. Below is an example of adminservice.
# Dockerfile for apollo-adminservice# Build with:# docker build-t apollo-adminservice. # Run with:# docker run-p 8090 name apollo-adminservice apollo-adminserviceFROM java:8-jreMAINTAINER LouisENV VERSION 1.5.0RUN apt-get install unzipADD apollo-adminservice-$ {VERSION}-github.zip / apollo-adminservice/apollo-adminservice-$ {VERSION}-github.zipRUN unzip / apollo-adminservice/apollo-adminservice-$ {VERSION}-github.zip-d / apollo-adminservice\ & & rm-rf / Apollo-adminservice/apollo-adminservice-$ {VERSION}-github.zip\ & & sed-I'$d' / apollo-adminservice/scripts/startup.sh\ & & echo "tail-f / dev/null" > > / apollo-adminservice/scripts/startup.shEXPOSE 8090CMD ["/ apollo-adminservice/scripts/startup.sh"]
What needs to be paid attention to
1: version needs to be modified according to its own packaged version
2: modify your path when ADD zip package
The dockerfile files of the three services are basically the same, so I won't say any more here. The friends you need can do it directly from https://github.com/yuelicn/docker-apollo.
4. The compilation of docker-compose
4.1 apollo-configservice-compose.yml
Version: "3" services: apollo-configservice: container_name: apollo-configservice build: apollo-configservice/ image: apollo-configservice ports:-80 spring_datasource_username=root 8080 volumes:-"/ docker/apollo/logs/100003171:/opt/logs/100003171" environment:-spring_datasource_url=jdbc:mysql://127.0.0.1:8306/ApolloConfigDB_TEST?characterEncoding=utf8-spring_datasource_username=root-spring_datasource_password=mysql2019*-eureka.instance.ip-address=172.11.11.11 restart: always
Points for attention
1: build: specify the location of your Dockerfile file in
2: specify the configuration information of your database in the environment environment variable
3: eureka.instance.ip-address specifies to register to the eureka address, which is best to use the intranet address of your physical machine.
Special note: before starting, it is best to modify the eureka.service.url value in ServerConfig in the ApolloConfigDB database to a specific IP.
Start:
Docker-compose-f apollo-configservice-compose.yml up-- build-d
4.2 apollo-adminservice-compose.yml
The content of apollo-adminservice-compose.yml is basically the same as apollo-configservice-compose.yml, so I won't explain them one by one here.
4.3 apollo-portal-compose.yml
Version: "3" services: apollo-portal: container_name: apollo-portal build: apollo-portal/ image: apollo-portal ports:-8070 apollo-portal 8070 volumes:-"/ docker/apollo/logs/100003173:/opt/logs/100003173"-"/ apollo-portal/config/apollo-env.properties:/apollo-portal/config/apollo-env.properties" environment:-spring_datasource_url=jdbc:mysql://127.0.0.1:8306/ ApolloPortalDB?characterEncoding=utf8-spring_datasource_username=root-spring_datasource_password=mysql2019* restart: always
Note:
1: what you need to pay attention to is basically the same as the above configservice
2: the matters that need to be paid special attention to are important! important! important! important! important! Volumes: I will
The apollo-env.properties file is mapped to the outside of the container. After configuring your own apollo-env.properties file, fill in your mount address, and change the address "/ apollo-portal/config/apollo-env.properties" before the colon to your own. This profile must be specified before startup.
Start
Docker-compose-f apollo-configservice-compose.yml up-- build-d
4.3.1 apollo-env.properties
Local.meta= http://localhost:8080dev.meta=${dev_meta}fat.meta=${fat_meta}uat.meta=${uat_meta}lpt.meta=${lpt_meta}pro.meta=${pro_meta}
Configure your own meta address, and you can delete what you don't have. If you don't understand, you can go to the official website to find out. After the environment is configured, modify the apollo.portal.envs value in the ApolloPortalDB.ServerConfig in the corresponding database, and fill in the environment of your configuration. Otherwise, we can only see the default dev environment on the portal administration page.
5 complete docker-compose.yml
If you dislike the trouble of starting one by one, use a complete compose to start.
Version: "3" services: apollo-configservice: container_name: apollo-configservice build: apollo-configservice/ image: apollo-configservice ports:-8080 spring_datasource_username=root 8080 volumes:-"/ docker/apollo/logs/100003171:/opt/logs/100003171" environment:-spring_datasource_url=jdbc:mysql://47.xx.xx.209:8306/ApolloConfigDB?characterEncoding=utf8-spring_datasource_username=root-spring_datasource_password=Tusdao@xx*-eureka.instance.ip-address=172. 11.11.11 restart: always apollo-adminservice: container_name: apollo-adminservice build: apollo-adminservice/ image: apollo-adminservice ports:-8090 spring_datasource_password=Tusdao@xx* 8090 volumes: "/ docker/apollo/logs/100003172:/opt/logs/100003172" environment:-spring_datasource_url=jdbc:mysql://47.xx.xx.209:8306/ApolloConfigDB?characterEncoding=utf8-spring_datasource_username=root-spring_datasource_password=Tusdao@xx*-eureka.instance.ip-address=172. 11.11.11 depends_on:-apollo-configservice restart: always apollo-portal: container_name: apollo-portal build: apollo-portal/ image: apollo-portal ports:-8070 always apollo-portal 8070 volumes:-"/ docker/apollo/logs/100003173:/opt/logs/100003173"-"/ Apollo/docker-image/apollo-portal/config/apollo-env.properties:/apollo-portal/config/apollo-env.properties" environment:-spring_datasource_ Url=jdbc:mysql://47.xx.xx.209:8306/ApolloPortalDB?characterEncoding=utf8-spring_datasource_username=root-spring_datasource_password=Tusdao@xx* depends_on:-apollo-adminservice restart: always
Note: the areas that need to be modified are basically the same as the individual, so I won't nag here.
The docker deployment Apoll is basically done here. If a partner needs a complete docker deployment file, please move to https://github.com/yuelicn/docker-apollo.
6. The construction of cluster
The construction of an Apollo cluster is very simple. It only needs to be modified in two places. We will explain it in terms of formal environment (pro).
In the pro environment, we have built two sets of adminservice and configservice, and the database is the same ApolloConfigDB.
1: write the eureka.service.url value eureka connection information in ServerConfig and separate them with commas: http://IP-1:port/eureka,http://IP-2:port/eureka
2: modify the connection information of the corresponding environment in apollo-env.properties, such as pro.meta= http://IP-1:port,http://IP-2:port addresses, separated by commas.
Then restart the service and it's done.
Finally, it is emphasized that adminservice and configservice need to be deployed separately for each environment, including databases. Only one set of portal needs to be deployed.
OK! Complete, the above refers to the personal building records, I hope it will be helpful to you, if not correct, welcome to correct.
Modified source address: https://github.com/yuelicn/apollo
Sorted out Docker-Apollo: https://github.com/yuelicn/docker-apollo
Thank you for reading this article carefully. I hope the article "how to deploy docker apollo" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.