Disconf安裝配置

簡介

Distributed Configuration Management Platform(分佈式配置管理平臺)

專注於各種「分佈式系統配置管理」的「通用組件」和「通用平臺」, 提供統一的「配置管理服務」。

搭建前提

服務器要求

  • 服務器需要能夠訪問外網
  • 配置暫不列舉

安裝依賴軟件

  • 安裝Mysql(Ver 14.12 Distrib 5.0.45, for unknown-linux-gnu (x86_64) using EditLine wrapper)
  • 安裝Tomcat(apache-tomcat-7.0.50)
  • 安裝Nginx(nginx/1.5.3)
  • 安裝 zookeeeper (zookeeper-3.3.0)
  • 安裝 Redis(2.4.5)
  • 安裝 Maven(3.2.3)

第一步:Disconf下載

下載地址:https://github.com/knightliao/disconf,我選擇的版本是disconf-master-2.6.36(如果版本不一致可能存在差異)。

        下載下來壓縮包爲disconf-master.zip。請使用unzip disconf-master.zip解壓

第二步:準備配置文件

  1. 將你的配置文件放到此地址目錄下(以下地址可自行設定):
    /home/work/dsp/disconf-rd/online-resources
  2. 如果不確定如何配置,可以拷貝/disconf-web/profile/rd/目錄下的文件,拷貝過去後修改即可。
    配置文件包括:
    - jdbc-mysql.properties (數據庫配置)
    - redis-config.properties (Redis配置,主要用於web登錄使用)
    - zoo.properties (Zookeeper配置)
    - application.properties (應用配置)
    注意,記得執行將application-demo.properties複製成application.properties:
       cp application-demo.properties application.properties

第三步:配置(/home/work/dsp/disconf-rd/online-resources)

  1. jdbc-mysql.properties
    jdbc.driverClassName=com.mysql.jdbc.Driver
    
    jdbc.db_0.url=jdbc:mysql://10.100.96.138:3306/disconf?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=false
    jdbc.db_0.username=root
    jdbc.db_0.password=123456
    
    jdbc.maxPoolSize=20
    jdbc.minPoolSize=10
    jdbc.initialPoolSize=10
    jdbc.idleConnectionTestPeriod=1200
    jdbc.maxIdleTime=3600
  2. redis-config.properties
    redis.group1.retry.times=2
    
    redis.group1.client1.name=BeidouRedis1
    redis.group1.client1.host=10.100.160.132
    redis.group1.client1.port=7001
    redis.group1.client1.timeout=5000
    redis.group1.client1.password=foobared
    
    redis.group1.client2.name=BeidouRedis2
    redis.group1.client2.host=10.100.160.132
    redis.group1.client2.port=7002
    redis.group1.client2.timeout=5000
    redis.group1.client2.password=foobared
    
    redis.group1.client1.name=BeidouRedis3
    redis.group1.client1.host=10.100.160.133
    redis.group1.client1.port=7003
    redis.group1.client1.timeout=5000
    redis.group1.client1.password=foobared
    
    redis.group1.client2.name=BeidouRedis4
    redis.group1.client2.host=10.100.160.133
    redis.group1.client2.port=7004
    redis.group1.client2.timeout=5000
    redis.group1.client2.password=foobared
    
    redis.group1.client1.name=BeidouRedis5
    redis.group1.client1.host=10.100.160.134
    redis.group1.client1.port=7005
    redis.group1.client1.timeout=5000
    redis.group1.client1.password=foobared
    
    redis.group1.client2.name=BeidouRedis6
    redis.group1.client2.host=10.100.160.134
    redis.group1.client2.port=7006
    redis.group1.client2.timeout=5000
    redis.group1.client2.password=foobared
    
    redis.evictor.delayCheckSeconds=300
    redis.evictor.checkPeriodSeconds=30
    redis.evictor.failedTimesToBeTickOut=6
  3. zoo.properties
    hosts=10.100.160.132:2181,10.100.160.133:2181,10.100.160.134:2181
    
    # zookeeper\u7684\u524D\u7F00\u8DEF\u5F84\u540D
    zookeeper_url_prefix=/disconf
  4. application.properties
    #
    # \u670d\u52a1\u5668\u7684domain
    #
    
    domain=disconf.com
    
    #
    # \u90ae\u7bb1\u8bbe\u7f6e
    #
    
    EMAIL_MONITOR_ON = true
    EMAIL_HOST = smtp.163.com
    EMAIL_HOST_PASSWORD = password
    EMAIL_HOST_USER = [email protected]
    EMAIL_PORT = 25
    DEFAULT_FROM_EMAIL = [email protected]
    
    # 
    # \u5b9a\u65f6\u6821\u9a8c\u4e2d\u5fc3\u7684\u914d\u7f6e\u4e0e\u6240\u6709\u5ba2\u6237\u7aef\u914d\u7f6e\u7684\u4e00\u81f4\u6027
    #
    

