This technology is similar to Spring Cloud Config.

1 Significance of Configuration Management

Reality pain points

  • Different configurations in different environments
  • Configure dynamic attribute refreshing

To solve the pain point, the common solution is to introduce a configuration server, the architecture is as follows

  • Introduction of depend on

  • Write configuration (convention over configuration), follow the following mapping diagram

  • Create a new bootstrap.yml configuration file

  • Configure in the NACOS operation panel

  • Start the content Center

2 Dynamic refreshing of configurations

After the configuration is modified, the application can dynamically refresh the configuration without restarting the application

  • Add the @refreshScope annotation

Roll back the Bug

Do not roll back to the initial state! Nacos is still unresolved.

  • Github.com/alibaba/nac…

  • Qithub.com/alibaba/nac…

Since the fix was delayed, we had to try to avoid using historical versions and change the configuration directly.

3 Share Configuration

3.1 Within the same application

Specified > genericCopy the code

3.2 Different applications

  • For example, this configuration is available in both the user/content center and can be handed over to nacOS to manage the shared configuration

Here are two options for configuring sharing in NACOS:

shared-detaids

ext-config

priority

Shared-dataids < ext-config < automaticCopy the code

4 Boot Context

4.1 It is used to connect to the configuration server and read external configurations

Bootstrap. yml is the configuration file for the boot context. For applications, this is to connect to Nacos to read the configuration in Nacos.

4.2 Parent Context of Application Context

Remote Configuration (Nacos) & Local Configuration Priority By default, remote configuration takes precedence

  • The following configuration files must be placed in remote configuration to take effect

5 Data Persistence

5.1 As a Service Discovery Component

Its data is stored in a local path:

~/nacos/naming/public
Copy the code

5.2 Serving as the Configuration Server

The data is divided into the following two parts

Configuration data added in the NACOS Web UI:

$NACOS_ HOME/data/derby-data
Copy the code
  • To see the details, you must stop NACOS and then connect to Derby, an embedded database developed by Apache, through IDEA’s data source

  • Configure a snapshot for the property

~/nacos/config

6 Nacos Configuration Management best practices

  • Can put local, not remote
  • Try to avoid priorities
  • Specification, such as annotations for all configuration properties
  • Minimal configuration managers (permission controls are being developed officially)