skywalking學習之路---skywalking環境從零搭建部署

介紹

SkyWalking項目是由華爲大牛吳晟開源的我的項目,目前已經加入Apache孵化器。SkyWalking項目的核心目標是針對微服務、Cloud Native、容器化架構提供應用性能監控和分佈式調用鏈追蹤功能,目前鏈路追蹤和監控應用支持的組件包括主流框架和容器,如dubbo、motan、spring boot、spring cloud等。java

總體架構以下圖示:node

總體主要分爲三個部分:web

1.skywalking-collector:鏈路數據歸集器,數據能夠保存在H2或ElasticSearchspring

2.skywalking-web:web的可視化管理後臺,能夠查看歸集的數據express

3.skywalking-agent:探針,用來收集和推送數據到歸集器apache

 

環境搭建

接下來就從零開始搭建一套skywalking環境bootstrap

第一步:安裝Elasticsearchvim

1.下載Elasticsearch瀏覽器

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.10.tar.gz架構

2.解壓壓縮包

tar -vxf elasticsearch-5.6.10.tar.gz

3.配置elasticsearch參數

cd /elasticsearch-5.6.10/config

vim elasticsearch.yml

設置參數:

cluster.name: CollectorDBCluster

node.name: CollectorDBCluster

network.host: 127.0.0.1

4.啓動ElasticSearch

./bin/elasticsearch

發現啓動失敗,提示報錯

OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory. # An error report file with more information is saved as: # /home/elasticsearch-5.6.10/hs_err_pid1738.log

 

查詢資料發現是jvm內存設置問題,繼續修改參數配置。

cd config

vim jvm.options

設置參數 -Xms4g 和 -Xmx4g  將-Xms2g和-Xmx2g註釋 以下圖示

再從新啓動elasticsearch,發現再次啓動失敗,錯誤信息爲:

Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root. at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93) at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144) at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) Refer to the log for complete error details.

 

緣由是Elasticsearch是不容許使用root帳戶啓動,因此須要切換到其餘用戶再啓動,最終elasticsearch啓動成功。

 

[2019-03-26T23:40:37,583][INFO ][o.e.n.Node ] [] initializing ... [2019-03-26T23:40:37,677][INFO ][o.e.e.NodeEnvironment    ] [5DFSDCK] using [1] data paths, mounts [[/ (/dev/disk1s1)]], net usable_space [187.5gb], net total_space [233.4gb], spins? [unknown], types [apfs] [2019-03-26T23:40:37,678][INFO ][o.e.e.NodeEnvironment    ] [5DFSDCK] heap size [1.9gb], compressed ordinary object pointers [true] [2019-03-26T23:40:37,679][INFO ][o.e.n.Node ] node name [5DFSDCK] derived from node ID [5DFSDCK_QhibMsJg734Ysg]; set [node.name] to override [2019-03-26T23:40:37,679][INFO ][o.e.n.Node               ] version[5.6.10], pid[22167], build[b727a60/2018-06-06T15:48:34.860Z], OS[Mac OS X/10.13.6/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_191/25.191-b12] [2019-03-26T23:40:37,679][INFO ][o.e.n.Node               ] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/Users/xingwuxu/tools/elasticsearch-5.6.10] [2019-03-26T23:40:38,317][INFO ][o.e.p.PluginsService     ] [5DFSDCK] loaded module [aggs-matrix-stats] [2019-03-26T23:40:38,317][INFO ][o.e.p.PluginsService     ] [5DFSDCK] loaded module [ingest-common] [2019-03-26T23:40:38,317][INFO ][o.e.p.PluginsService     ] [5DFSDCK] loaded module [lang-expression] [2019-03-26T23:40:38,317][INFO ][o.e.p.PluginsService     ] [5DFSDCK] loaded module [lang-groovy] [2019-03-26T23:40:38,317][INFO ][o.e.p.PluginsService     ] [5DFSDCK] loaded module [lang-mustache] [2019-03-26T23:40:38,317][INFO ][o.e.p.PluginsService     ] [5DFSDCK] loaded module [lang-painless] [2019-03-26T23:40:38,317][INFO ][o.e.p.PluginsService     ] [5DFSDCK] loaded module [parent-join] [2019-03-26T23:40:38,317][INFO ][o.e.p.PluginsService ] [5DFSDCK] loaded module [percolator] [2019-03-26T23:40:38,317][INFO ][o.e.p.PluginsService ] [5DFSDCK] loaded module [reindex] [2019-03-26T23:40:38,317][INFO ][o.e.p.PluginsService     ] [5DFSDCK] loaded module [transport-netty3] [2019-03-26T23:40:38,318][INFO ][o.e.p.PluginsService     ] [5DFSDCK] loaded module [transport-netty4] [2019-03-26T23:40:38,318][INFO ][o.e.p.PluginsService ] [5DFSDCK] no plugins loaded [2019-03-26T23:40:39,595][INFO ][o.e.d.DiscoveryModule ] [5DFSDCK] using discovery type [zen] [2019-03-26T23:40:39,976][INFO ][o.e.n.Node ] initialized [2019-03-26T23:40:39,976][INFO ][o.e.n.Node ] [5DFSDCK] starting ... [2019-03-26T23:40:40,167][INFO ][o.e.t.TransportService   ] [5DFSDCK] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300} [2019-03-26T23:40:43,226][INFO ][o.e.c.s.ClusterService   ] [5DFSDCK] new_master {5DFSDCK}{5DFSDCK_QhibMsJg734Ysg}{PFrWZNI9RHWNAneytiifdA}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)[, ] [2019-03-26T23:40:43,242][INFO ][o.e.h.n.Netty4HttpServerTransport] [5DFSDCK] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200} [2019-03-26T23:40:43,243][INFO ][o.e.n.Node ] [5DFSDCK] started [2019-03-26T23:40:43,248][INFO ][o.e.g.GatewayService     ] [5DFSDCK] recovered [0] indices into cluster_state

 

ElasticSearch啓動成功,監聽9200端口,此時在瀏覽器打開127.0.0.1:9200便可看到ElasticSearch的基本信息

 

 


第二步:安裝skywalking

第一步:下載skywalking

curl -L -O https://mirrors.tuna.tsinghua.edu.cn/apache/incubator/skywalking/6.0.0-GA/apache-skywalking-apm-incubating-6.0.0-GA.tar.gz

第二步:解壓壓縮包

tar -vxf -vxf 

第三步:修改配置文件,將數據存儲h2配置注射,並取消es的註釋

storage: # h2: # driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource} # url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db} # user: ${SW_STORAGE_H2_USER:sa} elasticsearch: # nameSpace: ${SW_NAMESPACE:""} clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200} indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:2} indexReplicasNumber: ${SW_STORAGE_ES_INDEX_REPLICAS_NUMBER:0}

 

第四步:啓動skywalking,執行bin目錄下的start.sh命令

./start.sh

日誌打印:

SkyWalking OAP started successfully! SkyWalking Web Application started successfully!

 

skywalking啓動成功,打開瀏覽器,在瀏覽器中輸入地址localhost:8080會顯示以下界面

skywalking後臺默認登錄用戶密碼爲:admin/admin,登錄以後界面爲:

至此skywalking的基本環境搭建已完成,接下來就在實踐中看看skywalking具體都有哪些功能及具體該怎麼用?

相關文章
相關標籤/搜索