Dubbo 部署

zookeeper 安装

下载 zookeeper 安装包:

wget http://apache.fayea.com/zookeeper/current/zookeeper-3.4.6.tar.gz

解压到 zookeeper 目录下,拷贝 zoo_sample.cfg 并重命名为 zoo.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=~/zookeeper/data

dataLogDir=~/zookeeper/log

# the port at which the clients will connect

clientPort=2181

启动 zookeeper 服务:

./bin/zkServer.sh start

dubbo-admin 部署

由于dubbo-admin 2.5.3版本有bug,注册中心为zookeeper时,管理控制台删除路由会失败,git上已经解决该问题,所以我们从git上下载最新的dubbo源码,重新打包dubbo-admin。

dubbo git地址:https://github.com/alibaba/dubbo

1、下载opensesame,并安装到本地仓库(dubbo引用该pom文件,否则编译dubbo通不过)

git clone https://github.com/alibaba/opensesame

mvn install

2、下载dubbo master,用maven在最外层目录编译即可将所有项目全部编译

git clone https://github.com/alibaba/dubbo

cd dubbo

export MAVEN_OPTS="-Xms512m -Xmx1024m"

mvn clean install -Dmaven.test.skip

注:想要将dubbo源码导入到eclipse,需要执行 mvn eclipse:eclipse

3、编译通过后可以获取到dubbo-admin-2.5.4-SNAPSHOT.war,部署到tomcat即可

启动tomcat,访问127.0.0.1:8080,输入账号密码(默认为root)就可以访问dubbo管理中心了。

注意修改WEB-INF/dubbo.properties中的配置(配置的地址端口必须和zookeeper的服务地址端口一致):

dubbo.registry.address=zookeeper://127.0.0.1:2181

dubbo-monitor 部署

由于dubbo所有项目已编译完成,所以能在dubbo-monitor-simple项目的target目录下找到编译好的dubbo-monitor-simple-2.5.4-SNAPSHOT-assembly.tar.gz包,

将该包解压到指定文件夹,打开配置文件,将端口号修改为未占用的端口:

dubbo.protocol.port=29000

dubbo.jetty.port=28000

启动 start.sh,浏览器输入127.0.0.1:28000即可访问。

注: 由于simple-monitor也是作为dubbo服务提供的,所以需要在monitor监控的服务中添加dubbo.monitor.protocol=registry,这样需要监控的服务作为消费者会向simple-monitor这个服务提供者发送统计数据。

补充

1、dubbo-admin jdk1.8启动报错

解决方法:dubbo-admin jdk8启动问题

其实,不只是 dubbo-admin,其他 dubbo 项目也可能出现该问题,主要原因是源码编译时的 jdk 版本和运行时的jdk版本不一致造成的,两者保持一致则不会出现该问题。

2、dubbo 源码导入 eclipse,提示找不到 dubbo.xsd

使用 dubbo 时 xml 提示以下错误:

org.xml.sax.SAXParseException: schema_reference.4:

Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd',

because :

1) could not find the document;

2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

解决方法:eclispe–>window–>preferences–>xml catalog–>add 注意 KEY 需要以 /dubbo.xsd 结尾,如下图所示

Dubbo 部署

以上是 Dubbo 部署 的全部内容, 来源链接: utcz.com/p/233171.html

回到顶部