Install Solr5.3 in CentOS

Source: Internet
Author: User

Install Solr5.3 in CentOS

Preface

Solr is now an independent server.

From Solr5.0, Solr is no longer released as a "war" Web Application package (Web Application Archive) deployed in any Servlet container ). Solr is now deployed as an independent java Server application, including startup and stop scripts that can be used on Unix and Windows platforms, and install Solr as a service to/etc/init. d.

In essence, Solr is still implemented with Servlet APIs and runs on Jetty, but only as an implementation. Deploying a "webapp" to other Servlet containers (or other Jetty instances) is not supported and may not work in future Solr 5.x versions. However, other changes to Solr may occur. In fact, it uses the custom network protocol stack function.

Install JRE

  1. Java Runtime Environment (JRE) 1.7 or later is required for verification first.

    # Java-version

  2. For installation instructions, refer to install JDK 8 under CentOS, including JRE.

Install Solr5.3

  1. Go to renewal.

  2. Put the solr-5.3.0.tgz file in the/tmp directory and execute the following script:

    #cd/tmp# Tar-zxvfsolr-5.3.0.tgz // decompress the package
  3. Create an application and data directory

    #mkdir-p/data/solr/usr/local/solr
  4. Create a user running solr and grant permissions

    #groupaddsolr#useradd-gsolrsolr#chown-Rsolr.solr/data/solr/usr/local/solr
  5. Install the solr Service

    #solr-5.3.0/bin/install_solr_service.shsolr-5.3.0.tgz-d/data/solr-i/usr/local/solr
  6. Check service status

    #servicesolrstatus

    The following output is displayed:

    Solrprocess29692runningonport8983{"solr_home":"/data/solr/data/","version":"5.3.01696229-noble-2015-08-1717:10:43","startTime":"2015-09-16T01:32:03.919Z","uptime":"0days,0hours,3minutes,6seconds","memory":"89.8MB(%18.3)of490.7MB"}

Solr command usage

  1. Go to solr application directory

    #cd/usr/local/solr/solr

  2. View solr Command Options

    #./bin/solr
Usage:solrCOMMANDOPTIONSwhereCOMMANDisoneof:start,stop,restart,status,healthcheck,create,create_core,create_collection,deleteStandaloneserverexample(startSolrrunninginthebackgroundonport8984):./solrstart-p8984SolrCloudexample(startSolrrunninginSolrCloudmodeusinglocalhost:2181toconnecttoZooKeeper,with1gmaxheapsizeandremoteJavadebugoptionsenabled):./solrstart-c-m1g-zlocalhost:2181-a"-Xdebug-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044"Pass-helpafteranyCOMMANDtoseecommand-specificusageinformation,suchas:./solrstart-helpor./solrstop-help#./bin/solrstart-helpUsage:solrstart[-f][-c][-hhostname][-pport][-ddirectory][-zzkHost][-mmemory][-eexample][-ssolr.solr.home][-a"additional-options"][-V]-fStartSolrinforeground;defaultstartsSolrinthebackgroundandsendsstdout/stderrtosolr-PORT-console.log-cor-cloudStartSolrinSolrCloudmode;if-znotsupplied,anembeddedZooKeeperinstanceisstartedonSolrport+1000,suchas9983ifSolrisboundto8983-h-p<port>SpecifytheporttostarttheSolrHTTPlisteneron;defaultis8983Thespecifiedport(SOLR_PORT)willalsobeusedtodeterminethestopportSTOP_PORT=($SOLR_PORT-1000)andJMXRMIlistenportRMI_PORT=(1$SOLR_PORT).Forinstance,ifyouset-p8985,thentheSTOP_PORT=7985andRMI_PORT=18985-d<dir>SpecifytheSolrserverdirectory;defaultstoserver-z<zkHost>ZooKeeperconnectionstring;onlyusedwhenrunninginSolrCloudmodeusing-cTolaunchanembeddedZooKeeperinstance,don'tpassthisparameter.-m<memory>Setsthemin(-Xms)andmax(-Xmx)heapsizefortheJVM,suchas:-m4gresultsin:-Xms4g-Xmx4g;bydefault,thisscriptsetstheheapsizeto512m-s<dir>Setsthesolr.solr.homesystemproperty;Solrwillcreatecoredirectoriesunderthisdirectory.ThisallowsyoutorunmultipleSolrinstancesonthesamehostwhilereusingthesameserverdirectorysetusingthe-dparameter.Ifset,thespecifieddirectoryshouldcontainasolr.xmlfile,unlesssolr.xmlexistsinZooKeeper.Thisparameterisignoredwhenrunningexamples(-e),asthesolr.solr.homedependsonwhichexampleisrun.Thedefaultvalueisserver/solr.-e<example>Nameoftheexampletorun;availableexamples:cloud:SolrCloudexampletechproducts:ComprehensiveexampleillustratingmanyofSolr'scorecapabilitiesdih:DataImportHandlerschemaless:Schema-lessexample-aAdditionalparameterstopasstotheJVMwhenstartingSolr,suchastosetupJavadebugoptions.Forexample,toenableaJavadebuggertoattachtotheSolrJVMyoucouldpass:-a"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=18983"Inmostcases,youshouldwraptheadditionalparametersindoublequotes.-nopromptDon'tpromptforinput;acceptalldefaultswhenrunningexamplesthatacceptuserinput-VVerbosemessagesfromthisscript#./bin/solrcreate-helpUsage:solrcreate[-cname][-dconfdir][-nconfigName][-shards#][-replicationFactor#][-pport]CreateacoreorcollectiondependingonwhetherSolrisrunninginstandalone(core)orSolrCloudmode(collection).Inotherwords,thisactiondetectswhichmodeSolrisrunningin,andthentakestheappropriateaction(eithercreate_coreorcreate_collection).Fordetailedusageinstructions,do:bin/solrcreate_core-helporbin/solrcreate_collection–help

