dubbo 2.5.3 环境搭建

alibaba dubbo基本上已经停止更新了,新用户请使用当当维护的 dubbox, dubbox 在 dubbo 的基础上添加了对 restfull 的支持,升级了 spring。


dubbox 2.8.4 环境搭建

安装Git, JDK 和 Maven

  1. 安装jdk, git

     yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel git
    
  2. 安装maven

     cd /usr/local/src/
     wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
     tar -zxf apache-maven-3.3.9-bin.tar.gz
     mv apache-maven-3.3.9 /usr/local/
     ln -s /usr/local/apache-maven-3.3.9 /usr/local/apache-maven
    
  3. 添加环境变量

     echo >> /root/.bash_profile <
  4. 生效环境变量

     . /root/.bash_profile
    
  5. 测试java

     [root@openstack_test ~]# java -version
     openjdk version "1.8.0_101"
     OpenJDK Runtime Environment (build 1.8.0_101-b13)
     OpenJDK 64-Bit Server VM (build 25.101-b13, mixed mode)
    
  6. 测试maven

     [root@openstack_test ~]# mvn -version
     Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
     Maven home: /usr/local/apache-maven
     Java version: 1.8.0_101, vendor: Oracle Corporation
     Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.101-3.b13.el6_8.x86_64/jre
     Default locale: en_US, platform encoding: UTF-8
     OS name: "linux", version: "2.6.32-573.18.1.el6.x86_64", arch: "amd64", family: "unix"
    

编译dubbo

  1. 安装opensesame

     cd /usr/local/src/
     git clone https://github.com/alibaba/opensesame.git
     cd opensesame/
     mvn clean install -Dmaven.test.skip
    
  2. 获取dubbo源码

     cd /usr/local/src/
     git clone https://github.com/alibaba/dubbo.git dubbo
     cd /usr/local/src/dubbo
     cp -r hessian-lite/ ../
     git checkout dubbo-2.5.3
     cp -r ../hessian-lite/ ./
    
  3. 修改pom.xml

     
         hessian-lite   
         dubbo-common
         dubbo-container
         dubbo-remoting
         .........
     
    
     
         .........
         1.1.39   
         .........
     
    
  4. 修改 hessian-lite/pom.xml

     
         com.alibaba
         dubbo-parent
         2.5.3   
     
    
  5. 修改 dubbo-admin/pom.xml

    webx的依赖改为3.1.6版;

     
         com.alibaba.citrus
         citrus-webx-all
         3.1.6
     
    

    添加velocity的依赖

     
         org.apache.velocity
         velocity
         1.7
     
    

    对依赖项dubbo添加exclusion,避免引入旧spring

     
         com.alibaba
         dubbo
         ${project.parent.version}
         
             
                 org.springframework
                 spring
             
         
     
    

    webx已有spring 3以上的依赖,因此注释掉dubbo-admin里面的spring依赖

     
         
         
     
    
  6. 编译

     mvn clean install -Dmaven.test.skip
    

安装ZooKeeper

  1. 安装zookeeper

     cd /usr/local/src
     wget http://apache.fayea.com/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
     tar -zxf zookeeper-3.4.8.tar.gz
     cp -r zookeeper-3.4.8 /usr/local/
     ln -s /usr/local/zookeeper-3.4.8/ /usr/local/zookeeper
    
  2. 修改配置

     cd /usr/local/zookeeper/
     cp conf/zoo_sample.cfg conf/zoo.cfg
    
     echo > conf/zoo.cfg <
  3. 启动&测试

    启动 server 端

         bin/zkServer.sh start
    

    启动客户端,尝试创建、查询节点

         bin/zkCli.sh -server localhost:2181
    
    
         [zk: localhost:2181(CONNECTED) 3] create /test 1111
         Created /test
         [zk: localhost:2181(CONNECTED) 4] get /test
         1111
         cZxid = 0x2
         ctime = Thu Sep 01 08:59:24 CST 2016
         mZxid = 0x2
         mtime = Thu Sep 01 08:59:24 CST 2016
         pZxid = 0x2
         cversion = 0
         dataVersion = 0
         aclVersion = 0
         ephemeralOwner = 0x0
         dataLength = 4
         numChildren = 0
    

安装dubbo-admin

  1. 安装tomcat

    yum install tomcat6

  2. 部署 dubbo-admin 代码

     mkdir /var/lib/tomcat6/webapps/ROOT/
     unzip dubbo-admin/target/dubbo-admin-2.5.3.war -d /var/lib/tomcat6/webapps/ROOT/
    

    确认/var/lib/tomcat6/webapps/ROOT/WEB-INF/dubbo.properties 中ZooKeeper的地址是否正确。本例中,该配置无需修改。 然后就可以启动tomcat了。

     /etc/init.d/tomcat6 restart
    

    可以通过浏览器访问 dubbo-admin。

启动demon

provider

cd /usr/local/src/dubbo/dubbo-demo/dubbo-demo-provider/target/
tar -zxf dubbo-demo-provider-2.5.3-assembly.tar.gz
cd dubbo-demo-provider-2.5.3

修改 conf/dubbo.properties

#dubbo.registry.address=multicast://224.5.6.7:1234
dubbo.registry.address=zookeeper://127.0.0.1:2181

启动provider

bin/start.sh

consumer

cd /usr/local/src/dubbo/dubbo-demo/dubbo-demo-consumer/target/
tar -zxf dubbo-demo-consumer-2.5.3-assembly.tar.gz
cd dubbo-demo-consumer-2.5.3

修改 conf/dubbo.properties

#dubbo.registry.address=multicast://224.5.6.7:1234
dubbo.registry.address=zookeeper://127.0.0.1:2181

启动consumer

bin/start.sh

确认

dubbo 2.5.3 环境搭建_第1张图片
consumer log

在consumer的日志中可以看到provider的正常回应。

dubbo 2.5.3 环境搭建_第2张图片
dubbo-admin

在dubbo-admin的 服务治理>>服务 页面也可以看到consumer和provider注册的服务,说明服务正常启动。

你可能感兴趣的:(dubbo 2.5.3 环境搭建)