赞
踩
服务依赖参数:
-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
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环境实践一波了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。