增加ZooKeeper命名空间,防止Solr将文件写到ZooKeeper根目录下
①更改Solr的zkHost配置,增加命名空间/solr
-DzkHost="cos6-node1:2181,
cos6-node2:2181,cos6-node3:2181/solr"
②通过zkCli在ZooKeeper中创建/solr节点
在zkCli中执行create /solr "solr"
若节点不存在,会抛出以下异常:
3004 T1 oasc.SolrException.log ERROR null:org.apache.solr.common.cloud.ZooKeeperException: A chroot was specified in ZkHost but the znode doesn't exist.
at org.apache.solr.core.ZkContainer.initZooKeeper(ZkContainer.java:149)
at org.apache.solr.core.ZkContainer.initZooKeeper(ZkContainer.java:67)
at org.apache.solr.core.CoreContainer.load(CoreContainer.java:222)
at org.apache.solr.servlet.SolrDispatchFilter.createCoreContainer(SolrDispatchFilter.java:189)
at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:136)
at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:119)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:719)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1252)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:710)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
at org.eclipse.jetty.server.Server.doStart(Server.java:280)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.apache.solr.client.solrj.StartSolrCloudJettyNode2.main(StartSolrCloudJettyNode2.java:69)
3004 T1 oass.SolrDispatchFilter.init SolrDispatchFilter.init() done
③打开Solr的Web控制台,展开Cloud->Tree菜单进行验证