安装jdk, git
yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel git
安装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
添加环境变量
echo >> /root/.bash_profile <
生效环境变量
. /root/.bash_profile
测试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)
测试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"
安装opensesame
cd /usr/local/src/
git clone https://github.com/alibaba/opensesame.git
cd opensesame/
mvn clean install -Dmaven.test.skip
获取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/ ./
修改pom.xml
hessian-lite
dubbo-common
dubbo-container
dubbo-remoting
.........
.........
1.1.39
.........
修改 hessian-lite/pom.xml
com.alibaba
dubbo-parent
2.5.3
修改 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依赖
编译
mvn clean install -Dmaven.test.skip
安装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
修改配置
cd /usr/local/zookeeper/
cp conf/zoo_sample.cfg conf/zoo.cfg
echo > conf/zoo.cfg <
启动&测试
启动 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
安装tomcat
yum install tomcat6
部署 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。
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
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
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(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
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
。