Installation of solr service scripts

  1. Run the installation script

    #/tmp/solr-5.3.0/bin/install_solr_service.sh
ERROR:MustspecifythepathtotheSolrinstallationarchive,suchassolr-5.0.0.tgzUsage:install_solr_service.shpath_to_solr_distribution_archiveOPTIONSThefirstargumenttothescriptmustbeapathtoaSolrdistributionarchive,suchassolr-5.0.0.tgz(only.tgzor.ziparesupportedformatsforthearchive)SupportedOPTIONSinclude:-dDirectoryforlive/writableSolrfiles,suchaslogs,pidfiles,andindexdata;defaultsto/var/solr-iDirectorytoextracttheSolrinstallationarchive;defaultsto/opt/Thespecifiedpathmustexistpriortousingthisscript.-pPortSolrshouldbindto;defaultis8983-sServicename;defaultstosolr-uUsertoowntheSolrfilesandruntheSolrprocessas;defaultstosolrThisscriptwillcreatethespecifieduseraccountifitdoesnotexist.NOTE:Mustberunastherootuser

Create a set

In this section, we create a simple Solr set.

Solr can have multiple sets, but in this example, we only use one. Run the following command to create a new set. We run with solr users to avoid any permission errors.

#su-solr-c"/usr/local/solr/solr/bin/solrcreate-cgettingstarted-ndata_driven_schema_configs"

In this command, gettingstarted is the set name, and-n specifies the configuration set. Solr provides three configuration sets by default. Here we use schemaless, which means that any column with any name can be provided, and the type will be guessed.

Setupnewcoreinstancedirectory:/data/solr/data/gettingstartedCreatingnewcore'gettingstarted'usingcommand:http://localhost:8983/solr/admin/cores?action=CREATE&name=gettingstarted&instanceDir=gettingstarted{"responseHeader":{"status":0,"QTime":3247},"core":"gettingstarted"}


You have created a collection and can add data. The default architecture only needs to provide one column: id. No other default columns, only dynamic columns.

Add and query documents

In this section, we will browse the Solr Web interface and add some documents to the collection.

If you access http: // your_server_ip: 8983/solr using a Web browser, the Solr Web interface will be displayed:

This Web Interface contains a large amount of useful information and can be used to debug any problems arising during use.

The set is divided into cores, which is why there are a lot of references to the core in the Web interface. Currently, gettingstarted only contains one core, named gettingstarted. On the left side, you can see the "Core Selector" drop-down menu. You can select gettingstarted to view more information.

After selecting the gettingstarted core, select "events ". Files store real data that can be searched by Solr. Because we use a stateless configuration, we can use any column. I added a single document using the following JSON example and copied the following to the "Documents (s)" column:

{"number":1,"president":"GeorgeWashington","birth_year":1732,"death_year":1799,"took_office":"1789-04-30","left_office":"1797-03-04","party":"NoParty"}

Click "Submit document" to add the document to the index. After a while, you will see the following information:

Output after adding a document:

Status:successResponse:{"responseHeader":{"status":0,"QTime":290}}

You can use a similar or totally different structure to add more documents, but you can also use only one document to continue.

Now, select "Query" on the left to Query the document we just added. Keep the default value on the screen. After you click "Execute Query", you can view up to 10 documents, depending on how much you have added:

Query output

{"responseHeader":{"status":0,"QTime":39,"params":{"q":"*:*","indent":"true","wt":"json","_":"1442371884598"}},"response":{"numFound":1,"start":0,"docs":[{"number":[1],"president":["GeorgeWashington"],"birth_year":[1732],"death_year":[1799],"took_office":["1789-04-30T00:00:00Z"],"left_office":["1797-03-04T00:00:00Z"],"party":["NoParty"],"id":"b9b294c1-4b68-4d96-adc2-f6fb77f60932","_version_":1512437472611532800}]}}


Reference: http://lucene.apache.org/solr/quickstart.html

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.