5.1. Zookeeper集群搭建
第一步:需要安装jdk环境。
第二步:把zookeeper的压缩包上传到服务器。
第三步:解压缩。
第四步:把zookeeper复制三份。
[root@localhost ~]# mkdir /usr/local/solr-cloud
[root@localhost ~]# cp -r zookeeper-3.4.6 /usr/local/solr-cloud/zookeeper01
[root@localhost ~]# cp -r zookeeper-3.4.6 /usr/local/solr-cloud/zookeeper02
[root@localhost ~]# cp -r zookeeper-3.4.6 /usr/local/solr-cloud/zookeeper03
第五步:在每个zookeeper目录下创建一个data目录。
第六步:在data目录下创建一个myid文件,文件名就叫做“myid”。内容就是每个实例的id。例如1、2、3
[root@localhost data]# echo 1 >> myid
[root@localhost data]# ll
total 4
-rw-r--r--. 1 root root 2 Apr 7 18:23 myid
[root@localhost data]# cat myid
1
第七步:修改配置文件。把conf目录下的zoo_sample.cfg文件改名为zoo.cfg
server.1=192.168.25.154:2881:3881
server.2=192.168.25.154:2882:3882
server.3=192.168.25.154:2883:3883
第八步:启动每个zookeeper实例。
启动bin/zkServer.sh start
5.2. Solr集群的搭建
第一步:创建四个tomcat实例。每个tomcat运行在不同的端口。8180、8280、8380、8480
第二步:部署solr的war包。把单机版的solr工程复制到集群中的tomcat中。
第三步:为每个solr实例创建一个对应的solrhome。使用单机版的solrhome复制四份。
第四步:需要修改solr的web.xml文件。把solrhome关联起来。
第五步:配置solrCloud相关的配置。每个solrhome下都有一个solr.xml,把其中的ip及端口号配置好。
第六步:让zookeeper统一管理配置文件。需要把solrhome/collection1/conf目录上传到zookeeper。上传任意solrhome中的配置文件即可。
使用工具上传配置文件:/root/solr-4.10.3/example/scripts/cloud-scripts/zkcli.sh
./zkcli.sh -zkhost 192.168.25.154:2181,192.168.25.154:2182,192.168.25.154:2183 -cmd upconfig -confdir /usr/local/solr-cloud/solrhome01/collection1/conf -confname myconf
到了这一步报错
- INFO - 2019-07-30 23:02:51.584; org.apache.zookeeper.ClientCnxn$SendThread; Unable to read additional data from server sessionid 0x16c431cd7700001, likely server has closed socket, closing socket connection and attempting reconnect
- INFO - 2019-07-30 23:02:51.686; org.apache.solr.common.cloud.ConnectionManager; Watcher org.apache.solr.common.cloud.ConnectionManager@162d0b1 name:ZooKeeperConnection Watcher:192.168.25.132:2181,192.168.25.132:2182,192.168.25.132:2183 got event WatchedEvent state:Disconnected type:None path:null path:null type:None
- INFO - 2019-07-30 23:02:51.686; org.apache.solr.common.cloud.ConnectionManager; zkClient has disconnected
- INFO - 2019-07-30 23:02:52.513; org.apache.zookeeper.ClientCnxn$SendThread; Opening socket connection to server 192.168.25.132/192.168.25.132:2183. Will not attempt to authenticate using SASL (unknown error)
- INFO - 2019-07-30 23:02:52.514; org.apache.zookeeper.ClientCnxn$SendThread; Socket connection established to 192.168.25.132/192.168.25.132:2183, initiating session
- INFO - 2019-07-30 23:02:52.515; org.apache.zookeeper.ClientCnxn$SendThread; Session establishment complete on server 192.168.25.132/192.168.25.132:2183, sessionid = 0x16c431cd7700001, negotiated timeout = 30000
- INFO - 2019-07-30 23:02:52.516; org.apache.solr.common.cloud.ConnectionManager; Watcher org.apache.solr.common.cloud.ConnectionManager@162d0b1 name:ZooKeeperConnection Watcher:192.168.25.132:2181,192.168.25.132:2182,192.168.25.132:2183 got event WatchedEvent state:SyncConnected type:None path:null path:null type:None
- WARN - 2019-07-30 23:03:02.200; org.apache.zookeeper.ClientCnxn$SendThread; Session 0x16c431cd7700001 for server 192.168.25.132/192.168.25.132:2183, unexpected error, closing socket connection and attempting reconnect
- java.io.IOException: Broken pipe
- at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
- at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
- at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
- at sun.nio.ch.IOUtil.write(IOUtil.java:65)
- at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487)
- at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:117)
- at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:366)
- at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
- INFO - 2019-07-30 23:03:02.303; org.apache.solr.common.cloud.ConnectionManager; Watcher org.apache.solr.common.cloud.ConnectionManager@162d0b1 name:ZooKeeperConnection Watcher:192.168.25.132:2181,192.168.25.132:2182,192.168.25.132:2183 got event WatchedEvent state:Disconnected type:None path:null path:null type:None
- INFO - 2019-07-30 23:03:02.304; org.apache.solr.common.cloud.ConnectionManager; zkClient has disconnected
- INFO - 2019-07-30 23:03:03.062; org.apache.zookeeper.ZooKeeper; Session: 0x16c431cd7700001 closed
- Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /configs/myconf/dist/solr-core-4.10.3.jar
- at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
- at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
- at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:783)
- at org.apache.solr.common.cloud.SolrZkClient$11.execute(SolrZkClient.java:462)
- at org.apache.solr.common.cloud.ZkCmdExecutor.retryOperation(ZkCmdExecutor.java:74)
- at org.apache.solr.common.cloud.SolrZkClient.makePath(SolrZkClient.java:459)
- at org.apache.solr.common.cloud.SolrZkClient.makePath(SolrZkClient.java:369)
- at org.apache.solr.cloud.ZkController.uploadToZK(ZkController.java:1403)
- at org.apache.solr.cloud.ZkController.uploadToZK(ZkController.java:1405)
- at org.apache.solr.cloud.ZkController.uploadConfigDir(ZkController.java:1440)
- at org.apache.solr.cloud.ZkCLI.main(ZkCLI.java:214)
- INFO - 2019-07-30 23:03:03.063; org.apache.zookeeper.ClientCnxn$EventThread; EventThread shut down
复制代码
P.S. zookeeper已经启动,两个从一个主,防火墙已关闭
求教!!! |
|