In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Preface
Solr is now a stand-alone server.
Starting with 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 a stand-alone java server application with start and stop scripts that can be used on Unix and Windows platforms, as well as installation scripts that install Solr as a service under / etc/init.d on a Unix-like platform.
In essence, Solr is still implemented in Servlet APIs and runs on Jetty, but only as an implementation. Deployment as "webapp" to other Servlet containers (or other Jetty instances) is not supported and may not work in future versions of Solr 5.x. It may bring other changes to Solr, in fact, taking advantage of custom network protocol stack functionality.
Install JRE
Java Runtime Environment (JRE) 1.7 or later is required, verify first.
# java-version
For installation, please refer to "installing JDK8 under CentOS", including JRE.
Install Solr5.3
Go to http://www.apache.org/dyn/closer.lua/lucene/solr/5.3.0 to download the Solr installation file solr-5.3.0.tgz.
Place the solr-5.3.0.tgz file in the / tmp directory and execute the following script:
# cd / tmp # tar-zxvf solr-5.3.0.tgz / / decompress the package
Create application and data directories
# mkdir-p / data/solr / usr/local/solr
Create and empower users running solr
# groupadd solr # useradd-g solr solr # chown-R solr.solr / data/solr / usr/local/solr
Install the solr service
# solr-5.3.0/bin/install_solr_service.sh solr-5.3.0.tgz-d / data/solr-I / usr/local/solr
Check service status
# service solr status
You will see the following output:
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 (.3) of 490.7 MB"}
Solr command usage
Navigate to the solr application directory
# cd / usr/local/solr/solr
View solr command options
#. / 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 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-helpUsage: 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 Specify the hostname for this Solr instance-p 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 Specify the Solr server directory; defaults to server-z ZooKeeper connection string; only used when running in SolrCloud mode using-c To launch an embedded ZooKeeper instance, don't pass this parameter. -m 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 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 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-an 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#. / bin/solr create-helpUsage: 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
Install solr service script usage
Run the installation script
# / tmp/solr-5.3.0/bin/install_solr_service.shERROR: Must specify the path to the Solr installation archive, such as solr-5.0.0.tgzUsage: install_solr_service.sh path_to_solr_distribution_archive OPTIONS The first argument to the script must be a path to a Solr distribution archive, such as solr-5.0.0.tgz (only .tgz or .zip are supported formats for the archive) Supported OPTIONS include:-d Directory for live / writable Solr files, such as logs, pid files And index data Defaults to / var/solr-i Directory to extract the Solr installation archive; defaults to / opt/ The specified path must exist prior to using this script. -p Port Solr should bind to; default is 8983-s Service name; defaults to solr-u User to own the Solr files and run the Solr process as; defaults to solr This script will create the specified user account if it does not exist.NOTE: Must be run as the root user
Create a collection
In this section, we create a simple Solr collection.
Solr can have multiple collections, but in this example, we use only one. Create a new collection using the following command. We run as solr to avoid any permission errors.
# su-solr-c "/ usr/local/solr/solr/bin/solr create-c gettingstarted-n data_driven_schema_configs"
In this command, gettingstarted is the name of the collection, and-n specifies the configuration collection. Solr provides three configuration collections by default. Here we are using schemaless, which means any column with any name can be provided, and the type will be guessed.
Setup new core instance directory: / data/solr/data/gettingstartedCreating new core 'gettingstarted' using command: http://localhost:8983/solr/admin/cores?action=CREATE&name=gettingstarted&instanceDir=gettingstarted{ "responseHeader": {"status": 0, "QTime": 3247}, "core": "gettingstarted"}
You have now created the collection and can start adding data. The default schema requires only one column: id. There are 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 visit the http://your_server_ip:8983/solr Web Web interface using a Web browser, it will be displayed as:
This Web interface contains a lot of useful information and can be used to debug any problems that arise in use.
Collections are divided into cores, which is why there are a large number of references to cores in the Web interface. Now, gettingstarted contains only one core, called gettingstarted. On the left-hand side, you can see the "Core Selector" drop-down menu, and we can select gettingstarted to see more information.
After selecting the gettingstarted core, select "Documents". The document stores real data that can be searched by Solr. Because we use a modeless configuration, we can use any column. I added a single document using the following JSON example by copying the following to the "Documents (s)" column:
{"number": 1, "president": "George Washington", "birth_year": 1732, "death_year": 1799, "took_office": "1789-04-30", "left_office": "1797-03-04", "party": "No Party"}
Click "Submit document" to add documents to the index. After a while, you will see the following message:
Output after adding the document:
Status: success Response: {"responseHeader": {"status": 0, "QTime": 290}}
You can add more documents using a similar or completely different structure, but you can also continue with only one document.
Now, select "Query" on the left to query the document we just added. Keep the default values on the screen. After clicking "Execute Query", you will see up to 10 documents, depending on how much you add:
Query output
{"responseHeader": {"status": 0, "QTime": 39, "params": {"Q": "*: *", "indent": "true", "wt": "json", "_": "1442371884598"}}, "response": {"numFound": 1 "start": 0, "docs": [{"number": [1], "president": ["George Washington"], "birth_year": [1732] "death_year": [1799], "took_office": ["1789-04-30T00:00:00Z"], "left_office": ["1797-03-04T00:00:00Z"] "party": ["No Party"], "id": "b9b294c1-4b68-4d96-adc2-f6fb77f60932", "_ version_": 1512437472611532800}
Reference: http://lucene.apache.org/solr/quickstart.html
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.