High Availability of spring cloud config distributed configuration center, springcloud

Source: Internet
Author: User

High Availability of spring cloud config distributed configuration center, springcloud

In the previous article, we implemented the unified management of configuration files, but we can find that we only use one server. If this server fails, the entire configuration center will be unavailable. Next, we will solve the high availability problem of the configuration center.

The following describes how to integrate Eureka to achieve high availability of the configuration center. As the Configuration Management in the architecture, it can also be seen as a microservice in the architecture, we can also register the config server as a service so that all clients can access the service. In this way, you only need to start multiple config servers pointing to the same Gitlab repository to achieve high availability.

1. Add the Config Server to Eureka

1. Add Eureka Dependencies

<dependency>    <groupId>org.springframework.cloud</groupId>    <artifactId>spring-cloud-starter-eureka</artifactId>   </dependency> 

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

@ EnableEurekaClient

3. Modify the Server configuration file

Add the Eureka registration configuration, bootstrap. yml

Server: port: 8889 eureka: client: service-url: defaultZone: http: // localhost: 8761/eureka instance: prefer-ip-address: true spring: application: name: foo cloud: config: server: git: uri: <span> https://gitlab.xxx.com/xxxxx/xxxxx.git </span> # configure the address of the gitlab repository search-paths: <span>/config-repo </span> # Separate multiple addresses in the gitlab repository address. Username: your name # account password of the gitlab Repository: your password # password of the gitlab Repository

Start Config Server

4. Modify the port number and start a Config Server.

5. Check whether the service is successfully registered.

Ii. Add the Config client to Eureka

1. Add the Eureka pom dependency, same as the Config Server

2. modify the configuration file of the Config client.

Bootstrap. properties has been tested. The client can only be bootstrap. properties. Otherwise, port 8888 will be connected continuously.

Server. port = 8890 spring. application. name = configserver spring. cloud. config. name = configserver spring. cloud. config. profile = dev spring. cloud. config. label = master # enable Config service discovery to support spring. cloud. config. discovery. enabled = true # Set this parameter to the service name spring registered by the Config Server on Eureka. cloud. config. discovery. service-id = foo # specify the service Discovery Center eureka. client. service-url.defaultZone = http: // localhost: 8761/eureka

The eureka. client. the service-url.defaultZone parameter specifies the Service Registration Center for service registration and discovery, and then spring. cloud. config. discovery. the enabled parameter is set to true. Enable the Config Server access function through the service, and use spring. cloud. config. discovery. serviceId parameter to specify the service name registered by Config Server. Here, spring. application. name and spring. cloud. config. profile have the same meaning as those in the previous blog.

3. Add Eureka support to the Application main class, which is consistent with the Config Server.

Iii. Verification

1. view the services on the Eureka Server

2. Check whether the Config Server is normal.

In the browser, enter http: // localhost: 8888/configserver/dev/master, http: // localhost: 8889/configserver/dev/master, respectively, check whether the returned results are as follows:

{   "name": "configserver",  "profiles": [   "dev"  ],  "label": "master",  "version": "8949024814dcb6d61f97dc49db7e9dadcfc724b1",  "state": null,  "propertySources": [   {    "name": "https://gitlab.xxx.com/xxxxx/xxxxx/project/config-repo/configserver.properties",    "source": {     "name": "chhliuxyh",     "hello": "i'm the king of the world!!!",     "profile": "profile-default"    }   }  ]  } 

3. Check whether the client is normal.

Enter http: // localhost: 8890/hello in the browser to check whether the following results are returned.

i'm the king of the world!!!

If the preceding steps are normal, they are OK.

4. Stop the Config Server corresponding to port 8888, and then re-enter http: // localhost: 8890/hello to check whether it is OK! We found that it is still OK, so we have completed the high availability of the configuration center!

<pre code_snippet_id="2245130" snippet_file_name="blog_20170306_4_711400"></pre> <pre></pre> <pre></pre> 

Summary

The above section describes the high availability Implementation Method of spring cloud config distributed configuration center. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.