Dubbo应用可观测性升级指南与踩坑记录

news2024/9/20 20:29:27

应用从dubbo-3.1.*升级到dubbo-*:3.2.*最新稳定版本,提升应用的可观测性和度量数据准确性

1. dubbo版本发布说明(可不关注)

dubbo版本发布

https://github.com/apache/dubbo/releases

  • 【升级兼容性】3.1 升级到 3.2

dubbo-3.2.0

2. 应用修改点

应用一般只需要升级dubbo-spring-boot-starter版本到3.2.10,相关组件版本检查是否一致

要求

  • dubbo-spring-boot-starter版本3.2.10dubbo系列版本一样 (xxx-spring-boot-starter引入,项目里可不单独引用)
  • 【依赖可选】netty系列版本4.1.101.Final
  • 【依赖可选】fastjson2 版本2.0.46 (全部统一使用hessian2参数序列化方式)
  • 【依赖可选】protobuf-java版本3.24.2
  • 【依赖可选】t-digest版本3.3
  • 检查jar包dubbo-spring-boot-observability-starterspring-boot-starter-actuator是否存在。

版本检查
通过Maven依赖树命令分析mvn dependency:tree > dependency-tree.txt
IDEA,通过Maven依赖分析功能,关键词搜索

Maven依赖分析

2.1 jar包升级

pom.xml依赖声明

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.16</version>
    <relativePath/>
</parent>

<properties>
    <dubbo.version>3.2.10</dubbo.version>
    <netty.version>4.1.101.Final</netty.version>
    <micrometer.version>1.12.0</micrometer.version>
    <prometheus-client.version>0.16.0</prometheus-client.version>
    <prometheus-pushgateway.version>0.16.0</prometheus-pushgateway.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>${dubbo.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

pom.xml依赖

<dependencies>
    <dependency>
        <groupId>org.apache.dubbo</groupId>
        <artifactId>dubbo-spring-boot-starter</artifactId>
    </dependency>
</dependencies>
  • 【版本检查】fastjson2版本升级到2.0.46

fastjson不太稳定,问题较多,风险较大。

参数序列化方式,建议保持不变。

全部统一使用hessian2参数序列化方式

2.2 属性配置

application.properties

management.server.port=18180
#management.server.base-path=
management.server.servlet.context-path=
management.endpoints.web.base-path=/
management.endpoints.web.exposure.include=prometheus
management.endpoints.web.exposure.exclude=metrics
management.endpoints.web.path-mapping.prometheus=metrics
management.metrics.export.prometheus.descriptions=false
management.metrics.tags.application=${spring.application.name}

# 消费者从提供者同步地址信息等元数据
dubbo.application.metadata-service-protocol=dubbo
dubbo.application.qos-port=22222
dubbo.metrics.protocol=prometheus
dubbo.metrics.enable-jvm=true
dubbo.metrics.enable-threadpool=true
dubbo.metrics.enable-registry=false
dubbo.metrics.enable-metadata=false
dubbo.metrics.export-metrics-service=false
dubbo.metrics.use-global-registry=true
dubbo.metrics.enable-rpc=true
dubbo.metrics.aggregation.enabled=true
dubbo.metrics.aggregation.enable-qps=true
dubbo.metrics.aggregation.enable-rt-pxx=true
dubbo.metrics.aggregation.enable-rt=true
dubbo.metrics.aggregation.enable-request=true
dubbo.metrics.histogram.enabled=true

【配置可选】Apollo统一的基础配置(集成外部配置数据源-配置中心)

建议使用Nacos

apollo-client依赖检查

apollo.bootstrap.enabled=true
apollo.bootstrap.namespaces=*,common-middleware-dubbo-metrics

2.3 类检查机制设置【升级必须设置】

若不设置,泛化调用可能会失败。

4-21 - 检测到不安全的序列化数据

出参入参对象可能有些未实现Serializable序列化接口,引起调用异常。

解法详见【官方文档】类检查机制

【解法】AutoConfiguration-自动配置

ApplicationConfig applicationConfig = new ApplicationConfig();
// 类检查机制
applicationConfig.setSerializeCheckStatus("DISABLE");
applicationConfig.setCheckSerializable(false);

【解法】属性文件

# 类检查机制
dubbo.application.serialize-check-status=DISABLE
dubbo.application.check-serializable=false

2.5 live存活探针日志-建议屏蔽

Kubernetes通过存活探针(liveness probe)检查容器是否还在运行,每隔2s探测一次,打印不少日志,建议屏蔽。

logback-k8s.xmllogback-spring.xml配置文件

<!-- k8s liveness probe qos日志很多,不打印 -->
<logger name="org.apache.dubbo.qos.command" level="warn" additivity="false"/>
logging.level.org.apache.dubbo.qos.command=warn

3. 踩过的坑

应用升级Dubbo3问题记录

3.1 检查系统最终组件版本

  • dubbo-boot-starter-*系列版本3.2.10 (xxx-spring-boot-starter引入,项目里可不单独引用)
  • fastjson2版本2.0.46 (全部统一使用hessian2参数序列化方式)
  • netty版本4.1.101.Final
  • protobuf-java版本3.24.2
  • t-digest版本3.3
  • 检查jar包dubbo-spring-boot-observability-starterspring-boot-starter-actuator是否存在。
  • micrometer系列组件版本是否一样
  • prometheussimpleclient系列组件版本是否一样

3.2 MetadataService报NPE异常

原因是提供者DubboAccessLogFilter抛出NPE异常,引起消费者获取应用地址等元数据信息失败。

dubbo过滤器加载机制调整

在Filter中调用RpcContext.getServiceContext().isConsumerSide()方法报空指针错误 · Issue #11716 · apache/dubbo

2024-01-23 11:51:14,075 [Dubbo-framework-metadata-retry-thread-1] ERROR org.apache.dubbo.registry.client.metadata.MetadataUtils -  [DUBBO] Failed to get app metadata for revision 6dd35818cdc09f4b682f8ac3fe312847 for type local from instance 192.168.108.31:8504, dubbo version: 3.2.10, current host: 192.168.104.218, error code: 1-39. This may be caused by , go to https://dubbo.apache.org/faq/1/39 to find instructions. 
org.apache.dubbo.rpc.RpcException: Failed to invoke remote method: getMetadataInfo, provider: dubbo://192.168.108.31:8502/org.apache.dubbo.metadata.MetadataService?connections=1&corethreads=2&dubbo=2.0.2&group=member&port=8502&prefer.serialization=hessian2&protocol=dubbo&release=3.2.10&retries=0&side=consumer&threadpool=cached&threads=100&timeout=3000&version=1.0.0, cause: org.apache.dubbo.remoting.RemotingException: java.lang.NullPointerException
java.lang.NullPointerException
    at com.xxx.member.config.DubboAccessLogFilter.invoke$original$xDfvMLE5(DubboAccessLogFilter.java:44)

【解法】对于@Activate自动激活的过滤器,不能再显示配置Filter

@Activate(group = CommonConstants.PROVIDER, order = 1)
public class DubboAccessLogFilter implements Filter {
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        // ...
        RpcContextAttachment rpcContext = RpcContext.getServerAttachment();
        // ...
    }
}

