简体   繁体   English

使用jaas.conf与Zookeeper进行Spring Solr连接

[英]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.

相关问题 spring 启动 jar 未连接到 Kafka 代理(通过系统变量 java.security.auth.login.config 设置 client_jaas.conf) - spring boot jar not connecting to Kafka brokers ( setting client_jaas.conf through he system variable java.security.auth.login.config) java.net.ConnectException:连接被拒绝:用 Spring boot 连接 Solr - java.net.ConnectException: Connection refused: connect Solr with Spring boot 如何使用Spring cloud zookeeper配置读取子节点 - How to read child nodes using Spring cloud zookeeper configuration Spring cloud zookeeper Config - 为zookeeper设置ACL - Spring cloud zookeeper Config - Set ACL for zookeeper 如何使用 spring-data-solr 为 solr 添加基本身份验证? - How to add basic Auth for solr using spring-data-solr? 在Spring Boot中使用新版本的Spring Data Solr - Using new version of Spring data Solr with Spring boot 使用Spring Boot的Spring Data Connection(二级连接) - Spring Data Connection (two level connection) using spring boot spring kafka如何配置不同kerberos的两个jaas - spring kafka how to configure two jaas of different kerberos 知道何时在Springboot应用程序中失去Zookeeper连接 - Know when Zookeeper connection is lost in a Springboot application 使用Spring Boot在Solr中搜索逗号分隔的列表 - Searching a comma-separated list in Solr using Spring Boot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM