Solr和Zookeeper - 3个Z节点,我应该使用哪个节点作为API来搜索请求

n3ipq98p  于 2022-12-09  发布在  Apache
关注(0)|答案(1)|浏览(113)

我一直在开发一个使用SolrCloud的系统,它需要一个Zookeeper集合体来帮助
“管理整个结构,以便索引和搜索请求都能正确路由”
我有3个Z节点。我应该使用哪个节点作为搜索请求API。如果它关闭了怎么办?Zookeeper如何能够将我代码中的IP更改为另一个Z节点?
我知道它不是这样工作的!但我试图找出它。

ivqmmu1c

ivqmmu1c1#

如果你正在使用solr云与zookeeper合奏和连接它使用Java。
您可以使用java代码获得如下连接。

CloudSolrClient solrClient;
     
    @SuppressWarnings("deprecation")
    public CloudSolrClient createConnection(){
        //You need to replace SERVERNAME with the server on which the zookeeper is running
        String zkHostString = "SERVERNAME:PORT,SERVERNAME:PORT,SERVERNAME:PORT"; 
        if(solrClient == null){
            solrClient = new CloudSolrClient.Builder().withZkHost(zkHostString).build();
        }
        return solrClient;
    }

这里你需要传递所有的zookeeper节点,这些节点正在运行以管理你的solr服务器。你也可以为你的应用程序使用springboot,在那里你可以将zk-host配置为application.properties的一部分。

相关问题