elasticsearch 安全连接示例


elasticsearch 安全连接示例

************************

单机连接

配置文件

spring:
  elasticsearch:
    rest:
      uris: http://host:port
      username: elastic
      password: 123456

控制台输出

2020-01-22 16:40:34.545  INFO 10952 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-01-22 16:40:34.648  INFO 10952 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-01-22 16:40:34.648  INFO 10952 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1203 ms
2020-01-22 16:40:36.816  WARN 10952 --- [/O dispatcher 1] org.elasticsearch.client.RestClient      : request [PUT http://host:port/person?master_timeout=30s&include_type_name=true&timeout=30s] returned 1 warnings: [299 Elasticsearch-7.5.1-3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96 "[types removal] Using include_type_name in create index requests is deprecated. The parameter will be removed in the next major version."]
2020-01-22 16:40:37.019  WARN 10952 --- [/O dispatcher 1] org.elasticsearch.client.RestClient      : request [PUT http://host:port/person/_mapping/person?master_timeout=30s&include_type_name=true&timeout=30s] returned 1 warnings: [299 Elasticsearch-7.5.1-3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96 "[types removal] Using include_type_name in put mapping requests is deprecated. The parameter will be removed in the next major version."]
2020-01-22 16:40:37.200  INFO 10952 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-01-22 16:40:37.328  INFO 10952 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-01-22 16:40:37.331  INFO 10952 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 4.405 seconds (JVM running for 5.832)

************************

集群连接

配置文件

扫描二维码关注公众号,回复: 8789301 查看本文章
spring:
  elasticsearch:
    rest:
      uris: http://host1:port1,http://host2:port2,http://host3:port3
      username: elastic
      password: 123456

控制台输出

2020-01-22 19:07:16.835  INFO 15860 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-01-22 19:07:16.843  INFO 15860 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-01-22 19:07:16.843  INFO 15860 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.30]
2020-01-22 19:07:16.940  INFO 15860 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-01-22 19:07:16.940  INFO 15860 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1054 ms
2020-01-22 19:07:17.707  WARN 15860 --- [/O dispatcher 2] org.elasticsearch.client.RestClient      : request [PUT http://host3:port3/person/_mapping/person?master_timeout=30s&include_type_name=true&timeout=30s] returned 1 warnings: [299 Elasticsearch-7.5.1-3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96 "[types removal] Using include_type_name in put mapping requests is deprecated. The parameter will be removed in the next major version."]
2020-01-22 19:07:17.876  INFO 15860 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-01-22 19:07:18.027  INFO 15860 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-01-22 19:07:18.031  INFO 15860 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 2.669 seconds (JVM running for 4.186)
发布了320 篇原创文章 · 获赞 91 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_43931625/article/details/104065935