用git2consul从Git同步配置到Consul
2020/2/20 8:09:37
本文主要是介绍用git2consul从Git同步配置到Consul,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
TIPS
当且仅当
spring.cloud.consul.config.format=files
时,才可用git2consul管理配置,其他格式无法使用。
单机版Consul的配置是不持久化的,一旦重启就会丢失,而开发过程中,重启Consul可能比较频繁。要想解决这个问题,可将配置存储到Git仓库,并使用git2consul将配置同步到Consul中,以下是步骤。
安装Node.js
下载Node.js
前往 https://nodejs.org/en/download/
可下载最新版本Node.js;前往 https://nodejs.org/en/download/releases/
可下载指定版本Node.js;根据自己的操作系统,下载安装即可。
TIPS
尽量安装LTS版本,例如:
10.16.3
安装Node.js
参考 https://www.runoob.com/nodejs/nodejs-install-setup.html
安装Node.js,常见系统安装说明都有。
安装git2consul
指定如下命令即可安装git2consul
npm install -g git2consul
如果网络不好,安装速度过慢,可使用如下命令:
npm install -g git2consul --registry=https://registry.npm.taobao.org
注意:对于Windows操作系统,需执行:
npm install -g consul-windows
配置git2consul
准备配置文件,名为 git2consul.json
内容如下:
{ // 配置版本 "version": "1.0", "repos": [ { // 名称,指的是在consul里面的目录名称 "name": "config", // 要同步的Git仓库 "url": "你的git仓库", "branches": [ // 要同步的分支 "master" ], // 是否要把分支名称作为Consul的key前缀 "include_branch_name": false, "hooks": [ { // 拉取模式 "type": "polling", // 同步的间隔(分钟) "interval": "1" } ] } ] }
其他选项详见:https://github.com/breser/git2consul
启动git2consul
执行如下命令,即可启动git2consul
git2consul --config-file /Users/itmuch/develop/git2consul.json
注意:对于Windows操作系统,需执行:
git2consul-windows --config-file C:/xxxx/xxx/git2consul.json
参考文档
- git2consul的GitHub:https://github.com/breser/git2consul
- Spring Cloud Consul官方文档:https://cloud.spring.io/spring-cloud-static/spring-cloud-consul/2.1.3.RELEASE/single/spring-cloud-consul.html
- spring cloud 使用 git2consul 管理配置中心:https://blog.csdn.net/qq_19671173/article/details/82260070
- fix crash on windows:https://github.com/breser/git2consul/pull/173
本文首发
这篇关于用git2consul从Git同步配置到Consul的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-04el-table 开启定时器下,表格的选中状态会消失是什么原因-icode9专业技术文章分享
- 2024-10-03如何安装和初始化飞牛私有云 fnOS?-icode9专业技术文章分享
- 2024-10-03如何安装 App 并连接到飞牛 NAS?-icode9专业技术文章分享
- 2024-10-03如何安装飞牛 TV 并连接到影视服务器?-icode9专业技术文章分享
- 2024-10-03如何在PVE和ESXI上安装飞牛私有云 fnOS?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS安装系统异常情况处理-icode9专业技术文章分享
- 2024-10-03飞牛NAS如何创建存储空间?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS硬盘会自动休眠吗?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS如何安装飞牛影视和创建媒体库?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS如何为家人朋友开通影视账号?-icode9专业技术文章分享