dubbo-admin管理平臺搭建
一、前言
dubbo的使用,其實只需要有註冊中心,消費者,提供者這三個就可以使用了,但是並不能看到有哪些消費者和提供者,為了更好的除錯,發現問題,解決問題,因此引入dubbo-admin。通過dubbo-admin可以對消費者和提供者進行管理。
二、下載與配置打包
下載下來是這樣的一個目錄結構:
但是這裡我們只關心dubbo-admin這個資料夾。
其實下面所謂配置的目的就是為了得到war包,war包網上也有,但是下載了很多下來都會有問題,原因可能是每個人的電腦jdk版本或其他環境不一樣,因此我們自己打包一個war就好。
打包war包,進入dubbo-admin這個檔案目錄 執行命令:
mvn package -Dmaven.skip.test=true
- 1
- 1
如果看到如下結果,說明打包成功了:
如果打包好後放入Tomcat啟動報錯:
1.錯誤:ERROR context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException:2.主要原因:主要是由於jdk8不能正常執行,切換成jdk8一下的可以執行
3.jdk8解決辦法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
修改pom.xml檔案 1、webx的依賴改為3.1.6版; <dependency> <groupId>com.alibaba.citrus</groupId> <artifactId>citrus-webx-all</artifactId> <version>3.1.6</version> </dependency> 2、新增velocity的依賴,我用了1.7; <dependency |
我的pom.xml檔案
修改dubbo-admin的pom檔案,這個檔案可以被正常打包,支援jdk1.7,jdk1.8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.alibaba</groupId> <artifactId>dubbo-parent</artifactId> <version>2.5.4-SNAPSHOT</version> </parent> <artifactId>dubbo-admin</artifactId> <packaging>war</packaging> <name>${project.artifactId}</name> <description>The admin module of dubbo project</description> <properties> <wtpversion>1.5</wtpversion> <wtpContextName>/</wtpContextName> <eclipse.useProjectReferences>false</eclipse.useProjectReferences> <skip_maven_deploy>false</skip_maven_deploy> </properties> <dependencies> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>2.5.3</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.alibaba.citrus</groupId> <artifactId>citrus-webx-all</artifactId> <version>3.1.6</version> </dependency> <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> </dependency> <dependency> <groupId>org.jboss.netty</groupId> <artifactId>netty</artifactId> </dependency> <dependency> <groupId>org.apache.mina</groupId> <artifactId>mina-core</artifactId> </dependency> <dependency> <groupId>org.glassfish.grizzly</groupId> <artifactId>grizzly-core</artifactId> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> </dependency> <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> </dependency> <dependency> <groupId>org.apache.bsf</groupId> <artifactId>bsf-api</artifactId> </dependency> <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> </dependency> <dependency> <groupId>com.github.sgroschupf</groupId> <artifactId>zkclient</artifactId> </dependency> <dependency> <groupId>com.netflix.curator</groupId> <artifactId>curator-framework</artifactId> </dependency> <dependency> <groupId>com.googlecode.xmemcached</groupId> <artifactId>xmemcached</artifactId> </dependency> <dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId> </dependency> <dependency> <groupId>com.caucho</groupId> <artifactId>hessian</artifactId> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> </dependency> <dependency> <groupId>javax.cache</groupId> <artifactId>cache-api</artifactId> </dependency> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity</artifactId> <version>1.7</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>${jetty_version}</version> <configuration> <contextPath>/</contextPath> <scanIntervalSeconds>10</scanIntervalSeconds> <connectors> <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> <port>8080</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> </configuration> </plugin> </plugins> </build> </project> |
如果一直打包不成功,那麼直接下載博主的war試試吧,注意博主的jdk是1.7的,下載連結:
打包成功之後,就會發現dubbo-admin下多了個target資料夾,開啟target資料夾,發現裡面有個war包:
三、安裝dubbo-admin
第二步我們得到dubbo-admin-2.5.4-SNAPSHOT.war,下面我們將這個war包部署到tomcat上。
把dubbo-admin-2.5.4-SNAPSHOT.war放到tomcat的webapps目錄下:
然後開啟tomcat的conf目錄下的server.xml檔案,把啟動埠改成8090,因為zookeeper預設使用的是8080,以免衝突:
啟動tomcat,讓它把war解壓了
如果一直提示unable to open the service ‘tomcat*’,那麼重新安裝一個tomcat(注意一定要使用tomcat安裝包,重新安裝,不是解壓可用那種),這裡提供window的安裝包下載:http://download.csdn.net/detail/u013142781/9376343
tomcat的webapps裡面就會多了這個資料夾:
然後就可以把tomcat stop了
開啟剛剛tomcat解壓生成的dubbo.properties,我的在Tomcat 7.0\webapps\dubbo-admin-2.5.4-SNAPSHOT\WEB-INF下:
內容是:
dubbo.registry.address=zookeeper://127.0.0.1:2181
dubbo.admin.root.password=root
dubbo.admin.guest.password=guest
- 1
- 2
- 3
- 1
- 2
- 3
知道root的密碼:root,guest的密碼:guest,待會登入用到
四、下面執行
輸入剛剛的使用者名稱root和密碼root: