dubbo

本文涉及的产品
云原生网关 MSE Higress,422元/月
注册配置 MSE Nacos/ZooKeeper,118元/月
服务治理 MSE Sentinel/OpenSergo,Agent数量 不受限
简介:

安装tomcat

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
root@kickseed:~ # cd /root/work/soft_dir/
root@kickseed:~ /work/soft_dir # wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz
root@kickseed:~ /work/soft_dir # ls
apache-maven-3.5.0-bin. tar .gz  apache-tomcat-8.5.20. tar .gz  jdk-8u77-linux-x64. tar .gz
root@kickseed:~ /work/soft_dir # mkdir -p /root/work/app_dir/tomcat
root@kickseed:~ /work/soft_dir # tar xf apache-tomcat-8.5.20.tar.gz -C /root/work/app_dir/tomcat
root@kickseed:~ /work/soft_dir # ln -sv /root/work/app_dir/tomcat/apache-tomcat-8.5.20/ /root/work/app_dir/tomcat/current
/root/work/app_dir/tomcat/current ’ -> ‘ /root/work/app_dir/tomcat/apache-tomcat-8 .5.20/’
root@kickseed:~ /work/soft_dir # ll /root/work/app_dir/tomcat/
total 12
drwxr-xr-x 3 root root 4096 Sep  5 20:31 ./
drwxr-xr-x 5 root root 4096 Sep  5 20:29 ../
drwxr-xr-x 9 root root 4096 Sep  5 20:28 apache-tomcat-8.5.20/
lrwxrwxrwx 1 root root   47 Sep  5 20:31 current ->  /root/work/app_dir/tomcat/apache-tomcat-8 .5.20 //
root@kickseed:~ /work/soft_dir # cd /root/work/app_dir/tomcat/current
root@kickseed:~ /work/app_dir/tomcat/current # pwd
/root/work/app_dir/tomcat/current
root@kickseed:~ /work/app_dir/tomcat/current # vim /etc/profile.d/tomcat.sh
root@kickseed:~ /work/app_dir/tomcat/current # cat /etc/profile.d/tomcat.sh
export  CATALINA_HOME= /root/work/app_dir/tomcat/current
export  PATH=$CATALINA_HOME /bin :$PATH
root@kickseed:~ /work/app_dir/tomcat/current # . /etc/profile.d/tomcat.sh
root@kickseed:~ /work/app_dir/tomcat/current # catalina.sh version
Using CATALINA_BASE:    /root/work/app_dir/tomcat/current
Using CATALINA_HOME:    /root/work/app_dir/tomcat/current
Using CATALINA_TMPDIR:  /root/work/app_dir/tomcat/current/temp
Using JRE_HOME:         /root/work/app_dir/jdk/current
Using CLASSPATH:        /root/work/app_dir/tomcat/current/bin/bootstrap .jar: /root/work/app_dir/tomcat/current/bin/tomcat-juli .jar
Server version: Apache Tomcat /8 .5.20
Server built:   Aug 2 2017 21:35:49 UTC
Server number:  8.5.20.0
OS Name:        Linux
OS Version:     4.4.0-31-generic
Architecture:   amd64
JVM Version:    1.8.0_77-b03
JVM Vendor:     Oracle Corporation
root@kickseed:~ /work/app_dir/tomcat/current #


建立应用目录

1
2
3
4
5
6
7
8
9
root@kickseed:~ /work/app_dir/tomcat/current # cd /root/work/
root@kickseed:~ /work # cd app_dir/
root@kickseed:~ /work/app_dir # ls
jdk  maven  tomcat
root@kickseed:~ /work/app_dir # mkdir deploy_tomcat
root@kickseed:~ /work/app_dir # mkdir learn_app
root@kickseed:~ /work/app_dir # ls
deploy_tomcat  jdk  learn_app  maven  tomcat
root@kickseed:~ /work/app_dir # cd learn_app/


dubbo-interfac目录结构

1
2
3
4
5
6
7
8
9
10
11
12
13
root@kickseed:~ /work/app_dir/learn_app/dubbo-interface # tree
.
├── pom.xml
└── src
     └── main
         ├── java
         │   └── com
         │       └── kingdz
         │           └── dubbo
         │               └── HelloWorld.java
         └── resources
 
7 directories, 2 files


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
root@kickseed:~ /work/app_dir/learn_app/dubbo-interface # mvn clean install
 
 
 
root@kickseed:~ /work/app_dir/learn_app/dubbo-interface # cd ../
root@kickseed:~ /work/app_dir/learn_app # ls
dubbo-consumer  dubbo-interface  dubbo-provider
root@kickseed:~ /work/app_dir/learn_app # cd dubbo-provider/
 
