因為有用到 dubbo 這個分布式服務框架,所以去網上看了一些教程。
教程地址,自己一步步跟着做,但是搭建 zookeeper+dubbo-admin 的時候犯了好多錯誤,特地分享一下。
搭建
- zookeeper 搭建
我用的是 zookeeper 3.4.6 版本的。下載下來解壓,把 conf 文件夾下的 zoo_sample.cfg 文件重命名為 zoo.cfg,然后修改文件為
# The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/usr/local/zookeeper-3.4.6/data/ dataLogDir=/usr/local/zookeeper-3.4.6/logs/ # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1
其中 data 和 logs 是自己新建的文件夾.
啟動:cd 到 zookeeper 文件夾下,然后./bin/zkServer.sh start 就啟動了,檢驗啟動成功與否,輸入命令 jps,出現622 QuorumPeerMain
字樣就是說明成功了。
- dubbo-admin 打包
我自己操作的錯誤都發生在這里,問題就是 war 不對。
- 網上有很多正確的 war 可以下載
- 自己去官網下載 dubbo 的源文件,然后自己打包
我啟動 zookeeper 之后,再啟動 tomcat,發生了很多不一的錯誤,具體錯誤信息,我沒記錄下來,也不准備提,歸結於 war 包不對,主要是兩種方式不對
- mvn install -Dmaven.test.skip=true 這命令的位置不對。正確應該是
dubbo-master
文件夾下打包,這樣就不會缺少依賴,而不是去dubbo-master/dubbo-admin
下面打包。 - jdk 版本,我的 Mac 是裝了兩個,1.7 和 1.8,但是我默認是 1.8,導致不對。我切換到 1.7 后就 OK 了。
作者:binbinyouli
鏈接:https://hacpai.com/article/1501899075701
來源:黑客派
協議:CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0/