之前写过一篇基于Linux下的Skywalking的部署,关于skywalking的介绍可以看这个https://www.cnblogs.com/shook/p/10852691.html
因为这次换了下环境,在docker下部署skywalking,以及.NETCore项目集成
一、所需镜像拉取
docker pull elasticsearch:7.5.1
docker pull apache/skywalking-oap-server:6.6.0-es7
docker pull apache/skywalking-ui:6.6.0
二、安装部署
安装es
docker run -d --name=es7
-p 9200:9200 -p 9300:9300
-e "discovery.type=single-node" elasticsearch:7.5.1
安装oap
docker run --name oap --restart always -d
-e TZ=Asia/Shanghai
-p 12800:12800
-p 11800:11800
--link es7:es7
-e SW_STORAGE=elasticsearch
-e SW_STORAGE_ES_CLUSTER_NODES=es7:9200
apache/skywalking-oap-server:6.6.0-es7
安装ui
docker run -d --name skywalking-ui
-e TZ=Asia/Shanghai
-p 8080:8080
--link oap:oap
-e SW_OAP_ADDRESS=oap:12800
apache/skywalking-ui:6.6.0
看一下容器
访问一下ip:8080就OK啦
三、.NETCore项目集成
还是先看官方文档 https://github.com/SkyAPM/SkyAPM-dotnet
Examples
On windows
dotnet new mvc -n sampleapp
cd sampleapp
dotnet add package SkyAPM.Agent.AspNetCore
set ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=SkyAPM.Agent.AspNetCore
set SKYWALKING__SERVICENAME=sample_app
dotnet run
On macOS/Linux
dotnet new mvc -n sampleapp
cd sampleapp
dotnet add package SkyAPM.Agent.AspNetCore
export ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=SkyAPM.Agent.AspNetCore
export SKYWALKING__SERVICENAME=sample_app
dotnet run
Configuration
Install SkyAPM.DotNet.CLI
dotnet tool install -g SkyAPM.DotNet.CLI
Use dotnet skyapm config [your_service_name] [your_servers] to generate config file.
dotnet skyapm config sample_app 192.168.0.1:11800
我这里是在jenkins里放了下命令,做了自动部署,也可以直接在vs装nuget包省了麻烦
D:
cd D:Jenkins_workspace estProject est
dotnet add package SkyAPM.Agent.AspNetCore
set ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=SkyAPM.Agent.AspNetCore
set SKYWALKING__SERVICENAME=t_netcore
在目标服务器的部署文件夹下执行,会生成skyapm.json文件
dotnet tool install -g SkyAPM.DotNet.CLI
dotnet skyapm config sample_app 192.168.1.1:11800
最后说一下在IIS下运行的配置
SKYWALKING_SERVICENAME
project_name
ASPNETCORE_HOSTINGSTARTUPASSEMBLIES
SkyAPM.Agent.AspNetCore
然后重启站点,回收一下就OK了~