服务依赖参数:

-javaagent:C:/Users/lixiuyang/Desktop/apache-skywalking-apm-bin/agent/skywalking-agent.jar  -Dskywalking.collector.backend_service=127.0.0.1:11800

 服务依赖:

        <dependency>
            <groupId>org.apache.skywalking</groupId>
            <artifactId>apm-toolkit-logback-1.x</artifactId>
            <version>8.8.0</version>
        </dependency>

控制台日志:

17:49:39.993 [http-nio-18082-exec-3] INFO  logger_name:com.lxy.controller.StudentController - [TID:8b6d110b5fc34cbda8b92a2c5a668df9.120.16439681799930001] - message:消费者------
17:49:44,399 |-INFO in ReconfigureOnChangeTask(born:1643967704392) - Empty watch file list. Disabling 
17:50:14,407 |-INFO in ReconfigureOnChangeTask(born:1643967704392) - Empty watch file list. Disabling 



17:49:32,823 |-INFO in ReconfigureOnChangeTask(born:1643967692809) - Empty watch file list. Disabling 
17:49:39.995 [DubboServerHandler-192.168.1.105:20880-thread-3] INFO  logger_name:com.lxy.service.StudentServiceImpl - [TID:8b6d110b5fc34cbda8b92a2c5a668df9.120.16439681799930001] - message:生产者------
17:50:02,824 |-INFO in ReconfigureOnChangeTask(born:1643967692809) - Empty watch file list. Disabling 

linux版本:   

2.制作需要的jre镜像

#项目中使用的基础jre镜像
docker pull  openjdk:8-jre
#运行jre
docker   run -it  --name   myjre    d44e1fb77166
#拷贝本地文件到容器内部
docker  cp   /data/sk   容器:/data
#提交制作好的镜像
docker  commit  -a ‘lixiuyang’  65b0a832e83b     myjre:v1
#登录阿里云docker 镜像仓库
docker login --username=XXX@qq.com registry.cn-hangzhou.aliyuncs.com
#打包本地镜像仓库
docker tag   3e597ed0a120  registry.cn-hangzhou.aliyuncs.com/lixiuyang/jdk:v1
#推送本地镜像到阿里云
docker push registry.cn-hangzhou.aliyuncs.com/lixiuyang/jdk:v1
至此,自定义镜像已经制作完成

2.制作Dockerfile文件

FROM registry.cn-hangzhou.aliyuncs.com/lixiuyang/jdk:v1
MAINTAINER lixiuyang

ENV DUBBO_PORT_TO_REGISTRY: tool-template
ENV DUBBO_PORT_TO_BIND: 20883

ADD dubbo-consumer-1.0.0.jar  dubbo-consumer.jar
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
ENTRYPOINT ["java","-javaagent:/data/apache-skywalking-apm-bin/agent/skywalking-agent.jar","-Dskywalking.collector.backend_service=112.74.188.53:11800","-Dskywalking.agent.service_name=dubbo-consumer", "-jar", "-Xms200m", "-Xmx200m", "/dubbo-consumer.jar"]

3.容器部署

#制作服务镜像
docker build -f Dockerfile -t dubbo-provider:1 .
docker build -f Dockerfile -t dubbo-consumer:1 .
#运行容器
docker run -p   18082:18082 -d     dubbo-consumer:1
docker run      dubbo-provider:1

4.查看日志

11:30:34.793 [http-nio-18082-exec-8] INFO  logger_name:com.lxy.controller.StudentController - [TID:d30ecf9d0b2f4ba6a535670aa39166b7.79.16469694347910001] - message:uri:"http://172.18.0.8:20880"------
11:30:34.793 [http-nio-18082-exec-8] INFO  logger_name:com.lxy.controller.StudentController - [TID:d30ecf9d0b2f4ba6a535670aa39166b7.79.16469694347910001] - message:消费者------



11:30:34.322 [DubboServerHandler-172.18.0.8:20880-thread-6] INFO  logger_name:com.lxy.service.StudentServiceImpl - [TID:d30ecf9d0b2f4ba6a535670aa39166b7.76.16469694343180001] - message:生产者------
11:30:34.478 [DubboServerHandler-172.18.0.8:20880-thread-7] INFO  logger_name:com.lxy.service.StudentServiceImpl - [TID:d30ecf9d0b2f4ba6a535670aa39166b7.77.16469694344710001] - message:生产者------
11:30:34.623 [DubboServerHandler-172.18.0.8:20880-thread-8] INFO  logger_name:com.lxy.service.StudentServiceImpl - [TID:d30ecf9d0b2f4ba6a535670aa39166b7.78.16469694346190001] - message:生产者------
11:30:34.796 [DubboServerHandler-172.18.0.8:20880-thread-9] INFO  logger_name:com.lxy.service.StudentServiceImpl - [TID:d30ecf9d0b2f4ba6a535670aa39166b7.79.16469694347910001] - message:生产者------

5.UI查看链路追踪:


至此,自定义镜像+项目集成skywalking就算结束了,接下来就可以着手去生产环境k8s环境实践一波了

skywalking-8.8.0-Java文档类资源-CSDN下载1.从官网趴下来的,官网下载很慢2.版本比较新8.8更多下载资源、学习资料请访问CSDN下载频道.https://download.csdn.net/download/riju4713/79231332

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