3.3 netty版本冲突

netty版本要和dubbo依赖的版本一样或兼容

<properties>
    <netty.version>4.1.101.Final</netty.version>
    <micrometer.version>1.12.0</micrometer.version>
    <prometheus-client.version>0.16.0</prometheus-client.version>
    <prometheus-pushgateway.version>0.16.0</prometheus-pushgateway.version>
</properties>
java.lang.NoSuchMethodError: io.netty.handler.codec.http2.Http2FrameCodecBuilder: method <init>()V not found
        at org.apache.dubbo.rpc.protocol.tri.TripleHttp2FrameCodecBuilder.<init>(TripleHttp2FrameCodecBuilder.java:32)
        at org.apache.dubbo.rpc.protocol.tri.TripleHttp2FrameCodecBuilder.fromConnection(TripleHttp2FrameCodecBuilder.java:37)

3.4 p95指标计算冲突

t-digest要高于3.3elasticsearch里引入了低版本。

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>5.3.3</version>
            <exclusions>
                <exclusion>
                    <groupId>com.tdunning</groupId>
                    <artifactId>t-digest</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
</dependencyManagement>

3.5 参数对象未实现Serializable序列化接口

4-21 - 检测到不安全的序列化数据

3.1 升级至 3.2

序列化协议升级

请求从消费者应用调用具体服务方法时,可能参数值为空,报如下异常。

Serialized class com.xxx.perform.request.XxxRequest is not in allow list. Current mode is `STRICT`, will disallow to deserialize it by default. Please add it into security/serialize.allowlist or follow FAQ to configure it., dubbo version: 3.2.5, current host: 192.168.108.111, error code: 4-21. This may be caused by , go to https://dubbo.apache.org/faq/4/21 to find instructions

解法详见【官方文档】类检查机制