*注意,即使只有一個redis,也應該配置兩個redis client,否則將造成內部錯誤。*

第四步:構建

  1. 設置War包將要被部署的地址(以下地址可自行設定):
    /home/work/dsp/disconf-rd/war
  2. 修改/home/disconf-master/disconf-web/src/main/resources/ehcache.xml,將updateCheck="false"改爲true,否則啓動tomcat時會自動訪問www.terracotta.org檢查更新
  3. 構建

    ONLINE_CONFIG_PATH=/home/work/dsp/disconf-rd/online-resources
    WAR_ROOT_PATH=/home/work/dsp/disconf-rd/war
    export ONLINE_CONFIG_PATH
    export WAR_ROOT_PATH
    cd /home/disconf-master/disconf-web
    sh deploy/deploy.sh

    這樣會在 /home/work/dsp/disconf-rd/war 生成以下結果:

    disconf-web.war - html - META-INF - WEB-INF

第五步:上線前的初始化工作

初始化數據庫:

可以參考 sql/readme.md 來進行數據庫的初始化。注意順序執行
0-init_table.sql
1-init_data.sql
201512/20151225.sql
20160701/20160701.sql

裏面默認有6個用戶(請注意線上環境刪除這些用戶以避免潛在的安全問題

 

name
pwd
adminadmin
testUser1MhxzKhl9209
testUser2MhxzKhl167
testUser3MhxzKhl783
testUser4MhxzKhl8758
testUser5MhxzKhl112

如果想自己設置初始化的用戶名信息,可以參考代碼來自己生成用戶:

src/main/java/com/baidu/disconf/web/tools/UserCreateTools.java

第六步:部署War

修改server.xml文件,在Host結點下設定Context:

<Context path="" docBase="/home/work/dsp/disconf-rd/war"></Context>

並設置端口爲 8080

啓動Tomcat,即可。

第七步:部署前端

upstream disconf {
server 127.0.0.1:8015;
}

server {

listen 8081;
server_name disconf.com;
access_log /home/work/var/logs/disconf/access.log;
error_log /home/work/var/logs/disconf/error.log;

location / {
root /home/work/dsp/disconf-rd/war/html;
index login.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;
}
}

關於host
這裏的 host 設置成 disconf.com (可以自定義),但它 必須與 application.properties 裏的domain一樣。
然後瀏覽器的訪問域名也是這個。

業務功能

  • 支持用戶登錄/登出
  • 瀏覽配置
    • 按 APP/版本/環境 選擇
  • 修改配置
    • 修改配置項
    • 修改配置文件
  • 新建配置
    • 新建配置項
    • 新建配置文件
    • 新建APP

架構方案

Nginx(處理靜態請求) + Tomcat(處理動態請求)

  • 後端
    • SpringMvc(Spring 4.1.7.RELEASE)
    • Jdbc-Template
    • Mysql
    • RestFul API
    • Redis for user login/logout
    • H2內存數據庫測試方案/Junit/SpringTest
  • 前端
    • HTML
    • Jquery(1.10.4):JS工具集合
    • Bootstrap(2.3.2):界面UI
    • Node(ejs/fs/eventproxy): 用於前端的HTML的模板化管理
  • 前後端接口(前後端分離)
    • 完全Ajax接口
    • JSON
    • RestFul API
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章