Disconf 分布式配置管理平台(安装配置)
依赖环境
Nginx:处理静态资源请求、动态请求转发到Tomcat Tomcat:处理Nginx的请求 Redis:用户session管理 MySQL:应用管理、用户管理、角色管理、环境管理、配置持久化 Zookeeper:管理Disconf配置信息,配置变更通过zk通知 JDK:zookkeeper依赖环境 mvn:disconf依赖环境
安装
1.安装nginx
本文使用openresty
tar -zxf openresty-1.13.6.1.tar.gz
cd openresty-1.13.6.1
./configure --user=www --group=www --with-http_stub_status_module --with-http_flv_module --with-http_gzip_static_module
make
make install
配置修改: vim /usr/local/openresty/nginx/conf/conf.d/disconf.test.com.conf
upstream disconf {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name disconf.test.com;
access_log /data/logs/nginx/access_disconf.test.com_80.log main buffer=10k flush=5s;
location / {
root /data/www/disconf.test.com/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;
}
}
2.安装Tomcat
Tomcat官网下载7.x以上版本的安装包: https://tomcat.apache.org/download-90.cgi 安装:
tar -zxvf apache-tomcat-9.0.5.tar.gz -C /usr/local/ && cd /usr/local/
mv apache-tomcat-9.0.5/ tomcat
启动: cd /usr/local/tomcat/bin && sh startup.sh
3.安装Redis
Redis官网下载安装包: https://redis.io/download 安装:
wget http://download.redis.io/releases/redis-4.0.8.tar.gz
tar -zxvf redis-4.0.8.tar.gz && cd redis-4.0.8
make
make install
cp redis.conf /etc
配置修改: vi /etc/redis.conf 将daemonize no修改为daemonize yes 修改requirepass foobared参数,设置密码及分配名字 启动: /usr/local/bin/redis-server /etc/redis.conf disconf需要双redis cp /etc/redis.conf /etc/redis2.conf 将port 6379修改为port 6380 启动 /usr/local/bin/redis-server /etc/redis2.conf
4.安装Mysql
yum -y install mysql-server
5.安装mvn
wget http://www-eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
tar xzf apache-maven-3.3.9-bin.tar.gz -C /usr/local/ && cd /usr/local/
mv apache-maven-3.3.9 maven
vi /etc/profile.d/maven.sh
export M2_HOME=/usr/local/maven
export PATH=${M2_HOME}/bin:${PATH}
source /etc/profile.d/maven.sh
mvn -version
6.安装Zookeeper及JDK
7.安装disconf
下载地址: https://github.com/knightliao/disconf/releases 安装: wget https://github.com/knightliao/disconf/archive/2.6.36.tar.gz tar -zxvf 2.6.36.tar.gz 创建目录,将配置文件放到目录online-resources下(以下地址可自行设定):
mkdir -p /data/www/disconf.test.com/online-resources
mkdir -p /data/www/disconf.test.com/war
cp disconf-2.6.36/disconf-web/profile/rd/* /data/www/disconf.test.com/online-resources/
#将application-demo.properties复制成application.properties
mv /data/www/disconf.test.com/online-resources/application-demo.properties /data/www/disconf.test.com/online-resources/application.properties
#修改application.properties配置
vim /data/www/disconf.test.com/online-resources/application.properties
#修改数据库配置
vim /data/www/disconf.test.com/online-resources/jdbc-mysql.properties
#修改Redis配置,主要用于web登录使用
vim /data/www/disconf.test.com/online-resources/redis-config.properties
#修改Zookeeper配置
vim /data/www/disconf.test.com/online-resources/zoo.properties
#构建
vim /etc/profile
#添加如下2行
export ONLINE_CONFIG_PATH=/data/www/disconf.test.com/online-resources
export WAR_ROOT_PATH=/data/www/disconf.test.com/war
#执行
source /etc/profile
#构建
cd disconf-web
sh deploy/deploy.sh
#导入数据结构
mysql -uroot -pMYSQL@2018 < 0-init_table.sql
mysql -uroot -pMYSQL@2018 disconf < 1-init_data.sql
mysql -uroot -pMYSQL@2018 disconf < 201512/20151225.sql
mysql -uroot -pMYSQL@2018 disconf < 20160701/20160701.sql
#部署war,修改server.xml文件,在Host结点下设定Context
vim /usr/local/tomcat/conf/server.xml
#在Host节点下添加以下配置(搜索`Host`第一个Host配置下添加)
<Context path="" docBase="/data/www/disconf.test.com/war"></Context>
#重启tomcat
##测试 需先绑定host 打开disconf.test.com即可,默认登录账号、密码为admin、admin