Spring Cloud Config 自动刷新所有节点 架构改造
详细参考:《Sprin Cloud 与 Docker 微服务架构实战》p162-9.9.4节
要做的改动是:
1、在spring cloud config server 服务端加入 spring-cloud-starter-bus-amqp 包
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.thunisoft</groupId>
<artifactId>thunisoft-microservice-config</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>thunisoft-microservice-config</name>
<description>Demo project for Spring Boot</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Edgware.SR2</spring-cloud.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>
2、添加配置
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
spring:
application:
name: thunisoft-microservice-configs
cloud:
config:
server:
git:
uri: https://gitee.com/ultrastrong/spring-cloud-config
clone-on-start: true # 启动时候就clone配置仓库
default-application-name: thunisoft-microservice-foo
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
server:
port: 8979
# 默认关闭权限验证
management:
security:
enabled: false
不要忘记关闭服务器端的安全认证,否则无法访问到端点。
3、使用 /bus/refresh 端点刷新配置时,只要在 服务器端就行了,这样所有的端点就都能收到更新请求了。
http://localhost:8979/bus/refresh
Spring Cloud Config 自动刷新所有节点 架构改造的更多相关文章
- Spring Cloud Config 自动刷新所有节点
全局刷新 详细参考:<Sprin Cloud 与 Docker 微服务架构实战>p160-9.9.2节 1.使用Spring Cloud Config 客户端时,可以使用 /refresh ...
- Spring Cloud Config 配置刷新
客户端进行刷新操作. 1.添加 actuator包,这样 /refresh url才处于可用状态. <dependency> <groupId>org.springframew ...
- 为spring cloud config实现刷新动态掉的坑
正常搭建配置中心,网上教程多,这里不讨论,只记坑也是为了后来者少花时间在这里,由于是当时研究了好久才写的文章,所以只能提供问题的原因,当然会给出印证的思路,闲话不多说进入正题! 版本spring bo ...
- spring cloud 使用spring cloud bus自动刷新配置
Spring Cloud Bus提供了批量刷新配置的机制,它使用轻量级的消息代理(例如RabbitMQ.Kafka等)连接分布式系统的节点,这样就可以通过Spring Cloud Bus广播配置的变化 ...
- Spring Cloud config之一:分布式配置中心入门介绍
Spring Cloud Config为服务端和客户端提供了分布式系统的外部化配置支持.配置服务器为各应用的所有环境提供了一个中心化的外部配置.它实现了对服务端和客户端对Spring Environm ...
- spring cloud config客户端
上篇介绍了spring cloud config服务器,本篇介绍客户端.客户端主要是从config服务器获取配置信息. 代码示例 首先创建一个Maven项目,在pom.xml文件中添加依赖: < ...
- Spring Cloud Config实现集群配置中心
Spring Cloud Config为分布式系统提供了配置服务器和配置客户端,可以管理集群中的配置文件.使用Git.SVN等版本管理系统存放配置文件,配置服务器会到版本管理系统获取配置,集群中的配置 ...
- 通过总线机制实现自动刷新客户端配置(Consul,Spring Cloud Config,Spring Cloud Bus)
通过总线机制实现自动刷新客户端配置 方案示意图 利用Git服务的webhook通知功能,在每次更新配置之后,Git服务器会用POST方式调用配置中心的/actuator/bus-refresh接口,配 ...
- Spring Cloud Config Server 节点迁移引起的问题,请格外注意这一点!
前言: 虽然强烈推荐选择使用国内开源的配置中心,如携程开源的 Apollo 配置中心.阿里开源的 Nacos 注册&配置中心. 但实际架构选型时,根据实际项目规模.业务复杂性等因素,有的项目还 ...
随机推荐
- FIR定点提高精度的trick_02
作者:桂. 时间:2018-02-05 19:36:08 链接:http://www.cnblogs.com/xingshansi/p/8419182.html 一.概述 本文简要记录FIR的小tr ...
- groupby elasticsearch
GET usertag/usertag/_search { "query": { "match": { "tagname": "春 ...
- AliSQL 5.6.32 vs MySQL 5.7.15抢鲜测试
摘要: 今天我们有幸抢鲜测试AliSQL,直接拿来和MySQL 5.7.15对比看看. AliSQL刚宣布开源,我就提交申请内测名额,节前收到开放内测邀请,于是第一时间进行了测试了解,希望能给大 ...
- Android百日程序 开篇章:Intent打开网页
学习一下人家100日写100个网页的做法,我也用100日写100个完整的Android程序. 这些程序的最基本要求: 1 完整性-每一个程序都必须是独立可执行的 2 不反复性-所用的重点知识点都不一样 ...
- CentOS编译安装vim
#删除系统自带的vim rpm -qa | grep vim rpm -e vim-X11-7.4.629-5.el6_8.1.x86_64 vim-filesystem-7.4.629-5.el6_ ...
- 修改PS1变量
PS1='\[\e[7;46m\]\u\[\e[0m\]@\[\e[0;32m\]\h\[\e[0m\]:\[\e[0;34m\]\w\[\e[0m\]\$ ' from: http://profes ...
- Splunk Web页面的登录密码忘记了怎么办
splunk的web登录密码忘记的话,可以使用以下方法重置. 一.关闭splunk服务 /opt/splunk/bin/splunk stop 二.删除默认密码配置文件 三.重启启动splunk服务, ...
- Burpsuite如何抓取使用了SSL或TLS传输的 IOS App流量
之前一篇文章介绍了Burpsuite如何抓取使用了SSL或TLS传输的Android App流量,那么IOS中APP如何抓取HTTPS流量呢, 套路基本上与android相同,唯一不同的是将证书导入i ...
- mysql++ Query
mysqlpp:: Query类存储了Connection的指针,可以用它进行SQL语句的增删改查. 连上数据库后,使用mysqlpp::Connection::query()获取Query对象 Qu ...
- App store 应用审核由于 IPv6 网络问题被拒的一点分析
App store 应用审核由于 IPv6 网络问题被拒的一点分析 六月以后陆续有一些软件提交市场的时候被拒了,症状基本就是无法登陆啥的.我们公司的应用也未能幸免. 很多同学也想了不少办法,申诉. ...