disconf-web在windows下的部署

来源:互联网 发布:mac tree 编辑:程序博客网 时间:2024/05/17 22:52
disconf,全称 Distributed Configuration Management Platform(分布式配置管理平台),是java下的一个开源项目,其地址为:https://github.com/knightliao/disconf

因为作者关于disconf-web项目的部署部分说明完全基于linux,笔者本机不想装个虚拟机再装Linux,所以折腾了N长时间,还找了Java方面的相关人员帮助,好不容易才在windows上成功的部署了web项目,故而在此记录下

disconfig_web的部署说明地址为:https://github.com/knightliao/disconf/tree/master/disconf-web#how-to-deploy

必须软件安装

1、Tomcat ,下载地址:http://tomcat.apache.org/ ,安装及配置(含java):http://jingyan.baidu.com/article/624e7459a7d6e734e9ba5a70.html

2、Nginx,下载地址:http://nginx.org/en/download.html,安装及配置:http://blog.163.com/njut_wangjian/blog/static/1657964252013327103716818/,这里因为本机已经装了IIS,所以配置上将Nginx的端口设置成了8081

3、zookeeeper,下载地址:https://zookeeper.apache.org/releases.html#download,安装及配置:中文版、英文版,这里我部署了三个服务端,配置如下:

物理结构如下:


4、mysql,本机已安装,忽略此步

5、redis,局域网服务器已安装,忽略此步


项目配置修改

此处按帮助说明修改成你实际的配置即可,这里忽略说明


将disconf-web打包成war包

因为没Linux,这里就跟文档上描述的不一样了,下载IdeaIU,安装后,在IDE中打开disconf-master下的pom.xml,当项目加载完成后,选择disconfig-web项目,在工具栏选择  Build -- Build Artifacts...,单击All,之后就是等着maven下载,以及war包生成了

生成的最终target应当如下


生成的结果看起来跟帮助说明中的不一样,但没关系,我们手工调整,先建立个war文件夹,然后分别将war包和相关文件夹从disconfig-web及生成的target下copy出来,最终结果如下,tmp文件夹可以忽略


将你修改的项目配置文件复制并覆盖 WEB-INF\classes 下的同名文件,然后修改Tomact的配置,在Host下增加Context配置,其docBase配置为你的war文件夹物理路径,举例来说我本机是配置成了 C:\\apache-tomcat-8.0.35\\webapps\\disconfig-rd\\war,注意这里反斜杠在xml中要配置成双反斜杠,Tomact端口部分我没变动,还是8080


MySql数据还原

按帮助说明一步步还原即可,此处忽略


Nginx部署

与帮助文档不同的地方在于:去掉了 upstream disconf,将listen端口设置成了8082(因为8081被我设置给了nginx自身),将root修改成了自己的物理路径,最重要的是将proxy_pass修改成了 http://127.0.0.1:8080

[html] view plain copy
  1. listen       8082;  
  2. server_name  localhost;  
  3.   
  4. #charset koi8-r;  
  5.   
  6. #access_log  logs/host.access.log  main;  
  7.   
  8. location / {  
  9.     root C:\apache-tomcat-8.0.35\webapps\disconfig-rd\war\html;  
  10.     if ($query_string) {  
  11.         expires max;  
  12.     }  
  13. }  
  14.   
  15. location ~ ^/(api|export) {  
  16.     proxy_pass_header Server;  
  17.     proxy_set_header Host $http_host;  
  18.     proxy_redirect off;  
  19.     proxy_set_header X-Real-IP $remote_addr;  
  20.     proxy_set_header X-Scheme $scheme;  
  21.     proxy_pass http://127.0.0.1:8080;  
  22. }  
依照上述步骤做完之后,依次开启各种服务,然后在地址栏中输入 http://localhost:8082 即可看到disconfig-web的界面了
原创粉丝点击