Dubbo 配置

Dubbo

  1. Zookeeper
  2. Dubbo-admin

dubbo 2.7.0

dubbo-admin 0.2.0

Zookeeper

install Zookeeper configuration center

1
docker pull zookeeper:3.5.6

运行 Zookeeper

1
docker run -d --name zookeeper-3.5.6 -p 2181:2181 zookeeper:3.5.6

测试

1
echo dump | nc 127.0.0.1 2181

Dubbo-admin

apache/dubbo-admin

1
docker pull apache/dubbo-admin:latest

运行

1
docker run -d --name dubbo-admin -p 8080:8080 --link zookeeper-3.5.6:zookeeper -e admin.registry.address=zookeeper://zookeeper:2181 -e admin.config-center=zookeeper://zookeeper:2181 -e admin.metadata-report.address=zookeeper://zookeeper:2181 dubbo-admin:latest

单独构建

Dockerfile

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
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM openjdk:8-jdk
RUN mkdir /source && wget https://github.com/apache/dubbo-admin/archive/0.2.0.zip && unzip 0.2.0.zip -d /source
WORKDIR /source/dubbo-admin-0.2.0
# 使用 settings.xml 的原因是要使用阿里的 maven 源。
ADD settings.xml /source/dubbo-admin-0.2.0
RUN ./mvnw clean package --settings settings.xml -Dmaven.test.skip=true

FROM openjdk:8-jre
LABEL maintainer="dev@dubbo.apache.org"
COPY --from=0 /source/dubbo-admin-0.2.0/dubbo-admin-distribution/target/dubbo-admin-0.2.0.jar /app.jar
ENTRYPOINT ["java","-XX:+UnlockExperimentalVMOptions","-XX:+UseCGroupMemoryLimitForHeap","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
EXPOSE 8080

settings.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
</settings>

构建

1
docker build -t dubbo-admin:0.2.0 .

运行

1
docker run -d --name dubbo-admin -p 8080:8080 --link zookeeper-3.5.6:zookeeper -e admin.registry.address=zookeeper://zookeeper:2181 -e admin.config-center=zookeeper://zookeeper:2181 -e admin.metadata-report.address=zookeeper://zookeeper:2181 dubbo-admin:0.2.0

访问

http://IP:8080 用户名:root,密码:root

运行 zookeeper 和 dubbo-admin

docker-compose.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
version: '3'

services:
zookeeper:
image: zookeeper:3.5.6
ports:
- 2181:2181
admin:
image: apache/dubbo-admin
depends_on:
- zookeeper
ports:
- 8080
environment:
- admin.registry.address=zookeeper://zookeeper:2181
- admin.config-center=zookeeper://zookeeper:2181
- admin.metadata-report.address=zookeeper://zookeeper:2181

Dubbo

安装 JDK

安装 Maven

下载示例

Dubbo 2.7.0

pom.xml 依赖可以更改一下

1
git clone https://github.com/apache/dubbo-samples.git
1
2
cd dubbo-samples/java
mvn clean package

Dubbo Provider

1
2
3
4
5
cd dubbo-samples-basic

mvn -Djava.net.preferIPv4Stack=true \
-Dexec.mainClass=org.apache.dubbo.samples.basic.BasicProvider \
exec:java

Dubbo Consumer

1
2
3
4
5
cd dubbo-samples-basic

mvn -Djava.net.preferIPv4Stack=true \
-Dexec.mainClass=org.apache.dubbo.samples.basic.BasicConsumer \
exec:java

参考

Docker多步构建生成dubbo-admin镜像

使用Docker容器化SpringBoot+Dubbo应用的实践

基于SpringBoot+Dubbo的微服务框架(借助Docker+Jenkins实现自动化、容器化部署)

Dubbo - Dubbo Admin 安装(生产版)

Dubbo - Dubbo Admin 安装(开发版-Dubbo OPS)

dubbo入门学习笔记之环境准备

dubbo提供者注册容器IP问题 | Vnimos’s blog

×

纯属好玩

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
  1. 1. Dubbo
    1. 1.1. Zookeeper
    2. 1.2. Dubbo-admin
      1. 1.2.1. 单独构建
    3. 1.3. 运行 zookeeper 和 dubbo-admin
    4. 1.4. Dubbo
      1. 1.4.1. Dubbo Provider
      2. 1.4.2. Dubbo Consumer
    5. 1.5. 参考
,