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

 
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();
}

14 个评论

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嘛

要回复文章请先登录注册