root@kickseed:~ /work/app_dir/learn_app/dubbo-provider # tree
.
├── pom.xml
└── src
     └── main
         ├── java
         │   ├── com
         │   │   └── kingdz
         │   │       └── dubbo
         │   │           └── impl
         │   │               └── HelloWorldImpl.java
         │   └── com.kingdz.dubbo.impl
         ├── resources
         │   ├── applicationContext.xml
         │   └── log4j.properties
         └── webapp
             ├── index.jsp
             └── WEB-INF
                 └── web.xml
 
11 directories, 6 files
 
root@kickseed:~ /work/app_dir/learn_app/dubbo-consumer # mvn clean install
 
 
 
 
root@kickseed:~ /work/app_dir/learn_app/dubbo-provider # cd ../dubbo-consumer/
 
root@kickseed:~ /work/app_dir/learn_app/dubbo-consumer # tree
.
├── pom.xml
└── src
     └── main
         ├── java
         │   └── com
         │       └── kingdz
         │           └── dubbo
         │               └── controller
         │                   └── HelloWorldController.java
         ├── resources
         │   ├── applicationContext.xml
         │   ├── log4j.properties
         │   └── spring-mvc.xml
         └── webapp
             ├── index.jsp
             └── WEB-INF
                 └── web.xml
 
10 directories, 7 files
 
 
root@kickseed:~ /work/app_dir/learn_app/dubbo-consumer # mvn clean install


1
2
3
http: //www .apache.org /dyn/closer .cgi /zookeeper/   下载地址zookeeper
http: //mirror .bit.edu.cn /apache/zookeeper/
http: //mirror .bit.edu.cn /apache/zookeeper/zookeeper-3 .4.6 /zookeeper-3 .4.6. tar .gz


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
root@kickseed:~ # cd /root/work/soft_dir/
root@kickseed:~ /work/soft_dir # wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
root@kickseed:~ /work/soft_dir # ls
apache-maven-3.5.0-bin. tar .gz  apache-tomcat-8.5.20. tar .gz  jdk-8u77-linux-x64. tar .gz  zookeeper-3.4.6. tar .gz
root@kickseed:~ /work/soft_dir # mkdir -p /root/work/app_dir/zookeeper
root@kickseed:~ /work/soft_dir # tar xf zookeeper-3.4.6.tar.gz -C /root/work/app_dir/zookeeper/
root@kickseed:~ /work/soft_dir # ls /root/work/app_dir/zookeeper/
zookeeper-3.4.6
root@kickseed:~ /work/soft_dir # cd /root/work/app_dir/zookeeper/
root@kickseed:~ /work/app_dir/zookeeper # ln -sv /root/work/app_dir/zookeeper/zookeeper-3.4.6/ /root/work/app_dir/zookeeper/current
/root/work/app_dir/zookeeper/current ’ -> ‘ /root/work/app_dir/zookeeper/zookeeper-3 .4.6/’
 
root@kickseed:~ /work/app_dir/zookeeper # ls
current  zookeeper-3.4.6
root@kickseed:~ /work/app_dir/zookeeper # cd current
root@kickseed:~ /work/app_dir/zookeeper/current # cp conf/zoo_sample.cfg conf/zoo.cfg
root@kickseed:~ /work/app_dir/zookeeper/current # vim conf/zoo.cfg
修改添加下面两行
dataDir= /root/work/app_dir/zookeeper/data
dataLogDir= /root/work/app_dir/zookeeper/datalog
 
