[英]Spring Solr connection with Zookeeper using jaas.conf
I am migrating an existing java project to Spring Boot. 我正在将现有的Java项目迁移到Spring Boot。 It connects to Solr via Zookeeper.
它通过Zookeeper连接到Solr。
It is throwing following error on startup. 它在启动时引发以下错误。
org.apache.zookeeper.KeeperException$NoAuthException: KeeperErrorCode = NoAuth for /clusterstate.json
This following configuration works on local, but on other environments Zookeeper requires some authentication (jaas.conf). 以下配置可在本地使用,但在其他环境中,Zookeeper需要进行一些身份验证(jaas.conf)。 How do I pass the jaas.conf to Spring Boot such that it can initialize SolrClient correctly?
如何将jaas.conf传递给Spring Boot,以便它可以正确初始化SolrClient?
@Configuration
@EnableSolrRepositories(basePackages = "com.search", multicoreSupport = true)
public class SolrConfig {
@Value("${spring.data.solr.zk-host}")
private String zkHost;
@Bean
public SolrClient solrClient() {
return new CloudSolrClient(zkHost);
}
@Bean
public SolrTemplate solrTemplate(SolrClient solrClient) throws Exception {
return new SolrTemplate(solrClient);
}
}
jaas.conf 的Jaas.conf
Client {
org.apache.zookeeper.server.auth.DigestLoginModule required
username="some_username"
password="some_password";
};
I tried passing credentials as environment properties of zkDigestUsername and zkDigestPassword. 我尝试将凭据作为zkDigestUsername和zkDigestPassword的环境属性进行传递。 In this case there was no exception during Spring Boot startup, but subsequent inserts/reads to Solr is not working.
在这种情况下,在Spring Boot启动期间也不例外,但是随后对Solr的插入/读取不起作用。
Any help would be appreciated. 任何帮助,将不胜感激。 Thanks much!
非常感谢!
通过使用以下JVM参数提供jaas配置,我能够解决此问题。
-Djava.security.auth.login.config=/etc/zookeeper/conf/jaas.conf
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.