魯春利的工作筆記,好記性不如爛筆頭
Solr is the popular, blazing-fast, open source enterprise search platform built on Apache Lucene.
Lucene官網(wǎng)地址為:http://lucene.apache.org/
Solr官網(wǎng)地址為:http://lucene.apache.org/solr/
Lucene與Solr的最新版本都為5.4.0,這里學(xué)習(xí)時(shí)采用的是5.3.0版本。
說明:Solr解壓后docs目錄為其幫助信息,也可以通過http://wiki.apache.org/solr/查看幫助。
1、解壓
tar -xzv -f solr-5.3.0.tgz # 解壓后目錄結(jié)構(gòu): [hadoop@nnode solr-5.3.0]$ ll 總用量 1160 drwxr-xr-x 3 hadoop hadoop 4096 8月 12 17:16 bin -rw-r--r-- 1 hadoop hadoop 502443 8月 17 18:23 CHANGES.txt drwxr-xr-x 13 hadoop hadoop 4096 8月 17 19:42 contrib drwxrwxr-x 4 hadoop hadoop 4096 1月 21 12:28 dist drwxrwxr-x 19 hadoop hadoop 4096 1月 21 12:28 docs drwxr-xr-x 7 hadoop hadoop 4096 1月 21 12:28 example drwxr-xr-x 2 hadoop hadoop 36864 1月 21 12:28 licenses -rw-r--r-- 1 hadoop hadoop 12646 8月 12 17:16 LICENSE.txt -rw-r--r-- 1 hadoop hadoop 565851 8月 17 18:23 LUCENE_CHANGES.txt -rw-r--r-- 1 hadoop hadoop 26529 8月 12 17:16 NOTICE.txt -rw-r--r-- 1 hadoop hadoop 7167 8月 12 17:16 README.txt drwxr-xr-x 11 hadoop hadoop 4096 1月 21 12:28 server #Solr5開始使用的服務(wù)端程序目錄 [hadoop@nnode solr-5.3.0]$
說明:Solr需要依賴于Jvava,這里使用的jdk版本為1.7。
java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
2、啟動(dòng)Solr
[hadoop@nnode solr-5.3.0]$ bin/solr -V Using Solr root directory: /lucl/solr-5.3.0 Using Java: /lucl/jdk1.7.0_80/bin/java java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode) Solr home directory /lucl/solr-5.3.0 must contain a solr.xml file! [hadoop@nnode solr-5.3.0]$
說明:SOLR_HOME變量暫時(shí)無需配置,否則在通過bin/solr start啟動(dòng)的時(shí)候會(huì)在SOLR_HOME目錄下查找solr.xml文件,而該目錄下是沒有solr.xml文件的。
# 通過如下命令啟動(dòng)solr [hadoop@nnode solr-5.3.0]$ bin/solr start Waiting up to 30 seconds to see Solr running on port 8983 [/] Started Solr server on port 8983 (pid=3608). Happy searching! [hadoop@nnode solr-5.3.0]$
查看Web UI
3、腳本介紹
[hadoop@nnode solr-5.3.0]$ bin/solr -help Usage: solr COMMAND OPTIONS where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete Standalone server example (start Solr running in the background on port 8984): ./solr start -p 8984 SolrCloud example (start Solr running in SolrCloud mode using localhost:2181 to 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 [hadoop@nnode solr-5.3.0]$
說明:Solr有兩種運(yùn)行模式,一個(gè)是單機(jī)模式,一個(gè)是集群模式(即SolrCloud)。
[hadoop@nnode solr-5.3.0]$ bin/solr start -help Usage: solr start [-f] [-c] [-h hostname] [-p port] [-d directory] [-z zkHost] [-m memory] [-e example] [-s solr.solr.home] [-a "additional-options"] [-V] -f Start Solr in foreground; default starts Solr in the background and sends stdout / stderr to solr-PORT-console.log -c or -cloud Start Solr in SolrCloud mode; if -z not supplied, an embedded ZooKeeper instance is started on Solr port+1000, such as 9983 if Solr is bound to 8983 -h <host> Specify the hostname for this Solr instance -p <port> Specify the port to start the Solr HTTP listener on; default is 8983 The specified port (SOLR_PORT) will also be used to determine the stop port STOP_PORT=($SOLR_PORT-1000) and JMX RMI listen port RMI_PORT=(1$SOLR_PORT). For instance, if you set -p 8985, then the STOP_PORT=7985 and RMI_PORT=18985 -d <dir> Specify the Solr server directory; defaults to server -z <zkHost> ZooKeeper connection string; only used when running in SolrCloud mode using -c To launch an embedded ZooKeeper instance, don't pass this parameter. -m <memory> Sets the min (-Xms) and max (-Xmx) heap size for the JVM, such as: -m 4g results in: -Xms4g -Xmx4g; by default, this script sets the heap size to 512m -s <dir> Sets the solr.solr.home system property, the default value is server/solr。 Solr will create core directories under this directory. This allows you to run multiple Solr instances on the same host while reusing the same server directory set using the -d parameter. If set, the specified directory should contain a solr.xml file, unless solr.xml exists in ZooKeeper.This parameter is ignored when running examples (-e), as the solr.solr.home depends on which example is run. -e <example> Name of the example to run; available examples: cloud: SolrCloud example techproducts: Comprehensive example illustrating many of Solr's core capabilities dih: Data Import Handler schemaless: Schema-less example -a Additional parameters to pass to the JVM when starting Solr, such as to setup Java debug options. For example, to enable a Java debugger to attach to the Solr JVM you could pass: -a "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=18983" In most cases, you should wrap the additional parameters in double quotes. -noprompt Don't prompt for input; accept all defaults when running examples that accept user input -V Verbose messages from this script [hadoop@nnode solr-5.3.0]$
4、Start Solr with a Specific Example Configuration
[hadoop@nnode solr-5.3.0]$ bin/solr -f -e techproducts WARNING: Foreground mode (-f) not supported when running examples. Creating Solr home directory /lucl/solr-5.3.0/example/techproducts/solr Starting up Solr on port 8983 using command: bin/solr start -p 8983 -s "example/techproducts/solr" Waiting up to 30 seconds to see Solr running on port 8983 [/] Started Solr server on port 8983 (pid=4436). Happy searching! Setup new core instance directory: /lucl/solr-5.3.0/example/techproducts/solr/techproducts // 略
查看狀態(tài)
[hadoop@nnode solr-5.3.0]$ bin/solr status Found 1 Solr nodes: Solr process 4436 running on port 8983 { "solr_home":"/lucl/solr-5.3.0/example/techproducts/solr/", "version":"5.3.0 1696229 - noble - 2015-08-17 17:10:43", "startTime":"2016-01-24T13:44:41.338Z", "uptime":"0 days, 0 hours, 3 minutes, 3 seconds", "memory":"34.6 MB (%7) of 490.7 MB"} [hadoop@nnode solr-5.3.0]$
5、Web訪問
http://nnode:8983/solr
6、Create a Core
[hadoop@nnode solr-5.3.0]$ bin/solr create -help Usage: solr create [-c name] [-d confdir] [-n configName] [-shards #] [-replicationFactor #] [-p port] Create a core or collection depending on whether Solr is running in standalone (core) or SolrCloud mode (collection). In other words, this action detects which mode Solr is running in, and then takes the appropriate action (either create_core or create_collection). For detailed usage instructions, do: bin/solr create_core -help or bin/solr create_collection -help [hadoop@nnode solr-5.3.0]$
說明:
Core: 也就是Solr Core,一個(gè)Solr中包含一個(gè)或者多個(gè)Solr Core,每個(gè)Solr Core可以獨(dú)立提供索引和查詢功能,每個(gè)Solr Core對(duì)應(yīng)一個(gè)索引或者Collection的Shard,Solr Core的提出是為了增加管理靈活性和共用資源。在SolrCloud中有個(gè)不同點(diǎn)是它使用的配置是在Zookeeper中的,傳統(tǒng)的Solr core的配置文件是在磁盤上的配置目錄中。
Collection:在SolrCloud集群中邏輯 意義上的完整的索引。它常常被劃分為一個(gè)或多個(gè)Shard,它們使用相同的Config Set。如果Shard數(shù)超過一個(gè),它就是分布式索引,SolrCloud讓你通過Collection名稱引用它,而不需要關(guān)心分布式檢索時(shí)需要使用的 和Shard相關(guān)參數(shù)。
Shard: Collection的邏輯分片。每個(gè)Shard被化成一個(gè)或者多個(gè)replicas,通過選舉確定哪個(gè)是Leader。
Replica: Shard的一個(gè)拷貝。每個(gè)Replica存在于Solr的一個(gè)Core中。
[hadoop@nnode solr-5.3.0]$ bin/solr create -c testcore
7、添加數(shù)據(jù)
Solr支持上傳很多種數(shù)據(jù)格式,如CSV、JSON、XML等,選中testcore下面的Documents。
8、數(shù)據(jù)查詢
通過Solr的Web頁面可以執(zhí)行多種條件的數(shù)據(jù)查詢,選中testcore下面的Query。
9、停止服務(wù)
[hadoop@nnode solr-5.3.0]$ bin/solr stop -help Usage: solr stop [-k key] [-p port] [-V] -k <key> Stop key; default is solrrocks -p <port> Specify the port the Solr HTTP listener is bound to -all Find and stop all running Solr servers on this host NOTE: To see if any Solr servers are running, do: solr status [hadoop@nnode solr-5.3.0]$
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
網(wǎng)站標(biāo)題:Solr-5.3.0學(xué)習(xí)筆記(一)基礎(chǔ)入門-創(chuàng)新互聯(lián)
當(dāng)前路徑:http://www.rwnh.cn/article38/dggssp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、外貿(mào)建站、建站公司、網(wǎng)站內(nèi)鏈、搜索引擎優(yōu)化、微信公眾號(hào)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容