本文基于Zipkin Server 2.12.9编写,理论支持Zipkin 2.0及更高版本。
Zipkin Server的 API兼容性(微服务通过集成reporter模块,从而Zipkin Server通信) 非常好
对于Spring Cloud Greenwich,Zipkin Server只需安装2.x即可。

下载

方式1:使用Zipkin官方的Shell下载

TIPS

如下命可以下载最新版本。

curl -sSL https://zipkin.io/quickstart.sh | bash -s

下载下来的文件名为 zipin.jar

方式2:到Maven中央仓库下载

TIPS

如下地址可以下载最新版本。

访问如下地址即可:

https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-server&v=LATEST&c=exec

下载下来的文件名为 zipkin-server-2.12.9-exec.jar

方式3:使用百度盘地址下载

提供2.12.9版本。

链接:https://pan.baidu.com/s/1HXjzNDpzin6fXGrZPyQeWQ 密码:aon2

启动Zipkin Server

使用如下命令,即可启动Zipkin Server

java -jar 你的jar包
访问http://localhost:9411 即可看到Zipkin Server的首页。

ZipKin 持久化

Zipkin支持多种存储:
    1. 内存(默认)
    2. MySQL(数据量大时,查询较为缓慢,不建议使用)
    3. Elasticsearch
    4. Cassandra(Twitter官方使用Cassandra作为Zipkin Server的存储,但国内大规模用Cassandra的公司较少,Cassandra相关文档也不多)

搭建Elasticsearch

{
"name" : "WfSYaKG",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "dGCAG-HkSv-hiNFfeqoV1A",
"version" : {
  "number" : "2.3.0",
  "build_hash" : "f9d9b74",
  "build_date" : "2017-02-24T17:26:45.835Z",
  "build_snapshot" : false,
  "lucene_version" : "6.4.1"
},
"tagline" : "You Know, for Search"
}

报错 详细见CentOS7下安装ElasticSearch文章

  • 启动内存不足

    ./bin/elasticsearch
    ./bin/elasticsearch -d 后台启动
Java HotSpot(TM) 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:
# /data/elasticsearch-5.2.2/hs_err_pid26945.log

解决方案:调小启动内存

vi $
/config/jvm.options

#-Xms2g
#-Xmx2g
-Xms512m
-Xmx512m  
  • 无法以root权限启动
[2017-03-23T16:22:17,193][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89) ~[elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82) ~[elasticsearch-5.2.2.jar:5.2.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:203) ~[elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-5.2.2.jar:5.2.2]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.2.2.jar:5.2.2]
        ... 6 more
解决方案:创建一个非root用户并赋予目录该用户权限,再启动<br>
    这是出于系统安全考虑设置的条件。由于ElasticSearch可以接收用户输入的脚本并且执行,为了系统安全考   虑,建议创建一个单独的用户用来运行ElasticSearch。

    创建用户组和用户:

    groupadd esgroup

    useradd esuser -g esgroup -p espassword

    更改elasticsearch文件夹及内部文件的所属用户及组:

    cd /opt

    chown -R esuser:esgroup elasticsearch-6.8.4

    切换用户并运行:

    su esuser

    ./bin/elasticsearch

执行如下命令,重新启动Zipkin Server

STORAGE_TYPE=elasticsearch ES_HOSTS=localhost:9200 java -jar zipkin-server-2.11.3-exec.jar

ZipKin 整合Elasticsearch时没有服务依赖解决

使用ZipKin Dependencies即可,下图是启动ZipKin Dependencies的环境变量
图片

Q.E.D.


爱调味品的大哥