一、disconf客户端部署

disconf目前仅支持java客户端,下文针对java客户端安装作为整理,记录下安装部署的步骤

1.环境依赖

首先需要安装java环境及maven环境,不再过多介绍

2.下载disconf-for-java客户端

  [root@shuke client]# git clone https://github.com/knightliao/disconf-demos-java.git

[root@minion client]# tree -L 2
.
└── disconf-demos-java
├── disconf-spring-boot-demo      使用disconf的基于Spring的standalone demo程序
├── disconf-standalone-demo       集成了disconf和dubbo的基于Spring的standalone demo程序
├── disconf-standalone-dubbo-demo   使用disconf的spring-boot demo程序,更少的配置
├── pom.xml
└── README.md

4 directories, 2 files

  • 下文以disconf-standalone-demo为例
  • 编辑disconf-client客户端下载的配置文件
[root@minion rd]# vim /data/disconf/client/disconf-demos-java/disconf-standalone-demo/profile/rd/disconf.properties   

[root@minion rd]# egrep -v "^#|^$" disconf.properties
disconf.enable.remote.conf=true          #是否使用远程配置文件,true(默认)会从远程获取配置, false则直接获取本地配置
disconf.conf_server_host=127.0.0.1:8084      #修改为discon-web的访问地址
disconf.version=1_0_0_0      #app对应的版本号
disconf.app=dzhops         #app名称
disconf.env=rd      #app的环境
disconf.ignore=redis.properties code.properties #忽略的分布式配置,用空格分隔
disconf.conf_server_url_retry_times=1 #获取远程配置重试次数,默认3次
disconf.conf_server_url_retry_sleep_seconds=1 #获取远程配置 重试时休眠时间,默认是5秒
disconf.user_define_download_dir=./disconf/download #用户定义的下载文件夹, 远程文件下载后会放在这里。注意,此文件夹必须有有权限,否则无法下载到这里
disconf.enable_local_download_dir_in_class_path=true #下载的文件会被迁移到classpath根路径下,强烈建议将此选项置为 true(默认是true)
  • 编辑disconf-client客户端下载对应文件的配置文件(内容为需要下载的,自己在本地部署的应用程序所依赖的文件,从disconf-web下载)
[root@minion resources]# vim /data/disconf/client/disconf-demos-java/disconf-standalone-demo/src/main/resources/applicationContext.xml

      <!-- 使用托管方式的disconf配置(无代码侵入, 配置更改会自动reload)-->
<bean id="configproperties_disconf"
class="com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:/server.cfg</value> #从disconf-web下载的文件,存放在discon-web服务器上面,启动disconf-client客户端,文件将会被下载
<value>classpath:/settings.py</value> #从disconf-web下载的文件,存放在disconf-web服务器上面,启动disconf-client客户端,文件将会被下载
</list>
</property>
</bean>

3.使用maven构建项目

[root@minion disconf-demos-java]# pwd
/data/disconf/client/disconf-demos-java
[root@minion disconf-demos-java]# mvn package #构建下载环境依赖
[root@minion disconf-demos-java]# cd disconf-standalone-demo/
[root@minion disconf-standalone-demo]# cat README.md #查看readme说明
[root@minion disconf-standalone-demo]# mvn clean package #构建环境,生成target目录

[root@minion disconf-standalone-demo]# cd target/
[root@minion target]# ls
classes disconf-standalone-demo.jar disconf-standalone-demo.tar.gz maven-archiver maven-status original-disconf-standalone-demo.jar starter-run
[root@minion target]# cd starter-run/
[root@minion starter-run]# ls
disconf.properties disconf-standalone-demo.jar env logback.xml start.sh stop.sh    #启动及停止客户端程序目录,disconf.properties为配置文件

4.启动client进程

[root@minion starter-run]# sh start.sh   #启动进程
[root@minion starter-run]# sh stop.sh #停止进程

[root@shuke starter-run]# ps -ef | grep "disconf-standalone-demo.jar"      #查找客户端进程是否运行,可以在log目录下查看相关日志
root 20075 1 22 00:20 pts/2 00:00:04 java -server -Xms1024m -Xmx1024m -Xmn448m -Xss256K -XX:MaxPermSize=128m -XX:ReservedCodeCacheSize=64m -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:ParallelGCThreads=2 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Dlogback.configurationFile=file:logback.xml -jar disconf-standalone-demo.jar
root 20098 3975 0 00:20 pts/2 00:00:00 grep disconf-standalone-demo.jar

5.文件下载检查

