• dubbo 2.5.3 环境搭建


    安装Git, JDK 和 Maven

    1. 安装jdk, git

       yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel git
      
      • 1
    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
      
      • 1
      • 2
      • 3
      • 4
      • 5
    3. 添加环境变量

       echo >> /root/.bash_profile <
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
  • 生效环境变量

     . /root/.bash_profile
    
    • 1
  • 测试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)
    
    • 1
    • 2
    • 3
    • 4
  • 测试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"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
  • 编译dubbo

    1. 安装opensesame

       cd /usr/local/src/
       git clone https://github.com/alibaba/opensesame.git
       cd opensesame/
       mvn clean install -Dmaven.test.skip
      
      • 1
      • 2
      • 3
      • 4
    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/ ./
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
    3. 修改pom.xml

       
           hessian-lite   
           dubbo-common
           dubbo-container
           dubbo-remoting
           .........
       
      
       
           .........
           1.1.39   
           .........
       
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
    4. 修改 hessian-lite/pom.xml

       
           com.alibaba
           dubbo-parent
           2.5.3   
       
      
      • 1
      • 2
      • 3
      • 4
      • 5
    5. 修改 dubbo-admin/pom.xml

      webx的依赖改为3.1.6版;

       
           com.alibaba.citrus
           citrus-webx-all
           3.1.6
       
      
      • 1
      • 2
      • 3
      • 4
      • 5

      添加velocity的依赖

       
           org.apache.velocity
           velocity
           1.7
       
      
      • 1
      • 2
      • 3
      • 4
      • 5

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

       
           com.alibaba
           dubbo
           ${project.parent.version}
           
               
                   org.springframework
                   spring
               
           
       
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11

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

       
           
           
       
      
      • 1
      • 2
      • 3
      • 4
    6. 编译

       mvn clean install -Dmaven.test.skip
      
      • 1

    安装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
      
      • 1
      • 2
      • 3
      • 4
      • 5
    2. 修改配置

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

    启动 server 端

         bin/zkServer.sh start
    
    • 1

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

         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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
  • 安装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/
      
      • 1
      • 2

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

       /etc/init.d/tomcat6 restart
      
      • 1

      可以通过浏览器访问 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
    
    • 1
    • 2
    • 3

    修改 conf/dubbo.properties

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

    启动provider

    bin/start.sh
    
    • 1

    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
    
    • 1
    • 2
    • 3

    修改 conf/dubbo.properties

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

    启动consumer

    bin/start.sh
    
    • 1

    确认

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-FZk0oIzY-1660429613487)(http://upload-images.jianshu.io/upload_images/63380-413478522bdd9209?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

    consumer log

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

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Pwd2WHUX-1660429613487)(http://upload-images.jianshu.io/upload_images/63380-e7e29afcf5dea8d1?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

    dubbo-admin

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

    文/whyreal(简书作者)
    原文链接:http://www.jianshu.com/p/6541f277f467
    著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。

  • 相关阅读:
    软件开发工具的现状与发展
    web前端之uniApp实现选择时间功能
    【vue3源码】十一、初始vue3中的渲染器
    【SQL】实现读写分离的分配的方式
    简单的Linux服务器端代码
    使用EasyExcel后端导出excel
    一个敏感词检查功能是怎么来的
    Nacos与Eureka的异同
    【Linux】【操作】Linux环境运行Windows程序方式一览(全网最全)
    hdfs - balancer学习
  • 原文地址:https://blog.csdn.net/m0_54850467/article/details/126327708