【解法】AutoConfiguration-自动配置

ApplicationConfig applicationConfig = new ApplicationConfig();
// 类检查机制
applicationConfig.setSerializeCheckStatus("DISABLE");
applicationConfig.setCheckSerializable(false);

// 提供者配置层
ProviderConfig providerConfig = new ProviderConfig();
// 参数解析序列化方式
providerConfig.setPreferSerialization("hessian2");
providerConfig.setSerialization("hessian2");

【解法】属性文件

# 类检查机制
dubbo.application.serialize-check-status=DISABLE
dubbo.application.check-serializable=false
# 参数解析序列化方式
# 提供者配置层
dubbo.provider.prefer-serialization=hessian2
dubbo.provider.serialization=hessian2

3.6 使用 sharding-jdbc 造成 SQLFeatureNotSupportedException: isValid

暂时关闭actuator对db的监控

  • https://www.cnblogs.com/laeni/p/16089788.html
  • https://blog.csdn.net/kurohatan/article/details/119951747
management.health.db.enabled=false

3.7 屏蔽dubbo访问警告日志

[DUBBO] Will write to the default location, " + "please enable this feature by setting 'accesslog.fixed.path=true' and restart the process. " + "We highly recommend to not enable this feature in production for security concerns, " + "please be fully aware of the potential risks before doing so!, dubbo version: 3.2.10, current host: 192.168.107.130, error code: 0-28. This may be caused by Change of accesslog file path not allowed. , go to https://dubbo.apache.org/faq/0/28 to find instructions.

dubbo协议配置,不设置accesslog访问日志配置项。

# 删除这些
- protocolConfig.setAccesslog(false);
- protocolConfig.setAccesslog("false");

3.8 Spring应用上下文刷新两次

这些信息在应用启动日志里出现两次,ContextRefreshedEvent事件会被触发两次,Spring以父子容器模式运行。

Initializing Spring embedded WebApplicationContext
Root WebApplicationContext: initialization completed

Tomcat initialized with port(s): 8080 (http)
Tomcat initialized with port(s): 18180 (http)

应用里有基于监听ContextRefreshedEvent事件的逻辑,可能会存在两次运行的风险。

防止重复触发

ContextRefreshedEvent使用注意事项

  • 方案一:增加一个是否初始化的标识,进行初始化前判断标识。
  • 方案二:改为监听ApplicationReadyEvent事件,只会触发一次。
/**
 * 并发开关
 */
private final AtomicBoolean concurrentSwitch = new AtomicBoolean(false);

if (concurrentSwitch.compareAndSet(false, true)) {
    // do something
}

先前,18180 端口是以 Jetty 服务器进程启动,不是 Tomcat。
父子容器,应该是 8080 和 18180 都使用 Tomcat 容器启动 引入。
应用以 父容器 为主线。可以查看对象地址

receive event org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@34766f4b, started on Wed Jan 10 10:07:53 CST 2024, parent: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2dd80673]

receive event org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2dd80673, started on Wed Jan 10 10:07:41 CST 2024]

3.9 应用未暴露18180端口

dubbo应用可能未依赖spring-boot-starter-web,未启动Servlet容器,进而未暴露18180端口。

因为18180端口暴露依赖于Servlet容器启动。

【可能解法】增加spring-boot-starter-web依赖可以解决

<!-- spring-boot -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

3.10 RPC调用消费者端反序列化响应对象时数据丢失一条

[FEATURE] 开启JSONWriter.Feature.ReferenceDetection序列化有java.util.List类型成员引用的对象能得到“$ref”序列化结果 · Issue #

RPC调用响应结构中的List某一条数据丢失问题,响应结构中存在外层字段引用List中的元素($ref),是fastjson2的问题,升级到fastjson2-2.0.46解决。

3.11 fastjson2 JSON反序列化异常

com.alibaba.fastjson2.JSONException: skip not support type INT32 68 · Issue #1257 · alibaba/fastjson

本问题是fastjson2的问题,升级到fastjson2-2.0.46解决。

Caused by: org.apache.dubbo.remoting.RemotingException: java.io.IOException: org.apache.dubbo.common.serialize.SerializationException: com.alibaba.fastjson2.JSONException: skip not support type INT32 68

Caused by: org.apache.dubbo.remoting.RemotingException: java.io.IOException: org.apache.dubbo.common.serialize.SerializationException: com.alibaba.fastjson2.JSONException: skip not support type INT32 69

4. 应用部署后检查

应用观测指标

  • 收集观测指标

应用日志中搜索18180关键词

