High availability of spring cloud config distributed configuration center

In the previous article, we realized the function of unified configuration file management, but we can find that we only use one server. If the server hangs up, the whole configuration center will not be available. Next, we will solve the problem of high availability of the configuration center.

Next, we integrate Eureka to realize the high availability of the configuration center, because as the configuration management in the architecture, it can also be regarded as a micro service in the architecture. We can also register the config server as a service, so that all clients can access it in the way of service. In this way, you only need to start multiple config servers pointing to the same gitlab warehouse location to achieve high availability.

1、 Join Eureka on the config server side

1. Join Eureka dependency

2. Add Eureka support and register the configuration service with Eureka

@EnableEurekaClient

3. Modify the configuration file on the server side

Add the configuration registered by Eureka, bootstrap yml

Start config server

4. Modify the port number and start a config server

5. Check whether the service is registered successfully

2、 Config client joins Eureka

1. Join Eureka's POM dependency, the same as config server

2. Modify the configuration file of config client

bootstrap. Properties has been tested. The client here can only be bootstrap Properties, otherwise it will always be connected to port 8888

Among them, through Eureka client. service-url. The defaultzone parameter specifies the service registry, which is used for service registration and discovery, and then spring cloud. config. discovery. Set the enabled parameter to true to enable the function of accessing config server through service. Finally, use spring cloud. config. discovery. Serviceid parameter to specify the service name registered by config server. Here's spring application. Name and spring cloud. config. The meaning of profile is consistent with that in the previous blog.

3. Add Eureka support on the main application class, which is consistent with config server

3、 Verify

1. View services on Eureka server

2. Check whether the config server is normal

Enter in the browser: http://localhost:8888/configserver/dev/master , http://localhost:8889/configserver/dev/master , see if there are any returned results as follows:

Enter in the browser http://localhost:8890/hello To see if there is any return

4. Stop the config server corresponding to port 8888, and then enter it again http://localhost:8890/hello , see if it's OK! We found that it is still OK, so we have completed the high availability of the configuration center!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>