disconf搭建


簡介:

  Distributed Configuration Management Platform(分布式配置管理平台)

  它是百度的一套完整的基於zookeeper的分布式配置統一解決方案,具有如下特性:

  • 部署極其簡單:同一個上線包,無須改動配置,即可在 多個環境中(RD/QA/PRODUCTION) 上線
  • 部署動態化:更改配置,無需重新打包或重啟,即可 實時生效
  • 統一管理:提供web平台,統一管理 多個環境(RD/QA/PRODUCTION)、多個產品 的所有配置
  • 支持微服務架構   

模塊架構圖

 

 

模塊信息

  • CLIENT: client目標是支持多語言。目前只提供了java語言客戶端。
    • disconf-core: 分布式配置基礎包模塊
    • disconf-client: 分布式配置客戶端模塊, 依賴disconf-core包。 用戶程序使用它作為Jar包進行分布式配置編程。
    • disconf-tool: 分布式配置工具包,依賴disconf-core包。 Disconf-tool是disconf的輔助工具類, 目前使用不多,建議不使用。
  • 管理端:disconf-web是統一的分布式配置管理平台。disconf-web: 分布式配置平台服務模塊, 依賴disconf-core包。采用SpringMvc+純HTML方式(前后端分離架構)實現。用戶使用它來進行日常的分布式配置管理。

 

java client: disconf-client 使用

在您的 Maven POM 文件里加入:

<dependency> <groupId>com.baidu.disconf</groupId> <artifactId>disconf-client</artifactId> <version>2.6.31</version> </dependency>

server: disconf-web 使用

部署方法請參見:https://github.com/knightliao/disconf/tree/master/disconf-web

 

根據官方文檔,web部署基本上以下幾步:

1.配置環境
  disconf運行需要的軟件:zookeeper、redis、mysql、nginx、tomcat

2.下載代碼
  cd work/github
  git clone https://github.com/knightliao/disconf.git

3.修改環境
  sudo vi /etc/profile,在文件的末尾加上
  ONLINE_CONFIG_PATH=/usr/local/xxx/disconf/source
  WAR_ROOT_PATH=/usr/local/xxx/disconf/war
  export ONLINE_CONFIG_PATH
  export WAR_ROOT_PATH

4.配置更改
  cp work/github/disconf/disconf-web/profile/rd/application-demo.properties jdbc-mysql.properties 

  redis-config.properties zoo.properties log4j.properties logback.xml rabbit.properties /usr/local/xxx/disconf/source
  將application-demo.properties修改成application.properties(mv或者cp命令都可以)
  然后將/usr/local/xxx/disconf/source下的這4個配置文件修改成自己環境相關的配置
  application.properties
  該文件中主要是配置了監控郵件發送和接受的服務器和郵箱地址
  zoo.properties
  主要修改里面的hosts,指定zookeeper集群的host的端口
  jdbc-mysql.properties
 主要修改數據庫的host和mysql的用戶名和密碼
 redis-config.properties
 主要修改2個實例的host和端口

 log4j.properties
 主要修改日志存放的路徑

log4j.appender.dailyRolling.File=/home/xxx/xxx/tomcat/log/disconf-log4j.log

 logback.xml
 主要修改web和監控的log存放位置

<property name="log.base" value="/home/xxx/tomcat/log/disconf-web"/>
<property name="log.monitor" value="/home/xxx/tomcat/log/monitor"/


rabbit.properties
修改用戶名和密碼以及端口(自己安裝的默認端口是5672)

 

5.生成war包

  cd disconf/disconf-web
  sh deploy/deploy.sh

6.初始化數據庫

如何初始化根據disconf-web下的sql文件夾下的README.md來初始化

7.tomcat配置,nginx配置
 在tomcat的server.xml中加入
 <Context path="" docBase="/usr/local/xxx/disconf/war"></Context>

 在http這個標記對里面加上如下配置(/etc/nginx/nginx.conf):
 upstream disconf {
    server 127.0.0.1:8080;
 }

 server {
    listen 8991;
    server_name localhost;
    access_log /home/xxx/nginx/log/disconf/access.log;
    error_log /home/xxx//nginx/log/disconf/error.log;
    location / {
        root /usr/local/xxx/disconf/war/html;
        if ($query_string) {
            expires max;
        }
    }
    location ~ ^/(api|export) {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_pass http://disconf;
    }
}
upstream disconf 配置中的端口必須與tomcat啟動的端口一致
server中listen是啟動該disconf前端的端口
里面需要修改access_log和error_log指定log的位置
disconf使用前后端分離的部署方式,前端配置在nginx是那個,后端api部署在tomcat中

8.啟動
  啟動tomcat和nginx,瀏覽器輸入:http://localhost:8991/
  用戶名和密碼都是admin
  ok,disconf的web操作服務搭建完成



 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM