脚本执行:
单机:bin/slor start
修改solr配置文件:vim solr.in.sh
伪分布式zk节点数至少3个集群才能生效
创建集合
自动路由
/bin/solr create_collection -c wish_item -d /Users/zhanxf/hadoop/solr-5.3.1_copy/server/solr/erp_wish_item1/conf -s 2 -rf 1
手动路由
curl http://localhost:8983/solr/admin/collections?action=CREATE&name=wish_item&router.name=implicit&shards=shard1,shard2,shard3,shard4,shard5,shard6&maxShardsPerNode=6
删除节点
curl http://localhost:8983/solr/admin/collections?action=DELETE&name=wish_item
单片搜索
http://localhost:8983/solr/testimplicit_shard1_replica1/select?q=*%3A*&wt=json&indent=true&debugQuery=true&shards=shard2
线上操作(集群环境)
虚拟机内存设置
SOLR_HEAP="12288M"
SOLR_JAVA_MEM="-Xms12288m -Xmx12288m"
SOLR_TIMEZONE="GMT+08:00”
上传宝贝配置文件
sh /data/project/solr-5.3.1/server/scripts/cloud-scripts/zkcli.sh -z zoo6.superboss.cc:30004,zoo5.superboss.cc:30004,zoo4.superboss.cc:30004 -cmd putfile /configs/wish_item/data-config.xml /data/project/wish_item_conf/data-config.xml
上传店铺配置文件
sh /data/project/solr-5.3.1/server/scripts/cloud-scripts/zkcli.sh -z zoo6.superboss.cc:30004,zoo5.superboss.cc:30004,zoo4.superboss.cc:30004 -cmd putfile /configs/wish_merchant/data-config.xml /data/project/wish_merchant_conf/data-config.xml
创建店铺core
sh solr create_collection -c wish_merchant -d /data/project/wish_merchant_conf
创建宝贝core
curl "http://121.41.43.155:30005/solr/admin/collections?action=CREATE&name=wish_item&router.name=implicit&shards=shard1,shard2,shard3,shard4,shard5,shard6&maxShardsPerNode=6”
关联配置文件和core
sh /data/project/solr-5.3.1/server/scripts/cloud-scripts/zkcli.sh -z zoo6.superboss.cc:30004,zoo5.superboss.cc:30004,zoo4.superboss.cc:30004 -cmd linkconfig -collection wish_item -confname wish_item
上传配置文件到zk
sh /data/project/solr-5.3.1/server/scripts/cloud-scripts/zkcli.sh -z zoo6.superboss.cc:30004,zoo5.superboss.cc:30004,zoo4.superboss.cc:30004 -cmd upconfig -confdir /data/project/wish_item_conf -confname wish_item
注意点:
名称搜索空格用+代替: Luxury+Tempered
fq:加速缓存查询
fl:过滤查询字段
[]包含头尾 {}不包含头尾,()用于构成子查询
SOLR安装常见问题
更新zk配置文件(managed-schema|data-config.xml):
./../../../scripts/cloud-scripts/zkcli.sh -z localhost:2181,localhost:2182,localhost:2183 -cmd putfile /configs/wish_item/data-config.xml /Users/zhanxf/hadoop/solr-5.3.1_copy/server/solr/erp_wish_item1/conf/data-config.xml
solr.in.sh集群配置(集群配置jvm配置内存至少1G)
ZK_HOST="localhost:2181,localhost:2182,localhost:2183"
SOLR_JAVA_MEM="-Xms1G -Xmx1G”
导入失败,将附加jar复制到solr-webapp/WEB-INFO/lib目录下
mmseg4j-core-1.10.0.jar
mmseg4j-solr-2.3.0.jar
mysql-connector-java-5.1.18-bin.jar
solr-dataimporthandler-5.3.1.jar
solr-dataimporthandler-extras-5.3.1.jar
编写solr插件问题,编译失败,上传下面2个jar到本地maven
mvn install:install-file -DgroupId=org.apache.solr.handler.dataimport
-DartifactId=solr-dataimporthandler -Dversion=5.3.1 -Dpackaging=jar -Dfile=solr-dataimporthandler-5.3.1.jarmvn install:install-file -DgroupId=org.restlet.jee
-DartifactId=org.restlet -Dversion=2.3.0 -Dpackaging=jar -Dfile=org.restlet-2.3.0.jarmvn install:install-file -DgroupId=org.restlet.jee
-DartifactId=org.restlet.ext.servlet -Dversion=2.3.0 -Dpackaging=jar -Dfile=org.restlet.ext.servlet-2.3.0.jar
问题排查常用命令
grep "concurrent mode failure" solr_gc_log_20170711_* | wc -l
jstat -gcutil 15611 5000 10
jstack 15611