> message:"18180" 

Tomcat started on port(s): 18180 (http) with context path ''

Tomcat initialized with port(s): 18180 (http)

应用本地启动并访问

http://localhost:18180/metrics

若指标URL访问不了,请检查下面这些配置项

management.server.port=18180
#management.server.base-path=
management.server.servlet.context-path=
management.endpoints.web.base-path=
management.endpoints.web.exposure.include=prometheus
management.endpoints.web.exposure.exclude=metrics
management.endpoints.web.path-mapping.prometheus=metrics

可观测工作台

  • Dubbo可观测仪表盘

应用名里搜索

Dubbo可观测

triple协议

1.应用启动日志里搜索tri协议或8506端口

ZookeeperRegistry -  [DUBBO] Register: tri://*.*.*.*:8506/com.xxx.consumer.api.Xxx

2.DubboKeeper工作台

内存满了,数据可能未及时更新

页面里查找8506

5. 升级进度

Dubbo-3.2升级进度表-飞书表格(配置各个环境的升级统计图)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1617360.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

第53篇:算法的硬件实现<四>

Q&#xff1a;本期我们在DE2-115开发板上实现二进制搜索算法电路&#xff0c;查找数据A在数组中的位置。 A&#xff1a;使用SW[9]设定开始查找信号&#xff0c;数据A由SW[7:0]设定&#xff0c;KEY[0]设定为复位信号&#xff0c;板载50MHz时钟作为电路的时钟输入&#xff0c;确…

C语言—深度剖析函数指针,函数指针数组

我们先来看一段代码 #include <stdio.h> void test() {printf("hehe\n"); } int main() {printf("%p\n", test);printf("%p\n", &test);return 0; }输出的是两个地址&#xff0c;这两个地址是 test 函数的地址。 那我们的函数的地址…

【行为型模型】迭代器模式

一、迭代器模式概述 迭代器模式定义&#xff1a;提供一种方法顺序访问一个聚合对象中的各个元素&#xff0c;而又不暴露其内部的表示。把游走的任务放在送代器上&#xff0c;而不是聚合上。这样简化了聚含的接口和实现,也让责任各得其所。(对象行为型) 迭代器模式的优缺点&…

第二届阿里巴巴大数据智能云上编程大赛亚军比赛攻略_北方的郎队

关联比赛: 第二届阿里巴巴大数据智能云上编程大赛-智联招聘人岗智能匹配 查看更多内容&#xff0c;欢迎访问天池技术圈官方地址&#xff1a;第二届阿里巴巴大数据智能云上编程大赛亚军比赛攻略_北方的郎队_天池技术圈-阿里云天池

[Windows] Bypass分流抢票 v1.16.25 五一黄金周自动抢票软件(2024.02.08更新)

五一黄金周要来了&#xff0c;火车票难买到&#xff0c;即便官网候选订票也要看运气&#xff0c;推荐使用这个靠谱的自动抢票软件&#xff0c; 该工具是目前市面上最好用口碑最好的电脑抢票软件&#xff0c;从13年到现在&#xff0c;作者依旧在更新&#xff0c;可以自动识别123…

Linux之 USB驱动框架-USB总线核心和主控驱动(4)

一、USB设备描述符 一个USB设备描述符中可以有多个配置描述符&#xff0c;即USB设备可以有多种配置&#xff1b;一个配置描述符中可以有多个接口描述符&#xff0c;即USB设备可以支持多种功能&#xff08;接口&#xff09;&#xff1b;一个接口描述符中可以有多个端点描述符。 …

Bentley二次开发教程16-元素管理-巩固练习

该练习中的方法涉及到前两期的方法&#xff0c;主要步骤为&#xff1a; 使用拉伸实体功能创建梁与圆柱并进行变换对梁截面进行标注并进行变换对梁与圆柱执行布尔运算对实体进行材质附加 public static void CmdPracticeWork(string unparsed) {DgnFile dgnFile Session.Inst…

小程序AI智能名片S2B2C商城系统:实现分销模式的四大要件深度解析

在当前的电商领域&#xff0c;小程序AI智能名片S2B2C商城系统正以其独特的分销模式&#xff0c;引领着行业创新的风潮。这种模式的成功&#xff0c;离不开四大核心要件&#xff1a;商品、机制、平台和运营。接下来&#xff0c;我们将对这四大要件进行深度解析。 首先&#xff0…

【LeetCode热题100】【多维动态规划】最小路径和

