在docker群集设置中的solr中索引数据时出现问题

时间:2016-12-31 14:14:17

标签: docker solr docker-machine solrcloud

我正在开发POC,我必须为solr设置一个集群环境并检查HA透视图即我们现有的工具。我正在使用docker并使用以下命令来设置

docker network create --subnet 192.168.22.0/24 --ip-range=192.168.22.128/25 netzksolr
#the IP address for the container
ZK1_IP=192.168.22.10
ZK2_IP=192.168.22.11
ZK3_IP=192.168.22.12

# the Docker image
ZK_IMAGE=jplock/zookeeper

docker pull jplock/zookeeper && docker create --ip=$ZK1_IP --net netzksolr --name zk1 --hostname=zk1 --add-host zk2:$ZK2_IP --add-host zk3:$ZK3_IP  -it $ZK_IMAGE
docker pull jplock/zookeeper && docker create --ip=$ZK2_IP --net netzksolr --name zk2 --hostname=zk2 --add-host zk1:$ZK1_IP --add-host zk3:$ZK3_IP  -it $ZK_IMAGE
docker pull jplock/zookeeper && docker create --ip=$ZK3_IP --net netzksolr --name zk3 --hostname=zk3 --add-host zk1:$ZK1_IP --add-host zk2:$ZK2_IP  -it $ZK_IMAGE

docker cp zk1:/opt/zookeeper/conf/zoo.cfg .
cat >>zoo.cfg <<EOM
server.1=zk1:2888:3888
server.2=zk2:2888:3888
server.3=zk3:2888:3888
EOM

docker cp zoo.cfg zk1:/opt/zookeeper/conf/zoo.cfg
docker cp zoo.cfg zk2:/opt/zookeeper/conf/zoo.cfg
docker cp zoo.cfg zk3:/opt/zookeeper/conf/zoo.cfg

echo "1">myid
docker cp myid zk1:/tmp/zookeeper/myid
echo "2">myid
docker cp myid zk2:/tmp/zookeeper/myid
echo "3">myid
docker cp myid zk3:/tmp/zookeeper/myid

docker start zk1;sleep 10
docker start zk2;sleep 10
docker start zk3;sleep 10

docker ps

ZKSOLR1_IP=192.168.22.20
ZKSOLR2_IP=192.168.22.21
ZKSOLR3_IP=192.168.22.22

SOLR_IMAGE=solr
HOST_OPTIONS="--add-host zk1:$ZK1_IP --add-host zk2:$ZK2_IP --add-host zk3:$ZK3_IP "

###setup solr
docker pull $SOLR_IMAGE && docker create --ip=$ZKSOLR1_IP --net netzksolr --name zksolr1 --hostname=zksolr1 -it $HOST_OPTIONS $SOLR_IMAGE
docker pull $SOLR_IMAGE && docker create --ip=$ZKSOLR2_IP --net netzksolr --name zksolr2 --hostname=zksolr2 -it $HOST_OPTIONS $SOLR_IMAGE
docker pull $SOLR_IMAGE && docker create --ip=$ZKSOLR3_IP --net netzksolr --name zksolr3 --hostname=zksolr3 -it $HOST_OPTIONS $SOLR_IMAGE

#create solr.sh file
for h in zksolr1 zksolr2 zksolr3; do
  docker cp zksolr1:/opt/solr/bin/solr.in.sh .
  sed -i -e 's/#ZK_HOST=""/ZK_HOST="zk1:2181,zk2:2181,zk3:2181"/' solr.in.sh
  sed -i -e 's/#*SOLR_HOST=.*/SOLR_HOST="'$h'"/' solr.in.sh
  mv solr.in.sh solr.in.sh-$h
done

docker cp solr.in.sh-zksolr1 zksolr1:/opt/solr/bin/solr.in.sh
docker cp solr.in.sh-zksolr2 zksolr2:/opt/solr/bin/solr.in.sh
docker cp solr.in.sh-zksolr3 zksolr3:/opt/solr/bin/solr.in.sh

