自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Spring Cloud Config的配置中心獲取不到最新配置信息的問題

企業(yè)動態(tài)
本篇源于Spring Cloud Config的一個問題,但這個問題并非所有人都會遇到。如果您遇到了,那必須得看看這篇,如果沒有遇到您也應該看看,防患于未然!

[[208203]]

本篇源于Spring Cloud Config的一個問題,但這個問題并非所有人都會遇到。如果您遇到了,那必須得看看這篇,如果沒有遇到您也應該看看,防患于未然!

問題描述

之前有朋友提出Spring Cloud Config的配置中心在運行一段時間之后,發(fā)現修改了配置信息,但是微服務應用并拿不到新的配置內容。同時,發(fā)現配置中心存儲配置的目錄/tmp的配置內容被清空了。

原因與解決

首先,分析一下上面的問題,其實已經有一定的線索。表面現象是微服務從配置中心獲取配置信息的時候獲取不到***的配置,而其根本原因就是在/tmp目錄下的緩存?zhèn)}庫已經被清空了,所以導致無法正常的通過Git獲取到***配置,那么自然各個微服務應用就無法獲取***配置了。

其實該問題在Spring Cloud的官方文檔中也有對應的說明,原文如下:

With VCS based backends (git, svn) files are checked out or cloned to the local filesystem. By default they are put in the system temporary directory with a prefix of config-repo-. On linux, for example it could be /tmp/config-repo-<randomid>. Some operating systems routinely clean out temporary directories. This can lead to unexpected behaviour such as missing properties. To avoid this problem, change the directory Config Server uses, by setting spring.cloud.config.server.git.basedir or spring.cloud.config.server.svn.basedir to a directory that does not reside in the system temp structure.

根據上面的內容,我們可以知道在某些系統中,對于/tmp目錄進行周期性的清理,所以也就有了上面所說的問題。

從文檔中我們也已經知道如果去解決該問題,無非就是通過spring.cloud.config.server.git.basedir或spring.cloud.config.server.svn.basedir參數來指定一個不會被定期清理的目錄。比如,我們可以設置:

  1. spring.cloud.config.server.git.basedir=config-repo 

其他問題

這里需要注意一下,該參數的設置依然有一定的問題。按理解,如上配置的話,應該是在配置中心程序所在的目錄下創(chuàng)建一個config-repo目錄來進行存儲。但是,在測試了Dalston SR1和SR2版本之后,發(fā)現該配置只會將內容存儲到配置中心程序的同一級目錄下,并不會創(chuàng)建一個config-repo目錄。

但是,如果我們這樣設置,就可以將配置的緩存內容存儲在配置中心所在目錄下的config-repo目錄中了:

  1. spring.cloud.config.server.git.basedir=config-repo/config-repo 

【本文為51CTO專欄作者“翟永超”的原創(chuàng)稿件,轉載請通過51CTO聯系作者獲取授權】

戳這里,看該作者更多好文

責任編輯:武曉燕 來源: 51CTO專欄
相關推薦

2021-11-16 11:45:00

SpringSpring ClouJava

2018-07-10 14:55:32

Git存儲配置

2010-08-06 14:53:35

思科路由器配置信息

2018-07-27 15:43:24

Spring Clou管理架構

2018-05-16 15:45:19

SpringCloudConfig

2017-07-28 16:41:53

Spring Clou微服務架構

2018-06-22 15:46:45

Spring Clou加密處理

2010-02-04 16:57:40

Android配置信息

2019-09-24 16:15:03

架構配置代碼

2009-12-17 10:08:06

Cisco路由器配置信

2023-06-12 00:20:42

Go配置管理庫

2018-05-23 15:58:27

Spring Clou微服務架構

2018-07-19 14:58:14

Spring Clou微服務架構

2009-12-21 13:27:45

WCF服務配置信息

2023-05-04 08:09:33

serviceId路徑謂詞中心注冊

2025-03-03 10:27:33

配置中心微服務架構

2009-03-02 10:00:00

口令路由器交換機

2018-10-09 11:27:24

阿里云ACM

2023-09-12 13:12:23

服務器系統

2009-11-17 17:00:47

寬帶路由器配置
點贊
收藏

51CTO技術棧公眾號