首页 > 代码库 > solr5.5集群
solr5.5集群
RHEL 6.4 64位
solr 5.5.2 集群+ zookeeper 3.4.6
1,配置JAVA
1.1
mkdir -p /usr/java
1.2
tar -xzvf jdk-7u79-linux-x64.tar.gz -C /usr/java/
1.3
vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_79
export JRE_HOME=/usr/java/jdk1.7.0_79/jre
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
alias vi="vim"
解压solr5.5.2:
tar -xzvf solr-5.5.2.tgz
解压zookeeper:
tar -xzvf zookeeper-3.4.6.tar.gz
创建solrcloud目录:
mkdir -p /solrcloud/zookeeper/data
mkdir /solrcloud/zookeeper/datalog
将solr和zookeeper解压路径放到/solrcloud下:
cp -r /soft/solr-5.5.2 /solrcloud/node1
cp -r /soft/solr-5.5.2 /solrcloud/node2
cp -r /soft/zookeeper-3.4.6 /solrcloud/zookeeper/zookeeper-3.4.6
修改zookeeper启动参数:
进入zookeeper配置文件路径
cd /solrcloud/zookeeper/zookeeper-3.4.6/conf
将文件zoo_sample.cfg名字改为zoo.cfg
mv zoo_sample.cfg zoo.cfg
修改参数
vi zoo.cfg
======找到这个位置
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
改成:
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/solrcloud/zookeeper/data
dataLogDir=/solrcloud/zookeeper/datalog
# the port at which the clients will connect
然后启动zookeeper:
/solrcloud/zookeeper/zookeeper-3.4.6/bin/zkServer.sh start
启动solr node1
/solrcloud/node1/bin/solr start -p 8983 -c -d server -z 10.40.96.132:2181 -s solr
停止命令:
/solrcloud/node1/bin/solr stop -p 8983
启动solr node2
/solrcloud/node2/bin/solr start -p 9983 -c -d server -z 10.40.96.132:2181 -s solr
停止命令:
/solrcloud/node2/bin/solr stop -p 9983
创建集合:
/solrcloud/node1/bin/solr create_collection -c example -d /solr_test/node1/example/example-DIH/solr/solr/conf/ -shards 2 -replicationFactor 2
-c集合名字
-d配置文件路径
删除集合:
/solrcloud/node1/bin/solr delete -c example
创建全量索引
/usr/bin/curl -G "http://10.1.12.51:8983/solr/core_bingdu/dataimport?command=full-import&clean=true&commit=true" 2&> /dev/null
创建增量索引
/usr/bin/curl -G "http://10.1.12.51:8983/solr/core_bingdu_user/dataimport?command=full-import&clean=true&commit=true" 2&> /dev/null
修改solr的collection配置后上传到zookeeper:
当前solr的collection配置副本存放在opt目录下
[root@mongo-shard1-1 opt]# tree .
.
├── core_bingdu_conf
│ ├── admin-extra.html
│ ├── admin-extra.menu-bottom.html
│ ├── admin-extra.menu-top.html
│ ├── data-config.xml
│ ├── dataimport.properties
│ ├── _rest_managed.json
│ ├── schema.xml
│ └── solrconfig.xml
└── core_bingdu_user_conf
├── admin-extra.html
├── admin-extra.menu-bottom.html
├── admin-extra.menu-top.html
├── data-config.xml
├── dataimport.properties
├── _rest_managed.json
├── schema.xml
└── solrconfig.xml
对以上配置文件进行修改后需要手动上传到zookeeper:
1)整个配置目录上传
cd /solrcloud/node1/server/scripts/cloud-scripts
./zkcli.sh -zkhost 10.40.96.132:2181 -cmd upconfig -confdir /solrcloud/conf -confname ac_words
./zkcli.sh -zkhost 10.40.96.132:2181 -cmd upconfig -confdir /opt/core_bingdu_user_conf -confname core_bingdu_user
2)单文件上传
zkcli.sh -zkhost 10.40.96.132:2181 -cmd putfile /configs/core_bingdu/solrconfig.xml /opt/core_bingdu_conf/solrconfig.xml
zkcli.sh -zkhost 10.40.96.132:2181 -cmd putfile /configs/core_bingdu_user/solrconfig.xml /opt/core_bingdu_user_conf/solrconfig.xml
报错,需配置中文分词器
cp /solrcloud/node1/contrib/analysis-extras/lucene-libs/* /solrcloud/node1/server/solr-webapp/webapp/WEB-INF/lib/
solr5.5集群