7
Spring Cloud之Finchley版学习(二十六)-使用Elasticsearch作为Zipkin Server的后端...
source link: https://www.wencst.com/archives/1673
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Spring Cloud之Finchley版学习(二十六)-使用Elasticsearch作为Zipkin Server的后端存储
前文搭建的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的首页。
测试步骤非常简单:
- 按照 跟我学Spring Cloud(Finchley版)-25-Spring Cloud Sleuth与Zipkin配合使用 一节的描述,往Zipkin Server中存储一些数据
- 停止Zipkin Server
- 再次启动Zipkin Server,查看之前存储的数据是否存在,如果存在说明数据已被持久化。
如果文章对您有用,扫一下支付宝的红包,不胜感激!
欢迎加入QQ群进行技术交流:656897351(各种技术、招聘、兼职、培训欢迎加入)
Leave a Reply Cancel reply
You must be logged in to post a comment.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK