- 環境配置
disconf運行需要如下軟件:mysql、nginx、tomcat、zookeeper、redis,這個網上可以找到很多種安裝配置的方法 - clone disconf
disconf的代碼在github上開源了,是一個很好的分佈式配置管理平臺,github上很多人fork了
下載至本地
cd work/github
git clone https://github.com/knightliao/disconf.git - 修改環境變量
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
注意:disconf這個文件夾必須有寫的權限 - 修改配置
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和端口
rabbit.properties
修改用戶名和密碼以及端口(自己安裝的默認端口是5672)
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"/> - 生成war包
cd disconf/disconf-web
sh deploy/deploy.sh
然後會發現war的內容會生成在/usr/local/xxx/disconf/war這個文件夾下 - 初始化數據庫
如何初始化根據disconf-web下的sql文件夾下的README.md來初始化 - tomcat配置
在tomcat的server.xml中加入
<Context path="" docBase="/usr/local/xxx/disconf/war"></Context> - nginx配置
在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中 - 啓動
分別啓動tomcat和nginx,打開瀏覽器:http://localhost:8991/
使用用戶名admin和密碼admin進入系統
至此disconf的web操作服務搭建完成
大概長成下面的樣子,接下去需要了解如何使用該平臺
disconf-搭建
參考:https://github.com/knightliao/disconf/wiki
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.