SkyWalking開源項目由吳晟於2015年建立,同年10月在GitHub上做爲我的項目開源。javascript
SkyWalking項目的核心目標,是針對微服務、Cloud Native、容器化架構,提供應用性能監控(APM)和分佈式調用鏈追蹤能力。php
2017年11月,SkyWalking社區正式決定,尋求加入Apache基金會,但願能使項目成爲更爲開放、全球化和強大的APM開源產品,並增強來自社區的合做和交流。最終實現構建一款功能強大、簡單易用的開源APM產品。css
2017年12月8日,Apache軟件基金會孵化器項目管理委員會 ASF IPMC宣佈「SkyWalking全票經過,進入Apache孵化器」。java
APM = Application Performance Management,即應用性能管理,主要是針對企業級應用軟件市場,對企業系統實施即時監控,以實現對應用程序性能管理和故障管理的系統化的解決方案。node
APM的覆蓋範圍包括五個層次的實現:終端用戶體驗,應用架構映射,應用事務的分析,深度應用診斷,和數據分析。linux
過去,企業的IT部門在收集系統性能參數時,通常重點關注爲最終用戶提供服務的硬件組件的利用率,如CPU利用率、內存佔用、網絡吞吐量。雖然這種方法也提供了一些寶貴的信息,但卻忽視了最重要的因素:最終用戶的響應時間。git
如今,經過事務處理過程監測、模擬等手段,能夠真實測量用戶響應時間,此外還能夠報告誰正在使用某一應用、該應用的使用頻率以及用戶所進行的事務處理過程是否成功完成、發生錯誤時的參數與堆棧調用信息、數據庫查詢語句跟蹤等。github
自微軟發佈 .net core 2.0以來,.net開發者迎來了幸福的春天,咱們的程序將再也不侷限於Windows平臺。2.x版的.net core已趨於穩定,各廠的配套也在逐步跟上,使得整個生態在逐漸的豐富起來。web
SkyWalking-netcore
是.net core平臺下的代理程序,在NCC社區的Lemon大神帶領下進行開發,並於2018年4月17日正式加入OpenSkywalking
,於2018年4月19日發佈v0.1.0版本。數據庫
佈署一個基於SkyWalking的.net core應用監控系統,監控Web應用的性能。
XShell
WinSCP
Visual Studio 2017
.net Core 2.0.3 SDK
JDK8+
Elasticsearch 5.x
本次實驗採用三臺服務器 ,Elasticsearch 與 Collector 放在一臺服務器上,收集另外兩臺Web服務器提供的數據,實驗應用架構以下圖。
實驗架構
Server-0一、Web0一、Web02安裝 CentOS系統,安裝過程詳見《IT基礎設施:CentOS7安裝指南》
IP配置表
服務器 | IP | 備註 |
---|---|---|
Server-01 | 192.168.10.191 | 提供ES服務、Collector與WebUI |
Web01 | 192.168.10.192 | 運行App1 |
Web02 | 192.168.10.193 | 運行 App2 |
MSSQL | 暫無 | 因.net Core的代理程序暫未提供支持,故本文不演示此部分,待新版本發佈後更新 |
WebService | 暫無 | 因.net Core的代理程序暫未提供支持,故本文不演示此部分,待新版本發佈後更新 |
在Web0一、Web02上安裝.net core 2.0 SDK,詳見《在CentOS7下安裝.Net Core 2.0.3 SDK》
由於oracle如今要贊成協議才能下載,直接使用wget加連接下載不到,因此要加上前面的那些代碼:
wget --no-check-certificate --no-cookie --header "Cookie: oraclelicense=accept-securebackup-cookie;" http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.rpm
也能夠先用迅雷下到主機,再經過局域網下載到虛擬機
使用rpm -ivh jdk-8u45-linux-x64.rpm
進行安裝
命令執行完畢即安裝完成,使用java -version
檢查是否安裝成功
一、到官網下載5.x版,目前爲5.6.9
下載5.x
二、使用WinSCP上傳到Server-01,解壓到/home/elasticsearch5.6.9下。
三、修改/home/elasticsearch5.6.9/config/elasticsearch.yml
設置 cluster.name: CollectorDBCluster
。此名稱須要和collector配置文件一致。
設置 node.name: masterNode
, 節點名稱能夠設置爲任意名字,如爲集羣模式,則每一個節點名稱須要不一樣。
增長以下配置
cluster.name: CollectorDBClusternetwork.host: 0.0.0.0thread_pool.bulk.queue_size: 1000
cluster.name: CollectorDBClusternetwork.host: 0.0.0.0thread_pool.bulk.queue_size: 1000
最終配置以下:
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!/usr/bin/env sh
PRG="$0"
PRGDIR=`dirname "$PRG"`
[ -z "$WEBAPP_HOME" ] && WEBAPP_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
WEBAPP_LOG_DIR="${WEBAPP_HOME}/logs"
JAVA_OPTS=" -Xms256M -Xmx512M"
JAR_PATH="${WEBAPP_HOME}/webapp"
if [ ! -d "${WEBAPP_HOME}/logs" ]; then
mkdir -p "${WEBAPP_LOG_DIR}"
fi
_RUNJAVA=${JAVA_HOME}/bin/java
[ -z "$JAVA_HOME" ] && _RUNJAVA=java
eval exec "\"$_RUNJAVA\" ${JAVA_OPTS} -jar ${JAR_PATH}/skywalking-webapp.jar \
--server.port=8080 --collector.ribbon.listOfServers=192.168.10.191:10800 \
2>${WEBAPP_LOG_DIR}/webapp.log 1> /dev/null &"
if [ $? -eq 0 ]; then
sleep 1
echo "Skywalking Web Application started successfully!"
else
echo "Skywalking Web Application started failure!"
exit 1
fi
運行啓動Elasticsearch/home/elasticsearch5.6.9/bin/elasticsearch.sh
下載release的版本https://github.com/OpenSkywalking/skywalking-netcore/releases
下載
將壓縮包解壓到Server-01
的/home/collector/
目錄
修改/home/collector/bin/webappService.sh
中的127.0.0.1
爲Server-01
的IP地址,目前爲192.168.10.191
。
最終腳本以下:
修改/home/collector/config/application.yml
中的全部localhost
爲Server-01
的IP地址,目前爲192.168.10.191
。
最終配置文件以下:
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the# "License");
you may not use this file except in compliance# with the License.
You may obtain a copy of the License at
## http://www.apache.org/licenses/LICENSE-2.0
## Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.#cluster:
# zookeeper:
# hostPort: localhost:2181
# sessionTimeout: 100000naming:
jetty:
host: 192.168.10.191
port: 10800
contextPath: /
cache:# guava:
caffeine:
remote:
gRPC:
host: 192.168.10.191
port: 11800agent_gRPC:
gRPC:
host: 192.168.10.191
port: 11800
#Set these two setting to open ssl
#sslCertChainFile: $path
#sslPrivateKeyFile: $path
#Set your own token to active auth
#authentication: xxxxxxagent_jetty:
jetty:
host: 192.168.10.191
port: 12800
contextPath: /
analysis_register: default:
analysis_jvm: default:
analysis_segment_parser: default:
bufferFilePath: ../buffer/
bufferOffsetMaxFileSize: 10M
bufferSegmentMaxFileSize: 500M
ui:
jetty:
host: 192.168.10.191
port: 12800
contextPath: /
storage:
elasticsearch:
clusterName: CollectorDBCluster
clusterTransportSniffer: true
clusterNodes: localhost:9300
indexShardsNumber: 2
indexReplicasNumber: 0
highPerformanceMode: true
ttl: 7
#storage:# h2:
# url: jdbc:h2:~/memorydb
# userName: saconfiguration: default
:# namespace: xxxxx
applicationApdexThreshold: 2000
serviceErrorRateThreshold: 10.00
serviceAverageResponseTimeThreshold: 2000
instanceErrorRateThreshold: 10.00
instanceAverageResponseTimeThreshold: 2000
applicationErrorRateThreshold: 10.00
applicationAverageResponseTimeThreshold: 2000
運行/home/collector/bin/startup.sh
啓動WebUI和Collector。
接下來,咱們建立一個Web應用,並在其中加入Skywalking for dotnet core的代理程序。
一、打開VS2017,建立一個.Net Core MVC應用,請跟着我操做:VS中點擊菜單「文件」——「新建」——「項目」(按Ctrl+Shift+N同等效果),在彈出的對話框中從左到右進行以下操做。
.Net Core Web應用
選擇項目類型
二、等項目建好,右鍵點擊「依賴項」——「管理Nuget程序包」,打開Nuget管理器。
操做
在「瀏覽」選項卡,輸入「Skywalking.AspNetCore」搜索,並安裝
找到包
安裝前須要接受許可證,點擊「我接受」(不接受請關閉本文)
許可證
三、安裝完成後,打開Startup.cs
,在ConfigureServices
函數中加入
services.AddSkyWalking(option =>
{ //這裏填本應用的名稱,每一個應用不一樣
option.ApplicationCode = "OurApplication1";
//這裏填Collector的地址
option.DirectServers = "192.168.10.191:11800";
});
Startup.cs
完整代碼以下
using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNetCore.Builder;using Microsoft.AspNetCore.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;using SkyWalking.AspNetCore;namespace WebApplication2
{ public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
} public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddSkyWalking(option =>
{ //這裏填本應用的名稱,每一個應用不一樣
option.ApplicationCode = "OurApplication1";
//這裏填Collector的地址
option.DirectServers = "192.168.10.191:11800";
});
services.AddMvc();
} // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{ if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
} else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
打開Program.cs
文件,容許非本地訪問,最終代碼以下
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace WebApplication2
{ public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
} public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseUrls("http://*:5000")
.UseStartup<Startup>()
.Build();
}
}
四、發佈:點擊咱們的WEB應用,右鍵——發佈,接下來看圖操做。
發佈
發佈到文件夾
選擇目標位置
發佈
沒有失敗,恭喜,大吉大利,今晚吃雞
咱們能夠看到,發佈完成後的文件,一大堆,咱們把這個文件夾更名爲App1
發佈成功
五、接下來,咱們在StartUp.cs
中把ApplicationCode改一下,按上面的步驟再發布一次。
image.png
此次發佈生成的Publish3文件夾,咱們更名爲App2
一、打開WinSCP,連上Web01,將App1拖到/home下。
二、打開XShell,連上Web01,執行以下命令
# 關掉防火牆(生產環境不宜)systemctl stop firewalld
# 給予執行權限chmod 777 /home/App1/WebApplication2.dll
# 在後臺運行應用nohup dotnet /home/App1/WebApplication2.dll &
一樣的操做,將App2佈署到Web02上。
咱們打開兩個應用,隨機點擊一下應用頂部的連接。
http://192.168.10.192:5000,這是咱們的app1
http://192.168.10.193:5000,這是咱們的app2
打開http://192.168.10.191:8080
,查看監測狀況
監測到的應用
查看被訪問的服務響應速度
服務狀態
Skywalking-netcore作爲.Net core社區的新生命,具備無限的潛力,據可靠消息,新版本將更深刻地監測數據庫操做及狀態,HTTP請求消息以及StackTrace跟蹤,讓咱們一塊兒爲它打Call加油吧。猛戮這裏,到Github給Skywalking-netcore點星星。 :)
原文地址: https://www.jianshu.com/p/3ddd986c7581