root@kickseed:~ /work/app_dir/zookeeper/current # mkdir -pv /root/work/app_dir/zookeeper/{data,datalog}
mkdir : created directory ‘ /root/work/app_dir/zookeeper/data
mkdir : created directory ‘ /root/work/app_dir/zookeeper/datalog
 
 
root@kickseed:~ /work/app_dir/zookeeper/current # ss -tnl
State       Recv-Q Send-Q                            Local Address:Port                              Peer Address:Port
LISTEN      0      128                                           *:22                                           *:*
LISTEN      0      50                                            *:3306                                         *:*
LISTEN      0      128                                          :::22                                          :::*
root@kickseed:~ /work/app_dir/zookeeper/current # bin/zkServer.sh start
JMX enabled by default
Using config:  /root/work/app_dir/zookeeper/current/bin/ .. /conf/zoo .cfg
Starting zookeeper ... STARTED
root@kickseed:~ /work/app_dir/zookeeper/current # ss -tnl
State       Recv-Q Send-Q                            Local Address:Port                              Peer Address:Port
LISTEN      0      128                                           *:22                                           *:*
LISTEN      0      50                                            *:3306                                         *:*
LISTEN      0      128                                          :::22                                          :::*
LISTEN      0      50                                           :::44378                                       :::*
LISTEN      0      50                                           :::2181


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
root@kickseed:~ /work/app_dir/learn_app # ls
dubbo-consumer  dubbo-interface  dubbo-provider
root@kickseed:~ /work/app_dir/learn_app # git clone https://github.com/alibaba/dubbo.git
root@kickseed:~ /work/app_dir/learn_app # ls
dubbo  dubbo-consumer  dubbo-interface  dubbo-provider
root@kickseed:~ /work/app_dir/learn_app # cd dubbo
root@kickseed:~ /work/app_dir/learn_app/dubbo # ls
codestyle    dubbo-cluster  dubbo-container  dubbo-maven     dubbo-remoting  dubbo- test     NOTICE
dubbo        dubbo-common   dubbo-demo       dubbo-monitor   dubbo-rpc       hessian-lite  pom.xml
dubbo-admin  dubbo-config   dubbo-filter     dubbo-registry  dubbo-simple    LICENSE       README.md
root@kickseed:~ /work/app_dir/learn_app/dubbo # mvn clean install -Dmaven.test.skip=true
 
root@kickseed:~ /work/app_dir/learn_app/dubbo # cd dubbo-admin/
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # ls target/
classes  dubbo-admin-2.5.4-SNAPSHOT  dubbo-admin-2.5.4-SNAPSHOT.war  generated-sources  maven-archiver  maven-status
 
 
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # ls /root/work/app_dir/
deploy_tomcat/ jdk/           learn_app/     maven/         tomcat/
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # ls /root/work/app_dir/deploy_tomcat/
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # cp -rf /root/work/app_dir/tomcat/apache-tomcat-8.5.20/ /root/work/app_dir/deploy_tomcat/app_name
 
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # ls /root/work/app_dir/deploy_tomcat/app_name/
bin  conf  lib  LICENSE  logs  NOTICE  RELEASE-NOTES  RUNNING.txt  temp  webapps  work
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # rm -rf /root/work/app_dir/deploy_tomcat/app_name/bin/*
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # rm -rf /root/work/app_dir/deploy_tomcat/app_name/lib
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # ls /root/work/app_dir/deploy_tomcat/app_name/
conf  LICENSE  logs  NOTICE  RELEASE-NOTES  RUNNING.txt  temp  webapps  work
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # rm -f /root/work/app_dir/deploy_tomcat/app_name/LICENSE
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # rm -f /root/work/app_dir/deploy_tomcat/app_name/NOTICE
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # rm -f /root/work/app_dir/deploy_tomcat/app_name/RELEASE-NOTES
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # rm -f /root/work/app_dir/deploy_tomcat/app_name/RUNNING.txt
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # ls /root/work/app_dir/deploy_tomcat/app_name/
bin  conf  logs  temp  webapps  work
 
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # cat /root/work/app_dir/deploy_tomcat/app_name/bin/appctl.sh
#!/bin/bash
 
export  CATALINA_BASE=$( cd  $( dirname  $0); cd  ../; pwd )
 
echo  $CATALINA_BASE
case  $1  in
     start)
         catalina.sh start
         ;;
     stop)
         catalina.sh stop
         ;;
     restart)
         catalina.sh stop
         catalina.sh start
         ;;
     *)
         exit  1
         ;;
esac
 
 
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # cat target/dubbo-admin-2.5.4-SNAPSHOT/WEB-INF/dubbo.properties
dubbo.registry.address=zookeeper: //127 .0.0.1:2181
dubbo.admin.root.password=root
dubbo.admin.guest.password=guest
 
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # cp -rf /root/work/app_dir/deploy_tomcat/app_name/ /root/work/app_dir/deploy_tomcat/dubbo-admin
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # cp target/dubbo-admin-2.5.4-SNAPSHOT.war /root/work/app_dir/deploy_tomcat/dubbo-admin/webapps/
 
