疲劳是最舒适的枕头,努力工作吧。

java客户端连接es5.0(基于xpack安全管理)

Elasticsearch | 作者 novia | 发布于2016年11月25日 | | 阅读数:19916

 
Settings settings = Settings.builder().put("cluster.name", "xxx")
.put("xpack.security.transport.ssl.enabled", false)
.put("xpack.security.user", "xxx:xxx")
.put("client.transport.sniff", true).build();
try {
client = new PreBuiltXPackTransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xxx.xxx.xxx.xxx"), 9300))
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("xxx.xxx.xxx.xxx"), 9300));
} catch (UnknownHostException e) {
e.printStackTrace();
}

[尊重社区原创,转载请保留或注明出处]
本文地址:http://elasticsearch.cn/article/109


19 个评论

java.lang.IllegalArgumentException: unknown setting [xpack.security.transport.ssl.enabled] please check that any required plugins are installed, or check the breaking changes documentation for removed settings
我的是5.0.1,安装了x-pack,采用楼主相同的写法,但是报错,求指导
你访问集群需要密码吗?
需要密码
PreBuiltXPackTransportClient这个来源于哪个jar包,我下了transport包但是没有该类
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>x-pack-transport</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
完美解决问题,谢谢楼主
楼主我还是没法导x-pack-transport啊,它不在elasticsearch5.0.0的Bin里,求问怎么办
啊啊啊我傻了,是lib里面
lib里面有吗?
lib里面有吗?
org.elasticsearch.transport.RemoteTransportException: [1sAwpjC][127.0.0.1:9300][cluster:monitor/nodes/liveness]
Caused by: org.elasticsearch.ElasticsearchSecurityException: unable to authenticate user [transport_client_user] for action [cluster:monitor/nodes/liveness]
at org.elasticsearch.xpack.security.support.Exceptions.authenticationError(Exceptions.java:39) ~[x-pack-api-5.2.2.jar:5.2.2]

请问像这种情况是什么问题
自己蠢了。。。。
已解决,"xpack.security.user","xx:xx"参数理解错误
xpack安全模块 user roles管理 有java的 API嘛
你后面解决了吗,我也没找到
怎么解决的,我找不到PreBuiltXPackTransportClient这个类
2017-11-16 11:29:18 INFO o.e.p.PluginsService - no modules loaded
2017-11-16 11:29:18 INFO o.e.p.PluginsService - loaded plugin [org.elasticsearch.index.reindex.ReindexPlugin]
2017-11-16 11:29:18 INFO o.e.p.PluginsService - loaded plugin [org.elasticsearch.join.ParentJoinPlugin]
2017-11-16 11:29:18 INFO o.e.p.PluginsService - loaded plugin [org.elasticsearch.percolator.PercolatorPlugin]
2017-11-16 11:29:18 INFO o.e.p.PluginsService - loaded plugin [org.elasticsearch.script.mustache.MustachePlugin]
2017-11-16 11:29:18 INFO o.e.p.PluginsService - loaded plugin [org.elasticsearch.transport.Netty4Plugin]
2017-11-16 11:29:18 INFO o.e.p.PluginsService - loaded plugin [org.elasticsearch.xpack.XPackPlugin]
2017-11-16 11:29:20 WARN c.i.a.w.f.AdminAccessInterceptor - java.lang.IllegalStateException: availableProcessors is already set to [8], rejecting [8]
at io.netty.util.NettyRuntime$AvailableProcessorsHolder.setAvailableProcessors(NettyRuntime.java:51)
at io.netty.util.NettyRuntime.setAvailableProcessors(NettyRuntime.java:87)
at org.elasticsearch.transport.netty4.Netty4Utils.setAvailableProcessors(Netty4Utils.java:87)

楼主能帮我解答一下这个问题的原因吗?
提示里 已经表明出错原因里,availableProcessors is already set to [8], rejecting [8] at at io.netty.util.NettyRuntime$AvailableProcessorsHolder.setAvailableProcessors(NettyRuntime.java:51)
说明 NettyRuntime的setAvailableProcessors被调用了二次,第二次被拒绝了

继续看下一条出错提示: at org.elasticsearch.transport.netty4.Netty4Utils.setAvailableProcessors(Netty4Utils.java:87)
貌似在Netty4Utils里源码里你会看到,有个“es.set.netty.runtime.available.processors”配置,当设置为false时,就不会再调用setAvailableProcessors方法了
是不是“用户名:密码”

要回复文章请先登录注册