Solr基本命令


啟動Solr

安裝Solr後,進入到Solr主目錄中的bin檔案夾,並使用以下命令啟動Solr。

[Hadoop@localhost ~]$ cd   
[Hadoop@localhost ~]$ cd Solr/ 
[Hadoop@localhost Solr]$ cd bin/ 
[Hadoop@localhost bin]$ ./Solr start

在 Windows 系統中使用以下命令 -

此命令在後台啟動Solr,通過顯示以下訊息監聽埠8983

Waiting up to 30 seconds to see Solr running on port 8983 [\]   
Started Solr server on port 8983 (pid = 6035). Happy searching!

在前台啟動Solr

如果使用start命令啟動Solr,那麼Solr將在後台啟動。然而可以使用-f選項在前台啟動Solr。

[Hadoop@localhost bin]$ ./Solr start –f  

5823 INFO  (coreLoadExecutor-6-thread-2) [   ] o.a.s.c.SolrResourceLoader 
Adding 'file:/home/Hadoop/Solr/contrib/extraction/lib/xmlbeans-2.6.0.jar' to 
classloader 
5823 INFO  (coreLoadExecutor-6-thread-2) [   ] o.a.s.c.SolrResourceLoader 
Adding 'file:/home/Hadoop/Solr/dist/Solr-cell-6.2.0.jar' to classloader 
5823 INFO  (coreLoadExecutor-6-thread-2) [   ] o.a.s.c.SolrResourceLoader 
Adding 'file:/home/Hadoop/Solr/contrib/clustering/lib/carrot2-guava-18.0.jar' 
to classloader 
5823 INFO  (coreLoadExecutor-6-thread-2) [   ] o.a.s.c.SolrResourceLoader 
Adding 'file:/home/Hadoop/Solr/contrib/clustering/lib/attributes-binder1.3.1.jar' 
to classloader 
5823 INFO  (coreLoadExecutor-6-thread-2) [   ] o.a.s.c.SolrResourceLoader 
Adding 'file:/home/Hadoop/Solr/contrib/clustering/lib/simple-xml-2.7.1.jar' 
to classloader 
…………………………………………………………………………………………………………………………………………………………………………………………………………… 
…………………………………………………………………………………………………………………………………………………………………………………………………. 
12901 INFO  (coreLoadExecutor-6-thread-1) [   x:Solr_sample] o.a.s.u.UpdateLog 
Took 24.0ms to seed version buckets with highest version 1546058939881226240 12902 
INFO  (coreLoadExecutor-6-thread-1) [   x:Solr_sample] 
o.a.s.c.CoreContainer registering core: Solr_sample 
12904 INFO  (coreLoadExecutor-6-thread-2) [   x:my_core] o.a.s.u.UpdateLog Took 
16.0ms to seed version buckets with highest version 1546058939894857728 
12904 INFO  (coreLoadExecutor-6-thread-2) [   x:my_core] o.a.s.c.CoreContainer 
registering core: my_core

在另一個埠上啟動Solr

使用start命令的-p選項指定一個啟動埠,可以在另一個埠啟動Solr,如下面的程式碼塊所示。

[Hadoop@localhost bin]$ ./Solr start -p 8081  

Waiting up to 30 seconds to see Solr running on port 8081 [-]   
Started Solr server on port 8081 (pid = 10137). Happy searching!

停止Solr

可以使用stop命令停止Solr,如下範例 -

$ ./Solr stop

此命令停止Solr,顯示訊息如下所示。

Sending stop command to Solr running on port 8983 ... waiting 5 seconds to 
allow Jetty process 6035 to stop gracefully.

重新啟動Solr

Solr的 restart 命令會停止Solr 5秒鐘,然後再次啟動。可以使用以下命令重新啟動Solr -

./Solr restart

此命令重新啟動Solr,顯示以下訊息 -

Sending stop command to Solr running on port 8983 ... waiting 5 seconds to 
allow Jetty process 6671 to stop gracefully. 
Waiting up to 30 seconds to see Solr running on port 8983 [|]  [/]   
Started Solr server on port 8983 (pid = 6906). Happy searching!

Solr ─ help 命令

Solr的help命令可用於檢視Solr提示及其選項的用法。

[Hadoop@localhost bin]$ ./Solr -help  

Usage: Solr COMMAND OPTIONS        
   where COMMAND is one of: start, stop, restart, status, healthcheck, 
create, create_core, create_collection, delete, version, zk  
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

Solr ─ status命令

Solr的 status 命令可用於在計算機上搜尋和找出執行的Solr範例。它可以提供有關Solr範例的資訊,例如它的版本,記憶體使用情況等。

可以使用status命令檢查Solr範例的狀態,如下所示:

[Hadoop@localhost bin]$ ./Solr status

執行時,顯示上述Solr的status命令結果如下 -

Found 1 Solr nodes:   

Solr process 6906 running on port 8983 {   
   "Solr_home":"/home/Hadoop/Solr/server/Solr",   
   "version":"6.2.0 764d0f19151dbff6f5fcd9fc4b2682cf934590c5 - 
   mike - 2016-08-20 05:41:37",   
   "startTime":"2016-09-20T06:00:02.877Z",   
   "uptime":"0 days, 0 hours, 5 minutes, 14 seconds",   
   "memory":"30.6 MB (%6.2) of 490.7 MB"
}

Solr Admin

啟動Apache Solr後,就可以使用以下URL存取Solr Web介面的主頁。

Solr管理員的介面如下 -