Detailed explanation of the process of deploying the distributed configuration center Apollo with one click using docker compose

Detailed explanation of the process of deploying the distributed configuration center Apollo with one click using docker compose

Introduction

When talking about distribution, we must think of distributed configuration center, distributed log, distributed link tracking, etc.

In distributed deployment, businesses often have a lot of configurations. For example, when an application starts and runs, it needs to read some configuration information. Configuration basically accompanies the entire life cycle of the application. For example, database connection parameters, startup parameters, etc., all need to be maintained and configured, but it is impossible to log in to each server to configure. Today I want to share with you the distributed configuration center Apollo:

Apollo is a distributed configuration center developed by Ctrip's framework department. It can centrally manage the configuration of different application environments and clusters. After the configuration is modified, it can be pushed to the application end in real time. It also has standardized permissions, process governance and other features, and is suitable for microservice configuration management scenarios.

Build

There are two ways to build in the official documentation: one is to download the source code for construction, and the other is to use Docker or K8S for construction. Today we use Docker for construction, after all, Docker is more friendly to developers.

If you already have a MySQL service, it is recommended to use the existing MySQL service or cloud service RDS as the database. After all, data is priceless.

version: "3"
services:
  apollo-configservice: #Config Service provides functions such as configuration reading and pushing. The service object is the Apollo clientimage: apolloconfig/apollo-configservice:1.8.1
    restart: always
    #container_name: apollo-configservice
    volumes:
          - ./logs/apollo-configservice:/opt/logs
    ports:
      - "8080:8080"
    environment:
      - TZ='Asia/Shanghai'    
      -SERVER_PORT=8080
      - EUREKA_INSTANCE_IP_ADDRESS=xxx.xxx.xxx.xxx
      - EUREKA_INSTANCE_HOME_PAGE_URL=http://xxx.xxx.xxx.xxx:8080
      - SPRING_DATASOURCE_URL=jdbc:mysql://xxx.xxx.xxx.xxx:3306/ApolloConfigDB?characterEncoding=utf8&serverTimezone=Asia/Shanghai
      -SPRING_DATASOURCE_USERNAME=root
      - SPRING_DATASOURCE_PASSWORD=MysqkPassWord!
      
      
  apollo-adminservice: #Admin Service provides functions such as configuration modification and publishing, and the service object is Apollo Portal (management interface)
    image: apolloconfig/apollo-adminservice:1.8.1
    restart: always
    #container_name: apollo-adminservice
    volumes:
      - ./logs/apollo-adminservice:/opt/logs
    ports:
      - "8090:8090"
    depends_on:
      - apollo-configservice
    environment:
      - TZ='Asia/Shanghai'    
      -SERVER_PORT=8090
      - EUREKA_INSTANCE_IP_ADDRESS=xxx.xxx.xxx.xxx
      - SPRING_DATASOURCE_URL=jdbc:mysql://xxx.xxx.xxx.xxx:3306/ApolloConfigDB?characterEncoding=utf8&serverTimezone=Asia/Shanghai
      -SPRING_DATASOURCE_USERNAME=root
      - SPRING_DATASOURCE_PASSWORD=MysqkPassWord!
      
      
  apollo-portal: #Management interfaceimage: apolloconfig/apollo-portal:1.8.1
    restart: always
    container_name: apollo-portal
    volumes:
      - ./logs/apollo-portal:/opt/logs
    ports:
      - "8070:8070"
    depends_on:
      - apollo-adminservice
    environment:
      - TZ='Asia/Shanghai'    
      -SERVER_PORT=8070
      - EUREKA_INSTANCE_IP_ADDRESS=xxx.xxx.xxx.xxx
      -APOLLO_PORTAL_ENVS=dev
      - DEV_META=http://xxx.xxx.xxx.xxx:8080
      - SPRING_DATASOURCE_URL=jdbc:mysql://xxx.xxx.xxx.xxx:3306/ApolloPortalDB?characterEncoding=utf8&serverTimezone=Asia/Shanghai
      -SPRING_DATASOURCE_USERNAME=root
      - SPRING_DATASOURCE_PASSWORD=MysqkPassWord!

From the above docker-compose.yaml, we can see that there are 3 services in total, namely:

  1. Config Service provides functions such as configuration reading and pushing, and its service object is Apollo client.
  2. Admin Service provides functions such as configuration modification and publishing, and its service object is Apollo Portal (management interface)
  3. Portal (management interface)

