CentOS下安裝Solr5.4 自帶服務安裝
-
需要Java Runtime Environment(JRE) 1.7或更高版本,先驗證。
# java -version
-
安裝可參考《在CentOS下安裝JDK8》,包含JRE。
-
去http://www.apache.org/dyn/closer.lua/lucene/solr/5.4.0下載Solr安裝檔案solr-5.4.0.tgz。
-
將solr-5.4.0.tgz檔案放到/tmp目錄下,執行如下指令碼:
# cd /tmp
# tar -zxvf solr-5.4.0.tgz // 解壓壓縮包
-
建立應用程式和資料目錄
# mkdir -p /data/solr /usr/local/solr
-
建立執行solr的使用者並賦權
# groupadd solr
# useradd -g solr solr
# chown -R solr.solr /data/solr /usr/local/solr
-
安裝solr服務
# solr-5.4.0/bin/install_solr_service.sh solr-5.4.0.tgz -d /data/solr -i /usr/local/solr
Extracting solr-5.4.0.tgz to /usr/local/solr5 Installing symlink /usr/local/solr5/solr -> /usr/local/solr5/solr-5.4.0 ... Installing /etc/init.d/solr script ... Installing /etc/default/solr.in.sh ... Waiting up to 30 seconds to see Solr running on port 8983 [/] Started Solr server on port 8983 (pid=17112). Happy searching! Found 1 Solr nodes: Solr process 17112 running on port 8983 { "solr_home":"/usr/local/solr5/data/data", "version":"5.4.0 1718046 - upayavira - 2015-12-04 23:16:46", "startTime":"2016-01-06T04:04:15.906Z", "uptime":"0 days, 0 hours, 0 minutes, 21 seconds", "memory":"60.4 MB (%12.3) of 490.7 MB"} Service solr installed.
6.檢查服務狀態
# service solr status
|
將會看到如下輸出:
Solr process 29692 running on port 8983
{
"solr_home":"/data/solr/data/",
"version":"5.3.0 1696229 - noble - 2015-08-17 17:10:43",
"startTime":"2015-09-16T01:32:03.919Z",
"uptime":"0 days, 0 hours, 3 minutes, 6 seconds",
"memory":"89.8 MB (%18.3) of 490.7 MB"}
|
# service solr restart
-
定位到solr應用程式目錄
# cd /usr/local/solr/solr
-
檢視solr命令選項
# ./bin/solr
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
|
# ./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; 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. The default value is server/solr.
-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
|