###Start docker
docker start zksolr1
docker start zksolr2
docker start zksolr3

docker ps


###Create data directory
docker exec -i zksolr1 /bin/bash -c 'mkdir ./Data'
###Create core
docker exec -i zksolr1 /opt/solr/bin/solr create_collection -c HATest -p 8983 -replicationFactor 2 -shards 2 
###Send data to solr
docker cp data_file.txt zksolr1:/opt/solr/Data/ 
##send schema to zoo keeper
docker exec -i zk1  bin/zkCli.sh -cmd set /configs/HATest/managed-schema "`cat <mylocal location>/managed-schema`"
##validate schema
docker exec -i zk1  bin/zkCli.sh -cmd get /configs/HATest/managed-schema

HOSTPORT="http://zksolr1:8983/solr/HATest"
DATAFILE="/opt/solr/Data/data_file.txt" #This is a file with 80,450 records; columns delimited by ",", and rows by \n
SCHEMA=<contains comma separated names of variables. There are 146 variables in it>

date;docker exec -i zksolr1 /bin/bash -c "curl '$HOSTPORT/update/csv?separator=%7C&fieldnames=$SCHEMA&encapsulator=%05&trim=true' -H 'Content-type:application/csv; charset=utf-8' --data-binary @$DATAFILE";date
docker exec -i zksolr1 /bin/bash -c "curl '$HOSTPORT/update/csv?commit=true'"

索引创建过程似乎永远不会完成。

GURC02RCC74G8WN:Data amada2$ date;docker exec -i zksolr1 /bin/bash -c "curl '$HOSTPORT/update/csv?separator=%7C&fieldnames=$SCHEMA&encapsulator=%05&trim=true' -H 'Content-type:application/csv; charset=utf-8' --data-binary @$DATAFILE";date
Fri Dec 30 23:01:44 IST 2016
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  3 91.4M    0     0    3 3632k      0    659 40:24:28  1:34:00 38:50:28     0^C
Sat Dec 31 00:35:46 IST 2016

查看zksolr1的日志。我看到无休止的警告/错误陈述

2016-12-31 12:59:05.581 ERROR (qtp110456297-16) [c:HATest s:shard1 r:core_node1 x:HATest_shard1_replica2] o.a.s.s.ManagedIndexSchema Bad version when trying to persist schema using 0 due to: org.apache.zookeeper.KeeperException$BadVersionException: KeeperErrorCode = BadVersion for /configs/HATest/managed-schema
2016-12-31 12:59:05.581 INFO  (qtp110456297-16) [c:HATest s:shard1 r:core_node1 x:HATest_shard1_replica2] o.a.s.s.ManagedIndexSchema Failed to persist managed schema at /configs/HATest/managed-schema - version mismatch
2016-12-31 12:59:05.634 ERROR (qtp110456297-16) [c:HATest s:shard1 r:core_node1 x:HATest_shard1_replica2] o.a.s.s.ManagedIndexSchema Bad version when trying to persist schema using 0 due to: org.apache.zookeeper.KeeperException$BadVersionException: KeeperErrorCode = BadVersion for /configs/HATest/managed-schema
2016-12-31 12:59:05.634 INFO  (qtp110456297-16) [c:HATest s:shard1 r:core_node1 x:HATest_shard1_replica2] o.a.s.s.ManagedIndexSchema Failed to persist managed schema at /configs/HATest/managed-schema - version mismatch

我查了一下这个错误并找到了下面的链接,因为它只是一个警告,这个过程应该可以正常工作。然而,虽然索引我的进程全部陷入困境。 https://issues.apache.org/jira/browse/SOLR-8791

我之前认为这可能是我的办公室机器的问题,所以我再试一次我的另一台笔记本电脑,同样的问题。我是新手,如果你能在这方面提供帮助,我将不胜感激。

谢谢, 阿曼

0 个答案:

没有答案