sleuth+zipkin+rabbitmq+elasticsearchz整合
版本 spring-boot-starter-parent---------------------1.5.9.RELEASE
1.http+mysql
在zipkin-server项目中引入
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
</dependency>
<!-- zipkin 存储到数据库需要引入此类 -->
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-storage-mysql</artifactId>
</dependency>
<!--保存到数据库需要如下依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.11</version>
</dependency>
application.properties
server.port=17601
spring.application.name=zddk-server-zipkin
spring.sleuth.enabled=false
zipkin.storage.type=mysql
spring.datasource.schema[0]=classpath:/zipkin.sql
spring.datasource.url=jdbc:mysql://localhost:3306/zddk-zipkin?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.initialize=true
spring.datasource.continue-on-error=true
在启动方法上添加@EnableZipkinServer
@SpringBootApplication
//@EnableZipkinStreamServer
@EnableZipkinServer
public class ZddkServerZipkinApplication {
public static void main(String[] args) {
/*args = new String[1];
args[0] = "--spring.profiles.active=zipkin-http";*/
SpringApplication.run(ZddkServerZipkinApplication.class, args);
}
}
在其他服务pom中引入
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
2.rabbitmq+mysql
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
application.properties
server.port=17601
spring.application.name=zddk-server-zipkin
spring.sleuth.enabled=false
zipkin.storage.type=mysql
spring.datasource.schema[0]=classpath:/zipkin.sql
spring.datasource.url=jdbc:mysql://localhost:3306/zddk-zipkin?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.initialize=true
spring.datasource.continue-on-error=true
spring.rabbitmq.host=192.****.***.***
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
在启动方法上添加@EnableZipkinStreamServer
@SpringBootApplication
@EnableZipkinStreamServer
//@EnableZipkinServer
public class ZddkServerZipkinApplication {
public static void main(String[] args) {
/*args = new String[1];
args[0] = "--spring.profiles.active=zipkin-http";*/
SpringApplication.run(ZddkServerZipkinApplication.class, args);
}
}
在其他服务pom中引入
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
3.rabbitmq+elasticsearch
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-server</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin</artifactId>
<version>1.28.1</version>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-storage-elasticsearch- http</artifactId>
<version>1.28.1</version>
</dependency>
application.yml
eureka:
client:
serviceUrl:
defaultZone: http://192.168.1.***:8011/eureka/
server:
port: 9411
spring:
application:
name: zipkin-server
sleuth:
enabled: false
rabbitmq:
host: 192.168.1.***
port: 5672
username: guest
password: guest
# datasource:
# url: jdbc:mysql://localhost:3306/zddk-zipkin?useUnicode=true&characterEncoding=utf8&useSSL=false
# username: root
# password: 123456
# driver-class-name: com.mysql.jdbc.Driver
#zipkin:
#storage:
# type: mysql
zipkin:
storage:
type: elasticsearch
StorageComponent: elasticsearch
elasticsearch:
cluster: elasticsearch
max-requests: 30
index: zipkin
index-shards: 3
index-replicas: 1
hosts: 192.168.1.143:9200
在启动方法上添加@EnableZipkinStreamServer
@SpringBootApplication
@EnableZipkinStreamServer
//@EnableZipkinServer
public class ZddkServerZipkinApplication {
public static void main(String[] args) {
/*args = new String[1];
args[0] = "--spring.profiles.active=zipkin-http";*/
SpringApplication.run(ZddkServerZipkinApplication.class, args);
}
}
在其他服务pom中引入
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>