Sunday, July 15, 2012

Installing Solr 3.6.0 on Ubuntu from source


1. Make a solr user

    useradd -d /opt/solr solr

2. Download a tarball of Solr 3.6.0 and install to /opt/solr

    wget http://archive.apache.org/dist/lucene/solr/3.6.0/apache-solr-3.6.0.tgz
    tar -zxf apache-solr-3.6.0.tgz
    mv apache-solr-3.6.0 /opt/solr
    chown -R solr /opt/solr

4. Make log directory

    mkdir /var/log/solr
    chown solr /var/log/solr

5. Create Upstart job at /etc/init/solr.conf:

    description "Solr"


    start on runlevel [2345]
    stop on runlevel [016]
    respawn


    exec su solr -l -c "cd /opt/solr/example && java -Dsolr.solr.home=/etc/solr -Djetty.port=8080 -Djetty.host=0.0.0.0 -Djetty.logs=/var/log/solr -jar start.jar > /var/log/solr/stdouterr.log 2>&1"

6. Create the base data directory for cores:

    mkdir /var/lib/solr
    chown solr /var/lib/solr

7. Make /etc/solr/solr.xml:

    <?xml version="1.0" encoding="UTF-8" ?>
    <solr persistent="false">
      <cores adminPath="/admin/cores">
        <core name="example.com" instanceDir="/etc/solr/example.com">
          <property name="dataDir" value="/var/lib/solr/example.com/data" />
        </core>
      </cores>
    </solr>

8. Make core conf in /etc/solr/example.com/conf/{schema.xml,solrconfig.xml}