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

    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]

    exec su solr -l -c "cd /opt/solr/example && java -Dsolr.solr.home=/etc/solr -Djetty.port=8080 -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="" instanceDir="/etc/solr/">
          <property name="dataDir" value="/var/lib/solr/" />

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