当前位置 : 李杰的流水账 > 技术 > linux

centos安装solr5.1、包括配置

安装solr 1、先检测java [root@solr ~]# which java /usr/bin/java [root@solr ~]# java -version openjdk version "1.8.0_131" OpenJDK Runtime Environment (build 1.8.0_131-b11) OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode) 没安装成功yum install java 2、下载 http://archive.apache.org/dist/lucene/solr/5.3.1/,解压 安装 ./solr-5.1.0/bin/install_solr_service.sh solr-5.1.0.tgz -i /opt -d /service/solr -u solr -d是数据目录,-i是安装目录,一定注意格式 [root@centos_solr www]# service solr status Found 1 Solr nodes: Solr process 26786 running on port 8983 { "solr_home":"/service/solr/data/", "version":"5.1.0 1672403 - timpotter - 2015-04-09 10:37:54", "startTime":"2017-05-22T07:49:44.973Z", "uptime":"0 days, 0 hours, 1 minutes, 2 seconds", "memory":"40.9 MB (%8.3) of 490.7 MB"} 成功 3、 cp /opt/solr-5.1.0/dist/solr-dataimporthandler-5.1.0.jar /opt/solr-5.1.0/server/solr-webapp/webapp/WEB-INF/lib/ cp /opt/solr-5.1.0/dist/solr-dataimporthandler-extras-5.1.0.jar /opt/solr-5.1.0/server/solr-webapp/webapp/WEB-INF/lib/ wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.42.tar.gz 解压 cp mysql-connector-java-5.1.42/mysql-connector-java-5.1.42-bin.jar /opt/solr-5.1.0/server/solr-webapp/webapp/WEB-INF/lib/ 4、[solr@centos_solr www]$ cd /opt/solr/bin/ [solr@centos_solr bin]$ [solr@centos_solr bin]$ ./solr create -c news 打开 http://127.0,0.1:8983/solr/ 可以看到库 cd /service/solr/data/news/conf/ cp managed-schema schema.xml vi solrconfig.xml <!-- <schemaFactory class="ManagedIndexSchemaFactory"> <bool name="mutable">true</bool> <str name="managedSchemaResourceName">managed-schema</str> </schemaFactory> --> <!-- <processor class="solr.AddSchemaFieldsUpdateProcessorFactory"> <str name="defaultFieldType">strings</str> <lst name="typeMapping"> <str name="valueClass">java.lang.Boolean</str> <str name="fieldType">booleans</str> </lst> <lst name="typeMapping"> <str name="valueClass">java.util.Date</str> <str name="fieldType">tdates</str> </lst> <lst name="typeMapping"> <str name="valueClass">java.lang.Long</str> <str name="valueClass">java.lang.Integer</str> <str name="fieldType">tlongs</str> </lst> <lst name="typeMapping"> <str name="valueClass">java.lang.Number</str> <str name="fieldType">tdoubles</str> </lst> </processor> --> <schemaFactory class="ClassicIndexSchemaFactory"/> solrconfig.xml <requestHandler name="/select" class="solr.SearchHandler">前面上加上一个dataimport的处理的Handler <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> <lst name="defaults"> <str name="config">data-config.xml</str> </lst> </requestHandler> data-config.xml <?xml version="1.0" encoding="UTF-8"?> <dataConfig> <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1:3306/cms" user="www" password="123456" /> <document> <entity name="supe_spaceitems" query="select itemid, subject, description,UNIX_TIMESTAMP(updatetime) updatetime from supe_spaceitems where folder=1" deltaImportQuery="select itemid, subject, description,UNIX_TIMESTAMP(updatetime) updatetime from supe_spaceitems where itemid='${dih.delta.itemid}'" deltaQuery="select itemid from supe_spaceitems where updatetime>'${dataimporter.last_index_time}' and folder=1" deletedPkQuery="select itemid from supe_spaceitems where folder != 1"> <field column="itemid" name="itemid"/> <field column="subject" name="subject"/> <field column="description" name="description"/> <field column="updatetime" name="updatetime"/> </entity> </document> </dataConfig> vi schema.xml 修改唯一字段,增加字段 5、增量全量数据方法 http://192.168.1.245:8983/solr/lijie1/dataimport?command=delta-import&clean=false http://192.168.1.245:8983/solr/lijie1/dataimport?command=full-import&clean=true

内容列表