前言:
此刻你们对“apexapache小demo”大概比较重视,同学们都想要了解一些“apexapache小demo”的相关文章。那么小编在网上搜集了一些关于“apexapache小demo””的相关知识,希望你们能喜欢,兄弟们一起来了解一下吧!1、部署Skywalking OAP
拉取镜像
docker pull apache/skywalking-oap-server:8.3.0-es7启动Skywalking OAP
注:–link后面的第一个参数和elasticsearch容器名一致; -e SW_STORAGE_ES_CLUSTER_NODES:es7也可改为你es服务器部署的Ip地址,即ip:9200
docker run --name oap -d --net=host -e TZ=Asia/Shanghai -e SW_STORAGE=elasticsearch7 -e SW_STORAGE_ES_CLUSTER_NODES=192.168.3.7:9200 apache/skywalking-oap-server:8.3.0-es7
如ES开启认证模式,上述启动命令需要修改加上:-e SW_ES_USER=elastic -e SW_ES_PASSWORD=ekexhuyraO3WlPROE1Dn
docker run --name oap -d --net=host -e TZ=Asia/Shanghai -e SW_STORAGE=elasticsearch7 -e SW_STORAGE_ES_CLUSTER_NODES=192.168.3.7:9200 -e SW_ES_USER=elastic -e SW_ES_PASSWORD=ekexhuyraO3WlPROE1Dn apache/skywalking-oap-server:8.3.0-es7
2、部署Skywalking UI
拉取镜像
docker pull apache/skywalking-ui:8.3.0启动Skywalking UI
注:–link后面的第一个参数和skywalking OAP容器名一致;
docker run -d --name skywalking-ui --net=host -e TZ=Asia/Shanghai -e SW_OAP_ADDRESS=192.168.3.18:12800 apache/skywalking-ui:8.3.0
3、spring boot项目集成Skywalking相关依赖
注:不同的日志工具需要集成不同依赖,如下为log4j2,且依赖版本要跟skywalking版本保持一致!
implementation "org.apache.skywalking:apm-toolkit-trace:8.3.0"implementation "org.apache.skywalking:apm-toolkit-log4j-2.x:8.3.0"
log4j2.xml文件配置修改:
<?xml version="1.0" encoding="UTF-8"?><Configuration status="INFO"> <Properties> <!--日志输出表达式--> <property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %style{[%t]}{bright,magenta} %highlight{%-5level}{ERROR=bright red, WARN=bright yellow, INFO=bright default, DEBUG=bright white} %style{%l %X{traceId} %traceId}{cyan} %highlight{%msg%n%throwable}{ ERROR=bright red, WARN=bright yellow, INFO=bright default, DEBUG=bright white}"/> </Properties> <Appenders> <!--控制台输出--> <Console name="Console" target="system_OUT"> <PatternLayout pattern="${FILE_LOG_PATTERN}"/> </Console> <GRPCLogClientAppender name="grpc-log"> <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> </GRPCLogClientAppender> <!--普通日志输出--> <RollingRandomAccessFile name="ServerFile" fileName="logs/server.log" filePattern="logs/server-%d{yyy-MM-dd}-%i.log.gz"> <PatternLayout> <Pattern>${FILE_LOG_PATTERN}</Pattern> </PatternLayout> <Policies> <!--按天归档--> <TimeBasedTriggeringPolicy/> <!--按大小归档--> <SizeBasedTriggeringPolicy size="128MB"/> </Policies> <DefaultRolloverStrategy max="50"> <Delete basePath="logs/" maxDepth="10"> <!-- 只保留14天内日志,超过15天删除 --> <IfLastModified age="15D"/> </Delete> </DefaultRolloverStrategy> </RollingRandomAccessFile> <!--异常日志输出--> <RollingRandomAccessFile name="ServerErrorFile" fileName="logs/server-error.log" filePattern="logs/server-error-%d{yyy-MM-dd}-%i.log.gz"> <PatternLayout> <Pattern>${FILE_LOG_PATTERN}</Pattern> </PatternLayout> <Policies> <TimeBasedTriggeringPolicy/> <SizeBasedTriggeringPolicy size="128MB"/> </Policies> <DefaultRolloverStrategy max="50"> <Delete basePath="logs/" maxDepth="10"> <!-- 只保留14天内日志,超过15天删除 --> <IfLastModified age="15D"/> </Delete> </DefaultRolloverStrategy> </RollingRandomAccessFile> <Async name="AsyncServerFile"> <AppenderRef ref="ServerFile"/> </Async> <Async name="AsyncServerErrorFile"> <AppenderRef ref="ServerErrorFile"/> </Async> </Appenders> <Loggers> <AsyncRoot level="INFO"> <AppenderRef ref="Console"/> <AppenderRef ref="grpc-log"/> <AppenderRef ref="AsyncServerFile"/> <AppenderRef ref="AsyncServerErrorFile" level="ERROR"/> </AsyncRoot> <!--定制日志打印级别--> <!-- <Logger name="com.test" level="DEBUG" />--> </Loggers></Configuration>
重新打包微服务!
4、应用程序配合Skywalking Agent部署
官网下载skywalking-agent
下载地址:
这里有一点需要注意,一定要下载对应的skywalking-oap版本的skywalking-agent,否则就有可能会导致agent无法上报,笔者一开始觉得agent可以做到向下兼容,下载了8.8版本,导致上传监控数据失败了,报错原因是oap-server端返回的方法不存在grpc-message: Method not found: skywalking.v3.JVMMetricReportService/collect,日志如下:
注意事项:
过滤不监控的请求地址复制如下jar包到agent/plugins下新增如下配置文件,apm-trace-ignore-plugin.config
trace.ignore_path=${SW_AGENT_TRACE_IGNORE_PATH:/nacos/v1/**,eventbus.EventBusService.subscribe,eventbus.EventBusService.subscribe/**,Lettuce/**}docker部署网关对接skywalking方式复制agent包到Dockerfile所在目录下
#进入Dockerfile所在目录cd /home/gateway#复制文件夹cp -r /opt/apache-skywalking-apm-bin ./apache-skywalking-apm-bin修改Dockerfile文件如下,现场有所不同可以调整
#基于java8FROM openjdk:8-jdk#指定工作目录WORKDIR /liveservice/gateway#开放9083端口EXPOSE 8088#将agent目录下的文件复制到容器中,注意COPY只能复制dockerfile文件所在目录的文件或文件夹COPY ./apache-skywalking-apm-bin ./apache-skywalking-apm-bin#将目录下的文件复制到容器中COPY ./gateway-client-server-1.0.0.jar ./gateway-client-server.jar#将配置文件复制到容器的指定目录中COPY ./config ./config#配置容器启动后执行的命令ENTRYPOINT ["java","-javaagent:./apache-skywalking-apm-bin/agent/skywalking-agent.jar=agent.service_name=apexsoft-gateway,collector.backend_service=192.168.3.18:11800","-jar","-Xms512M","-Xmx512M","./gateway-client-server.jar"]然后打包镜像,后续操作跟之前相同;javaagent运行
nohup java -javaagent:/opt/apache-skywalking-apm-bin/agent/skywalking-agent.jar=agent.service_name=fw-gateway,collector.backend_service=192.168.3.18:11800 -jar gateway-client-server-1.0.0.jar &
标签: #apexapache小demo