java连接zookeeper集群报错

最近做了个基于solr的检索项目,原系统部署是基于Windows系统三个solr节点,一个zookeeper调度管理,现在需要将Windows的检索迁移到hadoop的集群中

集群采用11+2的模式,solr索引数据存放在hdfs上的,整套集群是cdh5.8.3版本,11个solr节点,5个zookeeper,这下和原来的连接完全不同,有点傻眼,就开始各种资料各种尝试最后终于可以将系统迁移过来了,而且测试可以正常访问了,本以为就可以正常创建solr的索引信息,有一天下午同事正在建立映射信息创建core,不知为何提交不上去,报无法 创建collection具体错误忘了,重启了solr集群,solr集群起来2分钟,就报错了,后来找到原因了是因为solr中的需要改个参数,具体可以看上篇文章。集群处理过程中误操作删除了一个节点的服务器配置信息导致服务器系统无法正常启动,重新安装系统重新配置,配置完成后这台新装的服务器solr服务正常,但是不能创建节点信息,创建时报错

9月 7, 晚上8点34:01.291 INFO org.apache.solr.servlet.SolrDispatchFilter
[admin] webapp=null path=/admin/cores params={indexInfo=false&_=1504787528419&wt=json} status=0 QTime=0 
9月 7, 晚上8点34:01.541 INFO org.apache.solr.servlet.SolrDispatchFilter
[admin] webapp=null path=/admin/info/system params={_=1504787528659&wt=json} status=0 QTime=6 
9月 7, 晚上8点34:02.526 INFO org.apache.solr.common.cloud.ZkStateReader
A cluster state change: WatchedEvent state:SyncConnected type:NodeDataChanged path:/clusterstate.json, has occurred - updating... (live nodes size: 11)
9月 7, 晚上8点34:03.228 INFO org.apache.solr.cloud.DistributedQueue
NodeDataChanged fired on path /overseer/collection-queue-work/qnr-0000005310 state SyncConnected
9月 7, 晚上8点34:03.280 INFO org.apache.solr.servlet.SolrDispatchFilter
[admin] webapp=null path=/admin/collections params={numShards=5&collection.configName=clusterconf&maxShardsPerNode=3&name=test&replicationFactor=3&action=CREATE} status=500 QTime=30265 
9月 7, 晚上8点34:03.283 ERROR org.apache.solr.servlet.SolrDispatchFilter
null:org.apache.solr.common.SolrException: Could not fully createcollection: test
at org.apache.solr.handler.admin.CollectionsHandler.handleResponse(CollectionsHandler.java:361)
at org.apache.solr.handler.admin.CollectionsHandler.handleResponse(CollectionsHandler.java:317)
at org.apache.solr.handler.admin.CollectionsHandler.handleCreateAction(CollectionsHandler.java:483)
at org.apache.solr.handler.admin.CollectionsHandler.handleRequestBody(CollectionsHandler.java:154)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
at org.apache.solr.servlet.SolrDispatchFilter.handleAdminRequest(SolrDispatchFilter.java:871)
at org.apache.solr.servlet.SolrDispatchFilter.httpSolrCall(SolrDispatchFilter.java:323)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:260)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:255)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.solr.servlet.SolrHadoopAuthenticationFilter$2.doFilter(SolrHadoopAuthenticationFilter.java:408)
at org.apache.hadoop.security.authentication.server.AuthenticationFilter.doFilter(AuthenticationFilter.java:622)
at org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticationFilter.doFilter(DelegationTokenAuthenticationFilter.java:301)
at org.apache.hadoop.security.authentication.server.AuthenticationFilter.doFilter(AuthenticationFilter.java:574)
at org.apache.solr.servlet.SolrHadoopAuthenticationFilter.doFilter(SolrHadoopAuthenticationFilter.java:413)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.solr.servlet.HostnameFilter.doFilter(HostnameFilter.java:86)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:745)


最后经过大神处理比较,这台新装的solr,缺少jar包,dataimport开头的jar总共有4个。可以在其他集群中获取到,将jar补齐后重启了服务就可以正常访问了


在处理这个问题过程中引发了zookeeper无法正常访问的问题,连接时提示报错

