sentinel即哨兵,相比hystrix断路器而言,它的功能更丰富。hystrix仅支持熔断,当服务消费方调用提供方发现异常后,进入熔断;sentinel不仅支持异常熔断,也支持响应超时熔断,另外还支持限流,以及针对网关的熔断和限流。此外,它还有过载处理、监控控制台(Sentinel Dashboard)等。hystrix作为组件集成到微服务中,sentinel也是如此,但它的控制台需要独立部署。
先下载Sentinel Dashboard(下载地址https://github.com/alibaba/Sentinel/releases),目前最新版本是1.6.3,下载到本地(我的是E盘download目录下)后启动jar包:
C:\Users\wulf>e:
E:\>cd download
E:\download>java -jar sentinel-dashboard-1.6.3.jar
INFO: log base dir is: C:\Users\wulf\logs\csp\
INFO: log name use pid is: false
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.5.RELEASE)
2019-08-23 09:08:38.125 INFO 42064 --- [ main] c.a.c.s.dashboard.DashboardApplication : Starting DashboardApplication on wulf00 with PID 42064 (E:\download\sentinel-dashboard-1.6.3.jar started by wulf in E:\download)
2019-08-23 09:08:38.137 INFO 42064 --- [ main] c.a.c.s.dashboard.DashboardApplication : No active profile set, falling back to default profiles: default
2019-08-23 09:08:38.263 INFO 42064 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6c629d6e: startup date [Fri Aug 23 09:08:38 CST 2019]; root of context hierarchy
2019-08-23 09:08:41.446 ERROR 42064 --- [ main] o.a.catalina.core.AprLifecycleListener : An incompatible version [1.2.12] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14]
2019-08-23 09:08:41.787 INFO 42064 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-08-23 09:08:41.817 ERROR 42064 --- [ main] o.a.catalina.core.AprLifecycleListener : An incompatible version [1.2.12] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14]
2019-08-23 09:08:41.859 INFO 42064 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-08-23 09:08:41.861 INFO 42064 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.34
2019-08-23 09:08:41.887 ERROR 42064 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : An incompatible version [1.2.12] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14]
2019-08-23 09:08:42.037 INFO 42064 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-08-23 09:08:42.039 INFO 42064 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3777 ms
2019-08-23 09:08:42.163 INFO 42064 --- [ost-startStop-1] c.a.c.s.dashboard.config.WebConfig : Sentinel servlet CommonFilter registered
2019-08-23 09:08:42.288 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-08-23 09:08:42.291 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-08-23 09:08:42.292 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-08-23 09:08:42.293 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2019-08-23 09:08:42.295 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'authenticationFilter' to urls: [/*]
2019-08-23 09:08:42.296 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'sentinelFilter' to urls: [/*]
2019-08-23 09:08:42.296 INFO 42064 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2019-08-23 09:08:43.660 INFO 42064 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-08-23 09:08:43.930 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6c629d6e: startup date [Fri Aug 23 09:08:38 CST 2019]; root of context hierarchy
2019-08-23 09:08:44.060 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/registry/machine],produces=[application/json]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<?> com.alibaba.csp.sentinel.dashboard.controller.MachineRegistryController.receiveHeartBeat(java.lang.String,java.lang.Integer,java.lang.Long,java.lang.String,java.lang.String,java.lang.String,java.lang.Integer)
2019-08-23 09:08:44.067 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/auth/logout],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result com.alibaba.csp.sentinel.dashboard.controller.AuthController.logout(javax.servlet.http.HttpServletRequest)
2019-08-23 09:08:44.068 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/auth/login],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result com.alibaba.csp.sentinel.dashboard.controller.AuthController.login(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String)
2019-08-23 09:08:44.083 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v1/flow/delete.json],methods=[DELETE]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.lang.Long> com.alibaba.csp.sentinel.dashboard.controller.FlowControllerV1.delete(javax.servlet.http.HttpServletRequest,java.lang.Long)
2019-08-23 09:08:44.084 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v1/flow/rules],methods=[GET]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<java.util.List<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity>> com.alibaba.csp.sentinel.dashboard.controller.FlowControllerV1.apiQueryMachineRules(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String,java.lang.Integer)
2019-08-23 09:08:44.085 INFO 42064 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/v1/flow/rule],methods=[POST]}" onto public com.alibaba.csp.sentinel.dashboard.domain.Result<com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity> com.alibaba.csp.sentinel.dashboard.controller.FlowControllerV1.apiAddFlowRule(javax.servlet.http.HttpServletRequest,com.ali