Solr5.0 Quick Start

Source: Internet
Author: User
Tags solr

One, installation environment
Hardware: Virtual machines
Operating system: Centos 6.4 64-bit
ip:10.51.121.10
Host Name: datanode-4
Installation User: Root
Installation System requirements: You need to install JDK7 or above, recommended jdk7u55 or later version.

Two, install JDK7
Install Jdk7u55 or later. Install jdk1.7.0_75 here.
: http://www.oracle.com/technetwork/java/javase/downloads/index.html
1, download jdk-7u75-linux-x64.tar.gz, execute: #tar -zxvf jdk-7u75-linux-x64.tar.gz
to the/usr/lib directory. The directory after decompression is:/usr/lib/jdk1.7.0_75

2, add the following configuration in/root/.bash_profile:

export JAVA_HOME=/usr/lib/jdk1.7.0_75export PATH=$JAVA_HOME/bin:$PATH

3. Make the environment variable effective #source ~/.bash_profile
4, installation verification # java -version
Java Version "1.7.0_75"
Java (TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot (TM) 64-bit Server VM (build 24.75-b04, Mixed mode)

Third, install SOLR
1, download Solr5.0, download url:http://archive.apache.org/dist/lucene/solr/5.0.0/solr-5.0.0.tgz
2, execute: #tar -zxvf solr-5.0.0.tgz
to the/root/nutch directory. The directory after decompression is:/root/nutch/solr-5.0.0

four. Start the SOLR service
1, enter SOLR's installation directory,/root/nutch/solr-5.0.0
2, execution, #./bin/solr start -e cloud -noprompt
Welcome to the Solrcloud example!
Starting up 2 SOLR nodes for your example Solrcloud cluster.
...
Started SOLR Server on port 8983 (pid=8404). Happy searching!
...
Started SOLR Server on port 7574 (pid=8549). Happy searching!
...
Solrcloud example running, please visit HTTP://LOCALHOST:8983/SOLR

SOLR runs on 2 nodes, one port is 8983 and the other port is 7574. and automatically established a collection called gettingstarted, this collection has 2 shard, each shard has replicas.
3, enter in the browser: http://10.51.121.10:8983/solr/

Four, building the index
Specifies that you need to establish an index data source, which can be HTML, PDF, Microsoft Office files (such as MS Word, Excel), flat files, and so on.
This is an index to the files in the Docs folder under the SOLR installation directory.
1, perform#bin/post -c gettingstarted docs/

#bin/post-c gettingstarted docs/java-classpath/solr-5.0.0/dist/solr-core-5.0.0.jar-dauto=yes-dc=gettingstarted-ddata=Files-drecursive=yes Org.apache.solr.util.SimplePostTool Docs/simpleposttoolVersion5.0.0PostingFilesTo [base] urlhttp://localhost:8983/solr/gettingstarted/update ... Entering Auto mode. File endings considered is xml,json,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,Logentering recursive mode,Max Depth=999, delay=0sIndexingDirectory Docs (3Files, depth=0) POSTingFile Index.html (text/html)to [base]/extractpostingFile quickstart.html (text/html)To [base]/extractposting file system_requirements.html (text/html) to [base]/extractindexing  Directory Docs/changes (1 files, depth=1) POSTing file changes.html (text/html) to [base]/ Extract ... 3254 files indexed. Committing SOLR index changes to http://localhost:8983/solr/gettingstarted/update ... Time spent: 0:27.712 :            

2, indexing the XML file

#bin/post -c gettingstarted example/exampledocs/*.xml

3, indexing the JSON file

#bin/post -c gettingstarted example/exampledocs/*.json

4. Indexing a CSV file

#bin/post -c gettingstarted example/exampledocs/books.csv

Five, search
SOLR can access the search through the rest client, the Curl command, the wget command, and so on.
1, enter HTTP://10.51.121.10:8983/SOLR, select GETTINGSTARTED_SHARD1_REPLICA2, click Query Tab, enter "SOLR" in the Q input field, then click "Execute Query button, you can find the file with SOLR content.

2, accessed with curl in the Linux shell, for example:

# curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=foundation"
# curl "http://localhost:8983/solr/gettingstarted/Select?wt=json&indent=True&q=foundation"{" Responseheader": {" status": 0," Qtime":", "params": {" indent":"True"," Q": "Json ": 3105," start ": 0," Maxscorewith some utf-8 encoded Characters"], "Manu": ["Apache Software Foundation ": [" Software "," Search           

3, visit Http://10.51.121.10:8983/solr/gettingstarted/browse.

Six, common commands
The 1,SOLR command has start, stop, restart, status, Healthcheck, create, Create_core, Create_collection, delete.

#./BIN/SOLRUSAGE:SOLR command OPTIONS where command is one of:Start, stop, restart, status, Healthcheck,Create, Create_core, Create_collection,Delete Standalone Server Example (Start SOLR RunningIn the backgroundOn port8984):./SOLRStart-p8984 Solrcloud Example (Start SOLR RunningIn Solrcloud modeUsing localhost:2181to connect to ZooKeeper, with 1g max heap size and remote Java Debug options enabled):./SOLR start-c-M 1g-z localhost:2181-a "-xdebug-xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044 "Pass-help after any COMMAND to See command-specific usage information, such as:./SOLR start -help or./SOLR stop-help         

2,healthcheck command

[Root@datanode-4 solr-5.0.0]# BIN/SOLR Healthcheck-c gettingstarted{"Collection":"GettingStarted","Status":"Healthy","Numdocs":3296,"Numshards":2,"Shards": [{"Shard":"Shard1","Status":"Healthy","Replicas": [{"Name":"Core_node2","url":"Http://10.51.121.10:8983/solr/gettingstarted_shard1_replica2/","Numdocs":1633,"Status":"Active","Uptime":"0 days, 0 hours, minutes, 6 seconds","Memory":"36.9 MB (%7.5) of 490.7 MB "}, {"Name":"Core_node4","url":"Http://10.51.121.10:7574/solr/gettingstarted_shard1_replica1/","Numdocs":1633,"Status":"Active","Uptime":"0 days, 0 hours, minutes, seconds","Memory":"83.2 MB (%17) of 490.7 MB ","Leader": True}]}, {"Shard":"Shard2","Status":"Healthy","Replicas": [{"Name":"Core_node1","url":"Http://10.51.121.10:8983/solr/gettingstarted_shard2_replica2/","Numdocs":1663,"Status":"Active","uptime":"0 days, 0 hours, minutes, 6 seconds", "Memory":"37.1 mb (%7.6) of 490.7 MB"}, { "name ":" Core_node3 ", " url ":" http://10.51.121.10:7574/solr/gettingstarted_shard2_replica1/", " Numdocs " :1663, "status":"active", "uptime":"0 days, 0 hours, minutes, seconds", "Memory": c16> "83.3 mb (%17) of 490.7 MB", "leader": True}]}]}        

Solr5.0 Quick Start

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.