skywalking学习之路---skywalking环境从零搭建

Posted jackion5

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了skywalking学习之路---skywalking环境从零搭建相关的知识,希望对你有一定的参考价值。

介绍

SkyWalking项目是由华为大牛吴晟开源的个人项目,目前已经加入Apache孵化器。SkyWalking项目的核心目标是针对微服务、Cloud Native、容器化架构提供应用性能监控和分布式调用链追踪功能,目前链路追踪和监控应用支持的组件包括主流框架和容器,如dubbo、motan、spring boot、spring cloud等。

整体架构如下图示:

技术图片

整体主要分为三个部分:

1.skywalking-collector:链路数据归集器,数据可以保存在H2或ElasticSearch

2.skywalking-web:web的可视化管理后台,可以查看归集的数据

3.skywalking-agent:探针,用来收集和推送数据到归集器

 

环境搭建

接下来就从零开始搭建一套skywalking环境

第一步:安装Elasticsearch

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学习之路---skywalking环境从零搭建的主要内容,如果未能解决你的问题,请参考以下文章

初识SkyWalking

初识SkyWalking

SkyWalking集成与案例

Skywalking+Elasticsearch安装及应用(邮箱告警)

Skywalking简单入门使用

快速搞懂 Apache SkyWalking 的 OAL