美文网首页Spring Cloud Spring-Boot
跟我学Spring Cloud(Finchley版)-26-使用

跟我学Spring Cloud(Finchley版)-26-使用

作者: 周立_itmuch | 来源:发表于2019-04-18 13:48 被阅读16次

    前文搭建的Zipkin Server是没有后端存储的——数据会存储在Zipkin的内存中。这一般不适合生产,本节来探讨如何将Zipkin中的数据持久化。

    Zipkin支持多种存储:

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

    综上,个人建议使用Elasticsearch作为Zipkin Server的存储。

    OK,话不多说,来搭建吧。

    搭建

    • 前往 https://www.elastic.co/products/elasticsearch 下载Elasticsearch,笔者使用的版本是 elasticsearch-6.5.3

    • 启动Elasticsearch:

      cd elasticsearch-6.5.3/bin
      ./elasticsearch
      
      # Elasticsearch集群的搭建大家自己百度一下吧,也很简单。本文主要是讲Zipkin,只用一个实例演示就可以了。
      
    • 执行如下命令,启动Zipkin Server

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

      其中:STORAGE_TYPE 指定存储类型是啥;ES_HOSTS 指定你的Elasticsearch地址列表,多个用 , 分隔。还可指定其他环境变量,详见:https://github.com/openzipkin/zipkin/tree/master/zipkin-server#elasticsearch-storage

    • 访问 http://localhost:9411/ 即可看到Zipkin Server的首页。

    测试

    测试步骤非常简单:

    本文首发

    http://www.itmuch.com/spring-cloud/finchley-26/

    关注我

    都是干货!

    相关文章

      网友评论

        本文标题:跟我学Spring Cloud(Finchley版)-26-使用

        本文链接:https://www.haomeiwen.com/subject/nlozwqtx.html