11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

are set programmatically, but you could instead specify them on the java command line, as in the post.jar exa<br />

mple above:<br />

System.setProperty("javax.net.ssl.keyStore", "/path/to/solr-ssl.keystore.jks");<br />

System.setProperty("javax.net.ssl.keyStorePassword", "secret");<br />

System.setProperty("javax.net.ssl.trustStore", "/path/to/solr-ssl.keystore.jks");<br />

System.setProperty("javax.net.ssl.trustStorePassword", "secret");<br />

String zkHost = "127.0.0.1:2181";<br />

Cloud<strong>Solr</strong>Client server = new Cloud<strong>Solr</strong>Client(zkHost);<br />

server.setDefaultCollection("mycollection");<br />

<strong>Solr</strong>InputDocument doc = new <strong>Solr</strong>InputDocument();<br />

doc.addField("id", "1234");<br />

doc.addField("name", "A lovely summer holiday");<br />

server.add(doc);<br />

server.commit();<br />

Running <strong>Solr</strong> on HDFS<br />

<strong>Solr</strong> has support for writing and reading its index and transaction log files to the HDFS distributed filesystem.<br />

This does not use Hadoop MapReduce to process <strong>Solr</strong> data, rather it only uses the HDFS filesystem for index<br />

and transaction log file storage. To use Hadoop MapReduce to process <strong>Solr</strong> data, see the<br />

MapReduceIndexerTool in the <strong>Solr</strong> contrib area.<br />

To use HDFS rather than a local filesystem, you must be using Hadoop 2.x and you will need to instruct <strong>Solr</strong> to<br />

use the HdfsDirectoryFactory. There are also several additional parameters to define. These can be set in<br />

one of three ways:<br />

Pass JVM arguments to the bin/solr script. These would need to be passed every time you start <strong>Solr</strong><br />

with bin/solr.<br />

Modify solr.in.sh (or solr.in.cmd on Windows) to pass the JVM arguments automatically when<br />

using bin/solr without having to set them manually.<br />

Define the properties in solrconfig.xml. These configuration changes would need to be repeated for<br />

every collection, so is a good option if you only want some of your collections stored in HDFS.<br />

Starting <strong>Solr</strong> on HDFS<br />

Standalone <strong>Solr</strong> Instances<br />

For standalone <strong>Solr</strong> instances, there are a few parameters you should be sure to modify before starting <strong>Solr</strong>.<br />

These can be set in solrconfig.xml(more on that below), or passed to the bin/solr script at startup.<br />

You need to use an HdfsDirectoryFactory and a data dir of the form hdfs://host:port/path<br />

You need to specify an UpdateLog location of the form hdfs://host:port/path<br />

You should specify a lock factory type of ' hdfs' or none.<br />

If you do not modify<br />

solrconfig.xml, you can instead start <strong>Solr</strong> on HDFS with the following command:<br />

bin/solr start -Dsolr.directoryFactory=HdfsDirectoryFactory<br />

-Dsolr.lock.type=hdfs<br />

-Dsolr.data.dir=hdfs://host:port/path<br />

-Dsolr.updatelog=hdfs://host:port/path<br />

This example will start <strong>Solr</strong> in standalone mode, using the defined JVM properties (explained in more detail belo<br />

w).<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

532

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!