分布式配置中心disconf安装部署

来源:互联网 发布:淘宝管控记录违规记录 编辑:程序博客网 时间:2024/06/05 16:34

disconf是一款分布式配置管理平台,包括 百度、滴滴出行、银联、网易、拉勾网、苏宁易购、顺丰科技 等知名互联网公司正在使用!

官方github地址:https://github.com/knightliao/disconf



一、必要软件安装

1.安装MySQL

2.安装Tomcat(apache-tomcat-7.0.50)

3.安装Nginx(nginx/1.5.3)

4.安装 zookeeeper (zookeeper-3.3.0)

5.安装 Redis (2.4.5)

6.安装maven

 

二、下载源码

官网地址:https://github.com/knightliao/disconf

下载zip文件,然后上传到CentOS的/home/panliguan/install_softs/disconf目录下(目录可自行决定)。

 

三、编译打包

1.解压软件

[root@localhost disconf]# unzipdisconf-master.zip

Archive: disconf-master.zip

d01a14f5d99fbaa304a226fe045d5feed22b52e4

   creating:disconf-master/

  inflating:disconf-master/.gitignore 

  inflating:disconf-master/.travis.yml 

  inflating:disconf-master/LICENSE

…………

 

2.maven打包

[root@localhost disconf]# cddisconf-master/

[root@localhost disconf-master]# mvnclean install