题目链接&#xff1a;64. 最小路径和 - 力扣&#xff08;LeetCode&#xff09; 给定一个包含非负整数的 m x n 网格 grid &#xff0c;请找出一条从左上角到右下角的路径&#xff0c;使得路径上的数字总和为最小。 说明&#xff1a;每次只能向下或者向右移动一步。 经典动态规…

2025年考研复习资料免费获取教程(内容持续更新)

文章目录 导文2025年政治考研复习资料获取2025年英语考研复习资料获取2025年英语一考研复习资料获取2025年英语二考研复习资料获取 2025年数学考研复习资料获取2025年数学一考研复习资料获取2025年数学二考研复习资料获取 导文 考研复习是每一位考研学子都必须经历的重要阶段&a…

重学java 19.面向对象 继承 上

走不出的那段阴霾&#xff0c;很多时候只不过是&#xff0c;我们把它当成了唯一 —— 24.4.22 面向对象整体知识导向&#xff1a; 知识梳理&#xff1a; 1.知道继承的好处 2.会使用继承 3.继承之后成员变量和成员方法的访问特点 4.方法的重写&#xff0c;知道方法重写的使用场景…

nginx配置https及wss

环境说明 服务器的是centos7 nginx版本nginx/1.20.1 springboot2.7.12 nginx安装教程点击这里 微信小程序wss配置 如果您的业务是开发微信小程序&#xff0c; 请先进行如下配置。 boot集成websocket maven <dependency><groupId>org.springframework.boot<…

【Elasticsearch】Elasticsearch 从入门到精通(一):基本介绍

《Elasticsearch 从入门到精通》共包含以下 2 2 2 篇文章&#xff1a; Elasticsearch 从入门到精通&#xff08;一&#xff09;&#xff1a;基本介绍Elasticsearch 从入门到精通&#xff08;二&#xff09;&#xff1a;基础使用 &#x1f60a; 如果您觉得这篇文章有用 ✔️ 的…

c语言应用,三子棋游戏设计

在c语言中&#xff0c;若是要实现三子棋游戏&#xff0c;需要我们对c语言的一维和二维数组的使用&#xff0c;函数的声明和调用&#xff0c;以及循环语句分支语句的结合等&#xff0c;这些知识的贯通。 首先&#xff0c;在设计游戏前我们要知道一下三子棋游戏的规则&#xff0…

NXopen c++快速分割体

通过对话框选择体以及分割该体的面&#xff0c;实现体的分割&#xff0c;相关资源请访问下载我的资源分享&#xff08;上传需要时间审核&#xff09; NXOpen::Session* theSession NXOpen::Session::GetSession();NXOpen::Part* workPart(theSession->Parts()->Work());…

【Linux学习】初始冯诺漫体系结构

文章目录 认识冯诺依曼系统 认识冯诺依曼系统 什么是冯诺依曼体系结构&#xff1f; 冯诺依曼体系结构是一种将程序指令和数据以二进制形式存放在主存储器中&#xff0c;由中央处理器统一控制和执行的计算机系统结构。冯诺依曼体系结构实现了程序的可编程性和硬件与软件的分离&…

mmdeploy框架转化模型

文章目录 1 从源码编译1.1 安装onnxruntime后端1.2 build mmdeploy1.3 install model converter 2 模型转换2.1 deploy用法2.2 示例 1 从源码编译 参考链接 reference2 git clone -b main https://github.com/open-mmlab/mmdeploy.git --recursive cd mmdeploy1.1 安装onnxru…

计算机缺少msvcp120.dll如何解决,7种详细的修复方法分享

msvcr120.dll文件是微软Visual C运行时库的一部分&#xff0c;版本号为12.0。这个DLL文件包含了许多用于支持在Windows上运行的应用程序的重要函数和组件。它是确保某些程序能够正确执行的关键组成部分&#xff0c;特别是那些使用C编写或依赖于某些Microsoft库的程序。 当用户…

C++ | Leetcode C++题解之第44题通配符匹配

题目&#xff1a; 题解&#xff1a; class Solution { public:bool isMatch(string s, string p) {auto allStars [](const string& str, int left, int right) {for (int i left; i < right; i) {if (str[i] ! *) {return false;}}return true;};auto charMatch []…

4月18号总结

java学习 网络编程 1.网络分层 网络分层是将网络通信划分为不同的逻辑层次&#xff0c;每一层负责特定的功能&#xff0c;从而实现网络通信的模块化和标准化。常用的网络分层模型包括OSI&#xff08;开放系统互联&#xff09;模型和TCP/IP模型。 特点和作用&#xff1a; 分…