SolrCloud as a Windows Service

Want to setup a simple solrCloud network on Windows? If you are just running a couple nodes and intend to run the embedded ZooKeeper here’s how to get it done.

First, make a list of the ip addresses (or better yet, hostnames) of your servers. You’ll need this for the ZooKeeper bit of the solr configuration.

Download a copy of Solr 4.3 or greater. Extract it somewhere reasonable on your first server. For simplicity we’ll assume C:\SolrCloud, if not find/replace in your favorite editor will be handy.

Next, grab the Apache Commons daemon for Windows. Unzip it somewhere off to the side. Inside you’ll find two executables: prunmgr and prunsrv. Copy prunmgr.exe to C:\SolrCloud and rename it to solrCloudw.exe. Do the same for prunsrv.exe, but name it solrCloud.exe (no “w” at the end of the name).

Open a command prompt (Start->Run then “cmd.exe” and enter).

cd C:\SolrCloud

Then, run the following to register your first server service:

solrCloud.exe //IS/solrCloudZk --DisplayName="Solr Cloud with Zookeeper"
  --Install=c:\solr-cloud\solr-cloud\example\solrCloud.exe
  --LogPath=c:\solr-cloud\solr-cloud\example\logs
  --LogLevel=Debug 
  --StdOutput=auto 
  --StdError=auto 
  --StartMode=java 
  --StopMode=java 
  --Jvm=auto 
  ++JvmOptions=-Djetty.home=c:\SolrCloud\example\solr 
  ++JvmOptions=-DSTOP.PORT=8087 
  ++JvmOptions=-DSTOP.KEY=stopsolr 
  ++JvmOptions=-Djetty.logs=c:\SolrCloud\example\logs 
  ++JvmOptions=-Djetty.port=8983 
  ++JvmOptions=-Dorg.eclipse.jetty.util.log.SOURCE=true 
  ++JvmOptions=-XX:MaxPermSize=512M  
  --Classpath=c:\SolrCloud\example\start.jar 
  --StartClass=org.eclipse.jetty.start.Main 
  ++StartParams=OPTION=ALL 
  ++StartParams=c:\SolrCloud\example\etc\jetty.xml 
  --StopClass=org.eclipse.jetty.start.Main ++StopParams=--stop 
  ++JvmOptions=-Dsolr.solr.home=c:\SolrCloud\example\solr 
  --StartPath=c:\SolrCloud\example  
  --JavaHome="c:\Program Files\Java\jre6"
  ++JvmOptions=-DzkHost=10.5.0.1:9983;10.5.0.2:9983 
  ++JvmOptions=-DzkRun
  ++JvmOptions=-DnumShards=1
  ++JvmOptions=-Dcollection.configName=myconf
  ++JvmOptions=-Dbootstrap_confdir=c:\SolrCloud\example\solr\conf

A couple things to note here.

  1. Make sure to edit the line with “++JvmOptions=-DzkHost=10.5.0.1:9983;10.5.0.2:9983″. This should be a list of your servers with “:9983″ on the end of each. And, yes, you could supply a custom ZooKeeper root here by doing something like “:9983/myroot”. No need since we are running the embedded ZooKeeper, but who wants to do that forever?

  2. Check all the paths and make sure they reflect your setup. As mentioned, we are using “c:\SolrCloud” for simplicity.

  3. Don’t forget that we are writing logs to the C:\SolrCloud\example\logs directory. These can be very handy for trouble shooting.

  4. This setup will reset the the Solr config in ZooKeeper every time this server is restarted. You could remove this behavior by reregistering the service without the last line after it has run once. For now, I’d recommend keeping it until you are comfortable managing your own ZooKeeper servers. At that point you can drop the last for lines, and manage Zk as it’s on server/service.

Start the service:

 solrCloud.exe //SS

Repeat the above on the rest of your servers, with one change. Remove the last line of the service setup, “++JvmOptions=-Dbootstrap_confdir=c:\SolrCloud\example\solr\conf”.

You now have a SolrCloud cluster running on Windows!

Thanks to Alexandre Rafalovitch and his article on Solr as a Windows Service. Have a look there if you want to run Solr on Windows, but not SolrCloud.


post-type:post

One comment on “SolrCloud as a Windows Service

  1. Thanks for this example. It got me through setting up ZOLR+ZK on Windows. Few comments though.

    Following line has a wrong syntax. There should be a comma separating host entries, not a semicolon.

    ++JvmOptions=-DzkHost=10.5.0.1:9983;10.5.0.2:9983

    Should be

    ++JvmOptions=-DzkHost=10.5.0.1:9983,10.5.0.2:9983

    However once setup properly this line would throw following exception:

    null:java.lang.IllegalArgumentException: port out of range:-1

    It turns out there seems to be a bug/feature in SolrZkServer.java as described in this post

    http://mail-archives.apache.org/mod_mbox/lucene-dev/201306.mbox/%3CJIRA.12632095.1360706150911.59206.1370292140755@arcas%3E

    So for your example to work each SOLR node needs to have its setting modified as follows:

    ++JvmOptions=-DzkHost=localhost:9983,10.5.0.2:9983

    And

    ++JvmOptions=-DzkHost=10.5.0.1:9983,localhost:9983

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>