文件下载成功后会存放在当前路径及disconf/download目录下,如果在disconf-web端修改文件内容,客户端会自动检测并下载更新.

disconf-client-for-java的更多相关文章

  1. Java实践:一个简易的http server和client的java源码学习和总结。

    一.基本思路: 1.服务器端通过socket(), 监听在TCP 8080端口,等待客户端来连接. 2.服务器端解析客户端的HTTP请求中的URI值,把本地的目录下指定文件通过java的读取文件的方式 ...

  2. elasticsearch系列七:ES Java客户端-Elasticsearch Java client(ES Client 简介、Java REST Client、Java Client、Spring Data Elasticsearch)

    一.ES Client 简介 1. ES是一个服务,采用C/S结构 2. 回顾 ES的架构 3. ES支持的客户端连接方式 3.1 REST API ,端口 9200 这种连接方式对应于架构图中的RE ...

  3. springCloud 服务注册启动报错<com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect>

    报错:com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: ...

  4. springCloud com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect

    1.com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: c ...

  5. Eureka服务注册中心相关错误com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect

    启动项目报错如下 原因: 在默认设置下,Eureka服务注册中心也会将自己作为客户端来尝试注册它自己,所以会出现 com.sun.jersey.api.client.ClientHandlerExce ...

  6. Elasticsearch Java client(ES Client 简介、Java REST Client、Java Client、Spring Data Elasticsearch)

    elasticsearch系列七:ES Java客户端-Elasticsearch Java client(ES Client 简介.Java REST Client.Java Client.Spri ...

  7. com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect

    com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: con ...

  8. Eureka服务注册中心错误:com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect

    报错信息 14:43:45.484 [main] INFO com.netflix.discovery.DiscoveryClient - Getting all instance registry ...

  9. 【转】C# client 与java netty 服务端的简单通信,客户端采用Unity

    http://blog.csdn.net/wilsonke/article/details/24721057 近日根据官方提供的通信例子自己写了一个关于Unity(C#)和后台通信的类,拿出来和大家分 ...

  10. 从头写个http client(java)

    不熟悉java,但我熟悉http,然后从头打造个简单的httpclient,支持get/post,支持gzip,支持重定向,支持encoding,支持transfer-encoding,支持ssl,支 ...

随机推荐

  1. Codeforces 221 E. Little Elephant and Shifts

    E. Little Elephant and Shifts time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  2. 解决gridview row 左边序列号 显示不完全的技巧

    放在主程序 入口处, public Form1() { InitializeComponent(); gridView1.IndicatorWidth = ; //<宽度值>官方推荐常用是 ...

  3. 【CodeForces】671 C. Ultimate Weirdness of an Array

    [题目]C. Ultimate Weirdness of an Array [题意]给定长度为n的正整数序列,定义一个序列的价值为max(gcd(ai,aj)),1<=i<j<=n, ...

  4. web上下文监听器ServletContextListener

    1 package com.liveyc.common.listener; import javax.servlet.ServletContextEvent; import javax.servlet ...

  5. 【BZOJ 1001】[BJOI2006]狼抓兔子(最大流)

    题目链接 最大流裸题,没什么好说吧,恰好点数多,考验网络流的效率,正好练\(Dinic\). #include <cstdio> #include <queue> #inclu ...

  6. Tensorflow中使用TFRecords高效读取数据--结合Attention-over-Attention Neural Network for Reading Comprehension

    原文链接:https://arxiv.org/pdf/1607.04423.pdf 本片论文主要讲了Attention Model在完形填空类的阅读理解上的应用. 转载:https://blog.cs ...

  7. layui的模块化和非模块化使用

    非模块化和模块化的区别是 非模块化不用每次都调用layui.use([],fun...)引入对应模块,引入的JS是/layui/layui.all.js 模块化必须每次都调用layui.use([], ...

  8. 工具===激活xmind 8

      [下载jar包]: https://stormxing.oss-cn-beijing.aliyuncs.com/files/XMindCrack.jar   方法: 打开xmind 8 安装目录的 ...

  9. 大数据系列之Kafka安装

    先简单说下安装kafka的流程..(可配置多个zookeeper,这篇文只说一个zookeeper场景) 1.环境配置:jdk1.7+ (LZ用的是jdk1.8) 2.资料准备:下载 kafka_2. ...

  10. UVALive 3668 A Funny Stone Game

    题目链接:UVALive - 3668 题目大意为给定n堆石子,每次的操作是选择三个数i<j<=k,从i中拿一枚石子,在j和k中分别放入一枚石子.不能操作者输.求先手是否能赢,若可以,则输 ...