尝试从启用了kerberos的Datastax java驱动程序连接到cassandra安全集群。
示例连接代码:
cluster = Cluster.builder().addContactPoint(node).withCredentials("username","password").build();
Metadata metadata = cluster.getMetadata();
System.out.printf("Connected to cluster: %s\n",
metadata.getClusterName());
for (Host host : metadata.getAllHosts()) {
System.out.printf("Datatacenter: %s; Host: %s; Rack: %s\n",
host.getDatacenter(), host.getAddress(), host.getRack());
}
session = cluster.connect();
我收到以下错误:
线程“main”中的异常com.datastax.driver.core.exceptions.AuthenticationException:host / xxxx上的身份验证错误:java.lang.RuntimeException:javax.security.auth.login.LoginException:无法从用户获取密码
at com.datastax.driver.core.Connection.waitForSaslCompletion(Connection.java:204)
at com.datastax.driver.core.Connection.initializeTransport(Connection.java:170)
at com.datastax.driver.core.Connection.<init>(Connection.java:132)
at com.datastax.driver.core.Connection.<init>(Connection.java:59)
at com.datastax.driver.core.Connection$Factory.open(Connection.java:442)
at com.datastax.driver.core.ControlConnection.tryConnect(ControlConnection.java:205)
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:168)
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:81)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:662)
at com.datastax.driver.core.Cluster$Manager.access$100(Cluster.java:604)
at com.datastax.driver.core.Cluster.<init>(Cluster.java:69)
at com.datastax.driver.core.Cluster.buildFrom(Cluster.java:96)
at com.datastax.driver.core.Cluster$Builder.build(Cluster.java:585)
at com.datastax.training.SimpleClient.connect(SimpleClient.java:32)
at com.datastax.training.SimpleClient.main(SimpleClient.java:148)
使用的是DSE 3.1.3版。 Java驱动程序1.0.3-dse。
答案 0 :(得分:1)
在您的代码示例中,您使用用户名/密码凭据进行身份验证,这对Kerberos无效。此博客文章包含有关将Java驱动程序与安全DSE群集一起使用的详细信息:http://www.datastax.com/dev/blog/accessing-secure-dse-clusters-with-cql-native-protocol