If you want to know how they work, it is recommended to check the official documentation

Logs are mounted to the external ./logs directory

You can see that the deployment of MySQL is not given above. If you need to use a container to deploy MySQL, you can refer to the following docker-compose.yaml

version: '3'

services: 

  mysql: # myslq database image: 'mysql/mysql-server'
    container_name: 'mysql'
    restart: always
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --lower-case-table-names=1
    environment: #Environment variable MYSQL_ROOT_HOST: "%" 
      MYSQL_ROOT_PASSWORD: password
      MYSQL_USER: brook
      MYSQL_PASSWORD: password
    ports:
      - "3306:3306"

The above mysql docker-compose.yaml is for testing only

Initialize the database apolloconfigdb.sql and apolloportaldb.sql

After the database is initialized, remember to modify the eureka.service.url of the serverconfig table in the apolloconfigdb library, otherwise apollo-adminservice cannot be registered with eureka

After modification, switch to the Apollo docker-compose.yaml directory and use

docker-compose up -d #Start the three services in the file and run them in the background

Check the startup status

docker-compose ps

Visit http://10.0.0.53:8070/ #Apollo management terminal

Default username: apollo
Default password:admin

Create a test project


test

Create a .NetCore project and add Apollo.net client

Add Apollo

Configure Apollo

Configuration as above

Add test content to get Apollo code

Start the program and request /weatherforecast/apollotest

It was found that the configuration set in apollo was not obtained

Check Apollo and find that the configured value is not published

So everyone must remember to publish after configuring or modifying Apollo. We will refresh the browser again after publishing.

It is found that the data is already new data. Let's modify Apollo's Value again.

refresh

Apollo has been built and is ready to use.

Code

The code in the example is
https://github.com/yuefengkai/Brook.Apollo
Welcome everyone to start

Note: If the configuration cannot be pulled after the program starts, you can open the Apollo log. You can see the detailed configuration in the console and put it in the first line of the Program.cs Main function!

LogManager.UseConsoleLogging(Com.Ctrip.Framework.Apollo.Logging.LogLevel.Trace);

refer to

1. https://github.com/apolloconfig/apollo.net
2. https://github.com/apolloconfig/apollo
3. https://github.com/apolloconfig/apollo/tree/master/scripts/docker-quick-start

This is the end of this article about docker compose one-click deployment of distributed configuration center Apollo. For more related docker compose deployment distributed configuration center Apollo content, please search 123WORDPRESS.COM previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Docker compose configuration file writing and command usage examples
  • Using Docker Compose to build and deploy ElasticSearch configuration process
  • Docker-compose installation yml file configuration method
  • Detailed tutorial on docker-compose deployment and configuration of Jenkins
  • How to install and configure the Docker Compose orchestration tool in Docker.v19
  • Docker-compose steps to configure the spring environment
  • Detailed explanation of software configuration using docker-compose in linux
  • Detailed explanation of Docker Compose configuration file parameters

<<:  Vue implements internationalization of web page language switching

>>:  Mysql uses stored procedures to quickly add millions of data sample code

Recommend

The marquee element implements effects such as scrolling fonts and pictures

The marquee element can achieve simple font (image...

Analysis of implicit bug in concurrent replication of MySQL 5.7

Preface Most of our MySQL online environments use...

How to authorize remote connections in MySQL in Linux

Note: Other machines (IP) cannot connect to the M...

Initial settings after installing Ubuntu 16 in the development environment

The office needs Ubuntu system as the Linux devel...

A brief discussion on several advantages of Vue3

Table of contents 1. Source code 1.1 Monorepo 1.2...

Install mysql 5.6 from yum source in centos7.4 system

System environment: centos7.4 1. Check whether th...

Solve the problem of spring boot + jar packaging deployment tomcat 404 error

1. Spring boot does not support jsp jar package, ...

An exploration of the JS operator in problem

Here's the thing: Everyone knows about "...

Meta declaration annotation steps

Meta declaration annotation steps: 1. Sort out all...

JavaScript gets the scroll bar position and slides the page to the anchor point

Preface This article records a problem I encounte...

How to expand the disk partition for centos system

Problem/failure/scenario/requirement The hard dis...

Analysis of the difference between HTML relative path and absolute path

HTML beginners often encounter the problem of how ...

MySQL slow_log table cannot be modified to innodb engine detailed explanation

background Getting the slow query log from mysql....

How to use border-image to implement text bubble border sample code

During the development activity, I encountered a ...