dubbo-admin:
因为我们不能直观的看到dubbo和zk上到底有什么服务(提供者),所以我们需要一个可视化工具来方便我们管理每一个服务和每一个节点。
dubbo-admin 就是dubbo的管理控制台
需要的准备工作是你的Linux已经安装了
jdk
Zookeeper
tomcat
1、官网下载dubbo源码
https://github.com/alibaba/dubbo 或 https://github.com/apache/incubator-dubbo
2、编译dubbo-admin工程,打成war包 dubbo-admin-2.5.8.war
这里要安装 maven 并使用mvn 编译打包
3、进入 WEB-INF 目录修改文件 dubbo.properties 设置zookeeper 地址
dubbo.registry.address=zookeeper://127.0.0.1:2181
dubbo.admin.root.password=root
dubbo.admin.guest.password=guest
4、在tomcat 中部署dubbo-admin-2.5.8.war
5、用户密码都root/root
dubbo-Monitor:
dubbo-monitor-simple是dubbo提供的简单监控中心,可以用来显示接口暴露,注册情况,也可以看接口的调用明细,调用时间等。
- Simple Monitor挂掉不会影响到Consumer和Provider之间的调用,所以用于生产环境不会有风险。
- Simple Monitor采用磁盘存储统计信息,请注意安装机器的磁盘限制,如果要集群,建议用mount共享磁盘。
- charts目录必须放在jetty.directory下,否则页面上访问不了。
- 配置好了之后可以结合admin管理后台使用,可以清晰的看到服务的访问记录、成功次数、失败次数。
下面是官网的安装步骤
安装: git clone https://github.com/apache/incubator-dubbo-ops cd incubator-dubbo-ops && mvn package cd dubbo-monitor-simple/target && tar xvf dubbo-monitor-simple-2.0.0-assembly.tar.gz cd dubbo-monitor-simple-2.0.0 配置: vi conf/dubbo.properties 启动: ./assembly.bin/start.sh 停止: ./assembly.bin/stop.sh 重启: ./assembly.bin/restart.sh 调试: ./assembly.bin/start.sh debug 系统状态: ./assembly.bin/dump.sh 总控入口: ./assembly.bin/server.sh start ./assembly.bin/server.sh stop ./assembly.bin/server.sh restart ./assembly.bin/server.sh debug ./assembly.bin/server.sh dump 标准输出: tail -f logs/stdout.log 命令行 [1]: telnet 127.0.0.1 7070 help 或者: echo status | nc -i 1 127.0.0.1 7070 访问: http://127.0.0.1:8080
我的安装步骤
1. 下载源码(托管在github上) ~]# wget https://github.com/alibaba/dubbo/archive/dubbo-2.6.0.zip ~]# unzip dubbo-2.6.0.zip ~]# cd dubbo-dubbo-2.6.0/ 2. 安装依赖 ~]# yum -y install java-1.8.0-openjdk maven maven: 用于编译dubbo-simple-monitor jdk: dubbo-simple-monitor是java语言所写,故需要jdk 3. 编译dubbo-simple-monitor dubbo-dubbo-2.6.0]# cd dubbo-simple/dubbo-monitor-simple/ dubbo-monitor-simple]# mvn clean install
编译成功后的目标文件为:target/dubbo-monitor-simple-2.6.0-assembly.tar.gz
进入target文件夹
可以直接下载我编译好的包
4. 修改配置文件 我们使用dubbo-monitor-simple-2.6.0-assembly.tar.gz启动程序,因为还有一些配置需要修改 target]# tar xf dubbo-monitor-simple-2.6.0-assemble.tar.gz -C /usr/local target]# cd /usr/local local]# vim dubbo-monitor-simple-2.6.0/conf/dubbo.properties # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. dubbo.container=log4j,spring,registry,jetty dubbo.application.name=simple-monitor dubbo.application.owner= #dubbo.registry.address=multicast://224.5.6.7:1234 dubbo.registry.address=zookeeper://127.0.0.1:2181 zookeeper的地址 #dubbo.registry.address=redis://127.0.0.1:6379 #dubbo.registry.address=dubbo://127.0.0.1:9090 dubbo.protocol.port=7070 dubbo.jetty.port=8080 服务启动后访问的端口(修改一下,不要和tomcat冲突) dubbo.jetty.directory=/data/monitor dubbo.charts.directory=${dubbo.jetty.directory}/charts dubbo.statistics.directory=/data/monitor/statistics dubbo.log4j.file=logs/dubbo-monitor-simple.log dubbo.log4j.level=WARN
5. 启动服务 dubbo-monitor-simple-2.6.0]# bin/start.sh
报错:
2018-07-06 16:18:37,135 [main] WARN com.alibaba.dubbo.config.ServiceConfig (ServiceConfig.java:568) - [DUBBO] lvs: lvs: Temporary failure in name resolution, dubbo version: 2.6.0, current host: 127.0.0.1 java.net.UnknownHostException: lvs: lvs: Temporary failure in name resolution at java.net.InetAddress.getLocalHost(InetAddress.java:1505) at com.alibaba.dubbo.config.ServiceConfig.findConfigedHosts(ServiceConfig.java:566) at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:469) at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:357) at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:316) at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:215) at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:121) at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:50)
解决:修改hosts文件,把服务器名称 lvs 和 127.0.0.1 地址做一下 映射就好了
# vi /etc/hosts 加入 127.0.0.1 lvs
出现的错误
1.
# ./start.sh ./start.sh: line 30: netstat: command not found Starting the simple-monitor ...../start.sh: line 79: netstat: command not found ../start.sh: line 79: netstat: command not found
提示找不到netstat命令,centos7 默认不使用这个命令了。
我们安装一下network工具包,就可以使用这个命令了
# yum install net-tools
2.
访问时无法看到图
解决
- dubbo-simple-monitor配置文件中dubbo.jetty.directory中指明的目录需要手动创建
- 我们需要监控的服务在配置dubbo时要加入<dubbo:monitor protocol="registry"/>这项配置
Maven:
1.保证该项目安装了JDK
请在系统中输入java -version查看该命令是否存在
不存在请首先安装
2、下载maven安装包
官网地址 http://maven.apache.org/download.cgi
3、解压缩maven
#tar -zxvf apache-maven-3.5.4-bin.tar.gz
4.配置maven的环境变量
#vim
/etc/profile
在最后面加入export
MAVEN_HOME=
/root/dev/apache-maven-3
.5.4
export
PATH=$PATH:$MAVEN_HOME
/bin
使文件生效#source
/etc/profile
5.测试maven是否安装成功
#mvn -version
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T02:33:14+08:00) Maven home: /usr/local/apache-maven-3.5.4 Java version: 1.8.0_161, vendor: Oracle Corporation, runtime: /usr/java/jdk1.8.0_161/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-327.el7.x86_64", arch: "amd64", family: "unix"