天天看點

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

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.解壓軟體

[[email protected] 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打包

[[email protected] disconf]# cddisconf-master/

[[email protected] 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.配置環境變量

[[email protected] ~]# vi /etc/profile

添加:

#disconf

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

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

[[email protected] ~]# source/etc/profile

四、準備配置檔案

将配置檔案放到環境變量指定目錄下(/home/panliguan/install_softs/disconf/online-resources),如果不确定如何配置,可以拷貝/disconf-web/profile/rd目錄下的檔案。

1.切換到disconf-web/profile/rd目錄

[[email protected] rd]# pwd

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

2.拷貝指定檔案

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

3.檢視拷貝結果

[[email protected] online-resources]#pwd

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

[[email protected] 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

[[email protected] online-resources]# mvapplication-demo.properties application.properties

注意:

即使隻有一個redis,也應該配置兩個redis client,否則将造成内部錯誤。

五、建構

[[email protected] disconf-web]# cddisconf-web/

[[email protected] deploy]# shdeploy/deploy.sh

ONLINE_CONFIG_PATH is null, please set it in yourenv.

出錯了,需要打開新的shell指令行!!!

然後到目錄/home/panliguan/install_softs/disconf/disconf-master/disconf-web下,在執行:

[[email protected] 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生成以下檔案:

[[email protected] 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配置檔案已被拷貝過來了!!!

六、修改配置

[[email protected] 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操作服務搭建完成

-------------------------------------------------------------------------------------------------------------------------------------------------------------

繼續閱讀