solr实践

来源:互联网 发布:如何开淘宝网店视频 编辑:程序博客网 时间:2024/05/17 22:40

脚本执行:

单机: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+Temperedfq:加速缓存查询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.xmlsolr.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.jarmmseg4j-solr-2.3.0.jarmysql-connector-java-5.1.18-bin.jarsolr-dataimporthandler-5.3.1.jarsolr-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.jar

mvn install:install-file -DgroupId=org.restlet.jee
-DartifactId=org.restlet -Dversion=2.3.0 -Dpackaging=jar -Dfile=org.restlet-2.3.0.jar

mvn 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 -ljstat -gcutil 15611 5000 10jstack 15611
原创粉丝点击