……

Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-assembly-plugin/2.3/maven-assembly-plugin-2.3.pom

Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-assembly-plugin/2.3/maven-assembly-plugin-2.3.pom (15 KB at 10.0 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-assembly-plugin/2.3/maven-assembly-plugin-2.3.jar

Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-assembly-plugin/2.3/maven-assembly-plugin-2.3.jar (217 KB at 14.9 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/org/reflections/reflections/0.9.9-RC1/reflections-0.9.9-RC1.pom

Downloaded: https://repo.maven.apache.org/maven2/org/reflections/reflections/0.9.9-RC1/reflections-0.9.9-RC1.pom (4 KB at 4.8 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/org/reflections/reflections-parent/0.9.9-RC1/reflections-parent-0.9.9-RC1.pom

……

 

3.配置环境变量

[root@localhost ~]# vi /etc/profile

添加:

#disconf

 

 

exportONLINE_CONFIG_PATH=/home/panliguan/install_softs/disconf/online-resources

exportWAR_ROOT_PATH=/home/panliguan/install_softs/disconf/war

 

[root@localhost ~]# source/etc/profile

 

 

四、准备配置文件

将配置文件放到环境变量指定目录下(/home/panliguan/install_softs/disconf/online-resources),如果不确定如何配置,可以拷贝/disconf-web/profile/rd目录下的文件。

1.切换到disconf-web/profile/rd目录

[root@localhost rd]# pwd

/home/panliguan/install_softs/disconf/disconf-master/disconf-web/profile/rd

 

2.拷贝指定文件

[root@localhost rd]# cpapplication-demo.properties jdbc-mysql.properties redis-config.propertieszoo.properties /home/panliguan/install_softs/disconf/online-resources/

 

3.查看拷贝结果

[root@localhost online-resources]#pwd

/home/panliguan/install_softs/disconf/online-resources

 

[root@localhost online-resources]# ll

总用量 16

-rw-r--r--. 1 rootroot 419 7月  26 18:59 application-demo.properties

-rw-r--r--. 1 rootroot 370 7月  26 18:59 jdbc-mysql.properties

-rw-r--r--. 1 rootroot 498 7月  26 18:59 redis-config.properties

-rw-r--r--. 1 rootroot 130 7月  26 18:59 zoo.properties

 

4.重命名application-demo.properties

[root@localhost online-resources]# mvapplication-demo.properties application.properties

 

 

注意:

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

 

 

五、构建

[root@localhost disconf-web]# cddisconf-web/

[root@localhost deploy]# shdeploy/deploy.sh

ONLINE_CONFIG_PATH is null, please set it in yourenv.

 

出错了,需要打开新的shell命令行!!!

然后到目录/home/panliguan/install_softs/disconf/disconf-master/disconf-web下,在执行:

[root@localhost deploy]# shdeploy/deploy.sh

Downloading: https://repo.maven.apache.org/maven2/commons-beanutils/commons-beanutils/1.6/commons-beanutils-1.6.jar

Downloaded: https://repo.maven.apache.org/maven2/commons-beanutils/commons-beanutils/1.6/commons-beanutils-1.6.jar (116 KB at 2.9 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/commons-collections/commons-collections/3.2/commons-collections-3.2.jar

Downloaded: https://repo.maven.apache.org/maven2/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar (687 KB at 15.3 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/org/projectlombok/lombok/1.14.4/lombok-1.14.4.jar

Downloaded: https://repo.maven.apache.org/maven2/javax/mail/mail/1.4.7/mail-1.4.7.jar (509 KB at 10.0 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/org/aspectj/aspectjweaver/1.7.4/aspectjweaver-1.7.4.jar

Downloaded: https://repo.maven.apache.org/maven2/c3p0/c3p0/0.9.1.2/c3p0-0.9.1.2.jar (597 KB at 9.9 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/org/hibernate/hibernate-validator/5.0.1.Final/hibernate-validator-5.0.1.Final.jar

Downloaded: https://repo.maven.apache.org/maven2/commons-collections/commons-collections/3.2/commons-collections-3.2.jar (558 KB at 9.1 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/org/jboss/logging/jboss-logging/3.1.1.GA/jboss-logging-3.1.1.GA.jar

Downloaded: https://repo.maven.apache.org/maven2/org/jboss/logging/jboss-logging/3.1.1.GA/jboss-logging-3.1.1.GA.jar (60 KB at 0.9 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/com/fasterxml/classmate/0.8.0/classmate-0.8.0.jar

Downloaded: https://repo.maven.apache.org/maven2/com/fasterxml/classmate/0.8.0/classmate-0.8.0.jar (59 KB at 0.9 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/cglib/cglib/2.2.2/cglib-2.2.2.jar

Downloaded: https://repo.maven.apache.org/maven2/org/projectlombok/lombok/1.14.4/lombok-1.14.4.jar (1153 KB at 14.8 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/asm/asm/3.3.1/asm-3.3.1.jar

Downloaded: https://repo.maven.apache.org/maven2/cglib/cglib/2.2.2/cglib-2.2.2.jar (281 KB at 3.6 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/commons-io/commons-io/2.4/commons-io-2.4.jar

Downloaded: https://repo.maven.apache.org/maven2/org/hibernate/hibernate-validator/5.0.1.Final/hibernate-validator-5.0.1.Final.jar (560 KB at 7.2 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.6.0/jackson-annotations-2.6.0.jar

Downloaded: https://repo.maven.apache.org/maven2/asm/asm/3.3.1/asm-3.3.1.jar (43 KB at 0.5 KB/sec)

Downloading: https://repo.maven.apache.org/maven2/commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.jar

……下载一大堆东西……

 

执行完成之后,会在/home/panliguan/install_softs/disconf/war生成以下文件:

[root@localhost war]# ll

总用量 36200

-rw-r--r--. 1 rootroot      419 7月  26 18:59 application.properties

-rw-r--r--. 1 rootroot 37039327 7月  26 19:31 disconf-web.war

drwxr-xr-x. 4 rootroot     4096 7月  26 19:31 html

-rw-r--r--. 1 rootroot      370 7月  26 18:59 jdbc-mysql.properties

-rw-r--r--. 1 rootroot      186 7月  18 10:44 jpaas_control

drwxr-xr-x. 3 rootroot       36 7月  26 19:31 META-INF

-rw-r--r--. 1 rootroot      498 7月  26 18:59 redis-config.properties

-rw-r--r--. 1 rootroot       49 7月  18 10:44 Release

drwxr-xr-x. 4 rootroot       44 7月  26 19:31 WEB-INF

-rw-r--r--. 1 rootroot      130 7月  26 18:59 zoo.properties

 

不知道为什么那些properties配置文件已被拷贝过来了!!!

 

六、修改配置

[root@localhost classes]# cd/home/panliguan/install_softs/disconf/war/WEB-INF/classes

配置文件包括:

- jdbc-mysql.properties (数据库配置)

- redis-config.properties (Redis配置)

- zoo.properties (Zookeeper配置)

- application.properties (应用配置)

 

根据实际情况,修改文件中的地址端口,调整日志目录

 

七、初始化数据库

按照/home/panliguan/install_softs/disconf/disconf-master/disconf-web/sql/readme.md说明,创建数据库和表,按照顺序导入数据

 

 

八、配置tomcat,部署war包

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

<Context path=""docBase="/home/panliguan/install_softs/disconf/war"></Context>

 

并设置端口为 8015

启动Tomcat,即可。

 

九、配置Nginx

在http这个标记对里面加上如下配置(/home/panliguan/install_softs/nginx/nginx-1.10.1/conf/nginx.conf):

upstreamdisconf {

    server 192.168.1.107:8015;

}

 

server{

    listen 8081;

    server_name 192.168.1.107;

   access_log /home/xxx/nginx/log/disconf/access.log;

   error_log /home/xxx//nginx/log/disconf/error.log;

 

   location / {

       root /usr/local/upsmart/disconf/war/html;

       if ($query_string) {

           expires max;

       }

   }

 

   location ~ ^/(api|export) {

       proxy_pass_header Server;

        proxy_set_header Host $host:8081;

       proxy_redirect off;

       proxy_set_header X-Real-IP $remote_addr;

       proxy_set_header X-Scheme $scheme;

       proxy_pass http://disconf;

   }

}

upstreamdisconf 配置中的端口必须与tomcat启动的端口一致

server中listen是启动该disconf前端的端口

里面需要修改access_log和error_log指定log的位置

disconf使用前后端分离的部署方式,前端配置在nginx是那个,后端api部署在tomcat中

 

10.启动

启动MySQL

启动redis(多实例启动,端口:6379、6380)

启动zookeeper(单机伪分布集群)

启动tomcat

启动nginx

打开浏览器:http://192.168.1.107:8081/
使用用户名admin和密码admin进入系统
至此disconf的web操作服务搭建完成
-------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 


原创粉丝点击