Opening socket connection to server datanode1/192.168.126.83:2181. Will not attempt to authenticate using SASL (unknown error)
Socket connection established, initiating session, client: /10.49.78.69:57987, server: datanode1/192.168.126.83:2181
Session establishment complete on server datanode1/192.168.126.83:2181, sessionid = 0xb5e5e9af60b00b0, negotiated timeout = 40000
Watcher org.apache.solr.common.cloud.ConnectionManager@5a9b3751 name:ZooKeeperConnection Watcher:192.168.126.83:2181,192.168.126.84:2181,192.168.126.85:2181,192.168.126.86:2181,192.168.126.87:2181 got event WatchedEvent state:SyncConnected type:None path:null path:null type:None
Client is connected to ZooKeeper
Updating cluster state from ZooKeeper... 
org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /live_nodes
at org.apache.zookeeper.KeeperException.create(KeeperException.java:111)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1468)
at org.apache.solr.common.cloud.SolrZkClient$6.execute(SolrZkClient.java:235)
at org.apache.solr.common.cloud.SolrZkClient$6.execute(SolrZkClient.java:1)
at org.apache.solr.common.cloud.ZkCmdExecutor.retryOperation(ZkCmdExecutor.java:65)
at org.apache.solr.common.cloud.SolrZkClient.getChildren(SolrZkClient.java:232)
at org.apache.solr.common.cloud.ZkStateReader.createClusterStateWatchersAndUpdate(ZkStateReader.java:248)
at org.apache.solr.client.solrj.impl.CloudSolrServer.connect(CloudSolrServer.java:231)
at com.asideal.util.CloudSingleton.getNormalInstance(CloudSingleton.java:53)
at com.asideal.quartz.job.IndexJobAction.execute(IndexJobAction.java:110)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Job DEFAULT.V_JN_XCKY_SCENE_TOOLS_J threw an unhandled Exception: 
org.apache.solr.common.cloud.ZooKeeperException: 
at org.apache.solr.client.solrj.impl.CloudSolrServer.connect(CloudSolrServer.java:239)
at com.asideal.util.CloudSingleton.getNormalInstance(CloudSingleton.java:53)
at com.asideal.quartz.job.IndexJobAction.execute(IndexJobAction.java:110)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /live_nodes
at org.apache.zookeeper.KeeperException.create(KeeperException.java:111)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1468)
at org.apache.solr.common.cloud.SolrZkClient$6.execute(SolrZkClient.java:235)
at org.apache.solr.common.cloud.SolrZkClient$6.execute(SolrZkClient.java:1)
at org.apache.solr.common.cloud.ZkCmdExecutor.retryOperation(ZkCmdExecutor.java:65)
at org.apache.solr.common.cloud.SolrZkClient.getChildren(SolrZkClient.java:232)
at org.apache.solr.common.cloud.ZkStateReader.createClusterStateWatchersAndUpdate(ZkStateReader.java:248)
at org.apache.solr.client.solrj.impl.CloudSolrServer.connect(CloudSolrServer.java:231)
... 4 more
Job (DEFAULT.V_JN_XCKY_SCENE_TOOLS_J threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: org.apache.solr.common.cloud.ZooKeeperException: ]
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: org.apache.solr.common.cloud.ZooKeeperException: 
at org.apache.solr.client.solrj.impl.CloudSolrServer.connect(CloudSolrServer.java:239)
at com.asideal.util.CloudSingleton.getNormalInstance(CloudSingleton.java:53)
at com.asideal.quartz.job.IndexJobAction.execute(IndexJobAction.java:110)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
... 1 more
Caused by: org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /live_nodes
at org.apache.zookeeper.KeeperException.create(KeeperException.java:111)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1468)
at org.apache.solr.common.cloud.SolrZkClient$6.execute(SolrZkClient.java:235)
at org.apache.solr.common.cloud.SolrZkClient$6.execute(SolrZkClient.java:1)
at org.apache.solr.common.cloud.ZkCmdExecutor.retryOperation(ZkCmdExecutor.java:65)
at org.apache.solr.common.cloud.SolrZkClient.getChildren(SolrZkClient.java:232)
at org.apache.solr.common.cloud.ZkStateReader.createClusterStateWatchersAndUpdate(ZkStateReader.java:248)
at org.apache.solr.client.solrj.impl.CloudSolrServer.connect(CloudSolrServer.java:231)
... 4 more

这个原因也被大神找到因为我在建立zk连接时报错

String zkHost="192.168.126.83:2181,192.168.126.84:2181,192.168.126.85:2181,192.168.126.86:2181,192.168.126.87:2181/solr";

CloudSolrServer serverInstance=new CloudSolrServer(zkHost);

serverInstance.setDefaultCollection("testCollection");

serverInstance.setZkClientTimeout(30000);

serverInstance.setZkConnectTimeout(10000);

serverInstance.connect();

上面红的是错误的根源,以后集群连接时可得注意,掉坑里两天了。

再抽取数据solr创建索引时如果创建collection时报错记得重启solr集群,重新创建。如果创建字段找不到说明配置文件上传有问题


你可能感兴趣的:(solr,hadoop)