This is the 22nd day of my participation in Gwen Challenge

preface

Once upon a time, there was a mountain with a temple. There were 4 halls and 10 courtyards in the temple, namely, the Hall of the Young king, the hall of the young Treasure, the Hall of the young Gold and the Hall of the Careful, the Hall of the young Luo, the Hall of the young Ruo, the Hall of the young Ash, the House of the young Bodhisattva, the Courtyard of the young Law, the courtyard of the young King, the courtyard of the young house, the hall of the young Classics, and the courtyard of the young Da.

Each temple has a disciple who has a key to close the door

One night, the abbot was trapped in the small treasure house, the abbot is called let xiao Ming came to open the lock, and then find xiao bao Ming temple full house, the person responsible for closing the new keys to him, and in the evening, it is said that the first locked in the wang school, push gently, lock the inference, the abbot and xiao Ming went to look for a person to repair the lock and then put the key to wang, head of the hospital, on the way back, Xiao Ming found that the West hall (a position) was shut in the small jingge, gently called, the small jingge lock shock broken, xiao Ming from the lock repair master took a new key, and then ran to the corresponding person in charge.

Later, the temple added a new position ———— supervision and by Xiaoming, by the supervision with all the keys, after the lock change, the new key only need to be handed over to the supervision on the line, no longer have to hurry to find their person in charge!

Why do I need to configure the center?

When there are more and more services (the person in charge of closing the temple and courtyard), each service has its own configuration information (equivalent to the key of each temple and courtyard), such as database connection information, mysql, Redis, mongo related configuration, business related, such as qiniu storage, SMS related, email related. Or some business on the switch When a service configuration information is changed, the service must want to restart, restart process is equivalent to xiao Ming to take new keys to the head of the road, on the one hand, on the other hand, is time-consuming, head of the one thousand key is doing homework, xiao Ming is waiting for him to finish again, he is doing or interrupt, restart the service, Or we need to restart the service while it is idle so that the system is not affected

Spring Cloud Config features

Config provides two aspects of functionality

  • Centrally manage configuration files
  • The configuration information is automatically refreshed

Where is Spring Cloud Config?

  • The configuration service is placed in the memory of the configuration service (that is, local)
  • Put it in a remote Git repository

Spring Cloud Config

  • It has two roles: Config Server and Config client
  • Centrally manage application configurations in a distributed environment
  • Seamlessly integrates with Spring applications based on the Spring environment
  • Programs that can be developed in any language
  • The default implementation is based on git repositories for version management
  • Alternative custom implementations

Sonfig Server

Config Server is a scale-out, centralized configuration Server that centrally manages the configuration of an application in various environments. By default, Git is used to store configuration file content, SVN can be used to store configuration file content, or local file storage can be used. Update the Git repository copy when pulling the configuration to make sure it is up to date

  • Support rich data structure, YML, JSON, properties and so on
  • Service discovery can be realized with Eureke, and configuration push update can be realized with Cloud Bus
  • Configuration stores are based on git repositories for version management
  • Simple and reliable, with abundant supporting programs

Config Client

The Config Client is a Client of the Config Server. It curds the configurations stored in the Config Server

Use the Config Client

You can use a service that has configuration information (such as application.yml or application.properties) files, just specify in the configuration file which Config Server configuration file you want to use

spring:
  application:
    name: config-client
  cloud:
    #Config client configuration
    config:
      label: master # branch name
      name: config # Config file name
      profile: dev Read the suffix name
      uri: http://localhost:6666 Configure the central address server address

Copy the code

Today’s summary

Configuration technology that is actually very simple, in the center of the center configuration is also easy to understand what it is a component, of course, the principle of deep understanding of it, small make up remains to be strengthen, mainly take the time today is writing a story and configuration center on, think a lot of scenes, but think of it, not to use the final to the story of a small clear, ok, Never put off till tomorrow what can be done today. Goodbye