root@kickseed:~ /work/app_dir/learn_app/dubbo/dubbo-admin # cd /root/work/app_dir/deploy_tomcat/dubbo-admin
root@kickseed:~ /work/app_dir/deploy_tomcat/dubbo-admin # bin/appctl.sh start
/root/work/app_dir/deploy_tomcat/dubbo-admin
Using CATALINA_BASE:    /root/work/app_dir/deploy_tomcat/dubbo-admin
Using CATALINA_HOME:    /root/work/app_dir/tomcat/current
Using CATALINA_TMPDIR:  /root/work/app_dir/deploy_tomcat/dubbo-admin/temp
Using JRE_HOME:         /root/work/app_dir/jdk/current
Using CLASSPATH:        /root/work/app_dir/tomcat/current/bin/bootstrap .jar: /root/work/app_dir/tomcat/current/bin/tomcat-juli .jar
Tomcat started.
root@kickseed:~ /work/app_dir/deploy_tomcat/dubbo-admin # ss -tnl
State       Recv-Q Send-Q                            Local Address:Port                              Peer Address:Port
LISTEN      0      128                                           *:22                                           *:*
LISTEN      0      50                                            *:3306                                         *:*
LISTEN      0      128                                          :::22                                          :::*
LISTEN      0      50                                           :::44378                                       :::*
LISTEN      0      50                                           :::2181                                        :::*
LISTEN      0      100                                          :::8009                                        :::*
LISTEN      0      100                                          :::8080                                        :::*
 
 
root@kickseed:~ /work/app_dir/deploy_tomcat/dubbo-provider # sed -n 's#\(<Connector.*\)8009\(.*protocol.*$\)#\19009\2#gp' conf/server.xml
     <Connector port= "9009"  protocol= "AJP/1.3"  redirectPort= "8443"  />
 
root@kickseed:~ /work/app_dir/deploy_tomcat/dubbo-provider # sed -n 's#\(<Server.*\)8005\(.*SHUTDOWN.*$\)#\19005\2#gp' conf/server.xml
<Server port= "9005"  shutdown = "SHUTDOWN" >
 
root@kickseed:~ /work/app_dir/deploy_tomcat/dubbo-provider # sed -n 's#\(<Connector.*\)8080\(.*protocol.*$\)#\19080\2#gp' conf/server.xml
     <Connector port= "9080"  protocol= "HTTP/1.1"
 
root@kickseed:~ /work/app_dir/deploy_tomcat/dubbo-provider # sed -i 's#\(<Connector.*\)8009\(.*protocol.*$\)#\19009\2#g' conf/server.xml
root@kickseed:~ /work/app_dir/deploy_tomcat/dubbo-provider # sed -i 's#\(<Server.*\)8005\(.*SHUTDOWN.*$\)#\19005\2#g' conf/server.xml
root@kickseed:~ /work/app_dir/deploy_tomcat/dubbo-provider # sed -i 's#\(<Connector.*\)8080\(.*protocol.*$\)#\19080\2#g' conf/server.xml
 
root@kickseed:~ /work/app_dir/deploy_tomcat/dubbo-provider # grep -E '9005|9009|9080' conf/server.xml
<Server port= "9005"  shutdown = "SHUTDOWN" >
     <Connector port= "9080"  protocol= "HTTP/1.1"
     <Connector port= "9009"  protocol= "AJP/1.3"  redirectPort= "8443"  />




本文转自 f_066 51CTO博客,原文链接:http://blog.51cto.com/ganmu/1963214,如需转载请自行联系原作者

相关实践学习
基于MSE实现微服务的全链路灰度
通过本场景的实验操作,您将了解并实现在线业务的微服务全链路灰度能力。
相关文章
|
负载均衡 Dubbo Java
Dubbo总结必知必会
Dubbo总结必知必会
141 0
|
7月前
|
Dubbo Java 应用服务中间件
3.Dubbo
3.Dubbo
42 1
|
缓存 负载均衡 监控
1. 介绍一下 Dubbo?
1. 介绍一下 Dubbo?
78 0
|
7月前
|
监控 Dubbo Java
深入理解Dubbo-1.初识Dubbo
深入理解Dubbo-1.初识Dubbo
81 0
|
7月前
|
负载均衡 Dubbo 架构师
dubbo(2.7.3) 2.需求
dubbo(2.7.3) 2.需求
|
7月前
|
Dubbo Java 应用服务中间件
dubbo(2.7.3) 5.快速开始
dubbo(2.7.3) 5.快速开始
|
负载均衡 Dubbo Java
Dubbo介绍
Dubbo介绍
133 0
|
监控 负载均衡 Dubbo
Dubbo
Dubbo
249 0
|
监控 Dubbo Java
|
存储 Dubbo 应用服务中间件
使用Dubbo的RpcContext居然那么多坑
使用Dubbo的RpcContext居然那么多坑
2351 0
使用Dubbo的RpcContext居然那么多坑