Disconf安装配置

xiaoxiao2021-02-28  67

简介

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

专注于各种「分布式系统配置管理」的「通用组件」和「通用平台」, 提供统一的「配置管理服务」。

disconf: https://github.com/knightliao/disconfdemos: https://github.com/knightliao/disconf-demos-javawiki: https://github.com/knightliao/disconf/wiki

搭建前提

服务器要求

服务器需要能够访问外网配置暂不列举

安装依赖软件

安装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解压

第二步:准备配置文件

将你的配置文件放到此地址目录下(以下地址可自行设定):/home/work/dsp/disconf-rd/online-resources如果不确定如何配置,可以拷贝/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)

jdbc-mysql.propertiesjdbc.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=3600redis-config.propertiesredis.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=6zoo.propertieshosts=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=/disconfapplication.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 = sender@163.com EMAIL_PORT = 25 DEFAULT_FROM_EMAIL = disconf@163.com # # \u5b9a\u65f6\u6821\u9a8c\u4e2d\u5fc3\u7684\u914d\u7f6e\u4e0e\u6240\u6709\u5ba2\u6237\u7aef\u914d\u7f6e\u7684\u4e00\u81f4\u6027 #

*注意,即使只有一个redis,也应该配置两个redis client,否则将造成内部错误。*

第四步:构建

设置War包将要被部署的地址(以下地址可自行设定):/home/work/dsp/disconf-rd/war修改/home/disconf-master/disconf-web/src/main/resources/ehcache.xml,将updateCheck="false"改为true,否则启动tomcat时会自动访问www.terracotta.org检查更新

构建

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 adminadmintestUser1MhxzKhl9209testUser2MhxzKhl167testUser3MhxzKhl783testUser4MhxzKhl8758testUser5MhxzKhl112

如果想自己设置初始化的用户名信息,可以参考代码来自己生成用户:

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-TemplateMysqlRestFul APIRedis for user login/logoutH2内存数据库测试方案/Junit/SpringTest前端 HTMLJquery(1.10.4):JS工具集合Bootstrap(2.3.2):界面UINode(ejs/fs/eventproxy): 用于前端的HTML的模板化管理前后端接口(前后端分离) 完全Ajax接口JSONRestFul API
转载请注明原文地址: https://www.6miu.com/read-2625038.html

最新回复(0)