博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Elasticsearch-6.7.0系列(七)SpringCloud连接ES集群,使用ES用户名密码
阅读量:5098 次
发布时间:2019-06-13

本文共 6294 字,大约阅读时间需要 20 分钟。

pom.xml代码:

4.0.0
com.joyce
joyce-component-zipkin
1.0
jar
org.springframework.boot
spring-boot-starter-parent
1.5.20.RELEASE
org.springframework.cloud
spring-cloud-dependencies
Edgware.SR5
pom
import
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
org.springframework.cloud
spring-cloud-starter-netflix-hystrix
org.springframework.cloud
spring-cloud-starter-netflix-hystrix-dashboard
org.springframework.cloud
spring-cloud-starter-zipkin
org.springframework.cloud
spring-cloud-starter-netflix-ribbon
org.springframework.boot
spring-boot-starter-web
io.zipkin.java
zipkin-server
io.zipkin.java
zipkin-autoconfigure-ui
io.zipkin.java
zipkin-autoconfigure-storage-elasticsearch-http
2.8.4
true
com.squareup.okhttp3
okhttp
org.springframework.cloud
spring-cloud-sleuth-zipkin
junit
junit
test
org.springframework.boot
spring-boot-starter-test
test

 

application.properties配置文件代码:

server.port=8740spring.application.name=joyce-component-zipkineureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka,http://localhost:8762/eureka,http://localhost:8763/eurekaeureka.client.registerWithEureka=trueeureka.client.fetchRegistry=trueeureka.instance.instance-id=${spring.application.name}:${server.port}eureka.instance.prefer-ip-address=true#接受zipkin追踪,追踪数据会传导给turbine实时监控(如果存在)spring.zipkin.enabled=truespring.sleuth.feign.enabled=truespring.sleuth.hystrix.strategy.enabled=truespring.sleuth.sampler.percentage=1.0spring.zipkin.base-url=http://joyce-component-zipkin##############################  ES单点连接    #######################zipkin.storage.type=elasticsearch#zipkin.storage.elasticsearch.hosts=192.168.10.140:9200#zipkin.storage.elasticsearch.max-requests=100#zipkin.storage.elasticsearch.index=zipkin#zipkin.storage.elasticsearch.index-shards=0#zipkin.storage.elasticsearch.index-replicas=0##############################  ES集群连接,使用用户名和密码    ######################zipkin.storage.type=elasticsearch                            //使用elasticsearch存储zipkin追踪数据zipkin.storage.elasticsearch.cluster=joyce-elasticsearch     //集群的cluster namezipkin.storage.elasticsearch.hosts=192.168.10.110:9200,192.168.10.120:9200,192.168.10.130:9200zipkin.storage.elasticsearch.max-requests=100zipkin.storage.elasticsearch.timeout=1000         zipkin.storage.elasticsearch.index=zipkin         //存储zipkin数据时,ES的数据索引以zipkin为前缀,示例:zipkin-2019-06-09zipkin.storage.elasticsearch.date-separator=-     //ES索引数据的日期分隔符,默认为“-”zipkin.storage.elasticsearch.index-shards=6      //集群的分片个数zipkin.storage.elasticsearch.index-replicas=0    //集群的备(从)个数zipkin.storage.elasticsearch.username=elastic    //用户名zipkin.storage.elasticsearch.password=1234567    //密码

zipkin.storage.type前缀注入到zipkin-autoconfigure-storage-elasticsearch-http-2.8.4.jar包里的TracingZipkinElasticsearchHttpStorageAutoConfiguration类。

@ConditionalOnBean(Tracing.class)@ConditionalOnProperty(name = "zipkin.storage.type", havingValue = "elasticsearch")@Configurationclass TracingZipkinElasticsearchHttpStorageAutoConfiguration {

zipkin.storage.elasticsearch前缀注入到zipkin-autoconfigure-storage-elasticsearch-http-2.8.4.jar包里的ZipkinElasticsearchHttpStorageProperties类。

@ConfigurationProperties("zipkin.storage.elasticsearch")class ZipkinElasticsearchHttpStorageProperties implements Serializable {

SpringCloud启动类代码:

package com.joyce.zipkin;import org.slf4j.LoggerFactory;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.netflix.eureka.EnableEurekaClient;import org.springframework.cloud.netflix.hystrix.EnableHystrix;import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;import zipkin.server.internal.EnableZipkinServer;@SpringBootApplication@EnableZipkinServer@EnableHystrix@EnableHystrixDashboard@EnableEurekaClientpublic class ComponentZipkinApplication {    private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(ComponentZipkinApplication.class);        public static void main(String[] args) {        SpringApplication.run(ComponentZipkinApplication.class, args);     }}

 

转载于:https://www.cnblogs.com/zhuwenjoyce/p/10993231.html

你可能感兴趣的文章
mysql基础语句
查看>>
Oracle中的rownum不能使用大于>的问题
查看>>
[Data Structure & Algorithm] 有向无环图的拓扑排序及关键路径
查看>>
cassandra vs mongo (1)存储引擎
查看>>
Visual Studio基于CMake配置opencv1.0.0、opencv2.2
查看>>
Vue音乐项目笔记(三)
查看>>
遍历Map对象
查看>>
计算剪贴板里仿制的代码行数
查看>>
MySQL索引背后的数据结构及算法原理
查看>>
#Leetcode# 209. Minimum Size Subarray Sum
查看>>
SDN第四次作业
查看>>
DM8168 DVRRDK软件框架研究
查看>>
django迁移数据库错误
查看>>
yii 跳转页面
查看>>
洛谷 1449——后缀表达式(线性数据结构)
查看>>
[最小割][Kruskal] Luogu P5039 最小生成树
查看>>
Data truncation: Out of range value for column 'Quality' at row 1
查看>>
Dirichlet分布深入理解
查看>>
(转)Android之发送短信的两种方式
查看>>
python第九天课程:遇到了金角大王
查看>>