disconf-web部署

简介

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

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

homepage: https://disconf.readthedocs.io
disconf: https://github.com/knightliao/disconf
demos: https://github.com/knightliao/disconf-demos-java
wiki: https://github.com/knightliao/disconf/wiki

配置

$ cd /disconf-web
$ cp profile/rd/application-demo.properties profile/rd/application.properties
$ vim profile/rd/application.properties
$ vim profile/rd/jdbc-mysql.properties
$ vim profile/rd/redis-config.properties
$ vim profile/rd/zoo.properties

配置文件包括:

  • jdbc-mysql.properties (数据库配置)
  • redis-config.properties (Redis配置,主要用于web登录使用)
  • zoo.properties (Zookeeper配置)
  • application.properties (应用配置)

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

构建

$ cd /disconf-web
$ mkdir /data/www/disconf/disconf-rd
$ mkdir /data/www/disconf/disconf-rd/online-resources
$ mkdir /data/www/disconf/disconf-rd/war
$ cp profile/rd/* /data/www/disconf/disconf-rd/online-resources/

$ ONLINE_CONFIG_PATH=/data/www/disconf/disconf-rd/online-resources
$ WAR_ROOT_PATH=/data/www/disconf/disconf-rd/war
$ export ONLINE_CONFIG_PATH
$ export WAR_ROOT_PATH
$ sh deploy/deploy.sh

这样会在 /data/www/disconf/disconf-rd/war 生成以下结果:

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

上线前的初始化工作

初始化数据库:

可以参考 disconf-web/sql/readme.md 来进行数据库的初始化。注意顺序执行

  • 0-init_table.sql
  • 1-init_data.sql
  • 201512/20151225.sql
  • 20160701/20160701.sql

里面默认有6个用户(请注意线上环境删除这些用户以避免潜在的安全问题)

name password
admin admin
testUser1 MhxzKhl9209
testUser2 MhxzKhl167
testUser3 MhxzKhl783
testUser4 MhxzKhl8758
testUser5 MhxzKhl112

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

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

Tomcat部署War

修改server.xml文件,在Host结点下设定Context:

<Context path="" docBase="/data/www/disconf/disconf-rd/war"></Context>

并设置端口为 8015,启动Tomcat,即可。

部署前端

修改 nginx.conf

upstream disconf {
    server 127.0.0.1:8015;
}

server {
    listen   8081;
    server_name disconf.com;
    access_log /data/www/logs/disconf/access.log;
    error_log /data/www/logs/disconf/error.log;

    location / {
        root /data/www/disconf/disconf-rd/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;
    }
}

关于host:这里的host设置成 disconf.com(可以自定义),但必须与application.properties里的domain一样。

上一篇 Linux服务器时间同步
下一篇 Spring Boot 集成 disconf-client
目录
文章列表
1 Git设置和取消代理
Git设置和取消代理
2
DialogFragment调用show()报Can not perform this action after onSaveInstanceState的解决办法
DialogFragment调用show()报Can not perform this action after onSaveInstanceState的解决办法
3
Python格式化千分位数字
Python格式化千分位数字
4
Vue组件中直接获取Vuex状态state数据
Vue组件中直接获取Vuex状态state数据
5
Nginx配置gzip中的坑
Nginx配置gzip中的坑
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。