Jetty Solr with Drupal Search API and Ubuntu

A strange order to list the players but there you have it.

Recently I was trying to re create a Solr server but over a pair of OpenVZ slices. Solr on one, Drupal on the other. At the same time I switched from Tomcat to Jetty. I had a couple more pitfalls.

Here are my original notes for the Tomcat set up with Solr on the same host as Drupal

# Installing solr 
$ sudo apt-get install solr-tomcat

# Copy config from search_api_solr module to /etc/solr
/etc/solr/conf$ sudo cp /srv/www/example.com/profiles/example/modules/contrib/search_api_solr/schema.xml ./
/etc/solr/conf$ sudo cp /srv/www/example.com/profiles/example/modules/contrib/search_api_solr/solrconfig.xml ./

# Configure solr
http://example.com/admin/config/search/search_api/server/solr/edit
Solr host: localhost
Solr port: 8080
Solr path: /solr

# Soft link Ubuntu's data directory with Drupals one
/usr/share/solr$ sudo ln -s /var/lib/solr/data data

# Install the SolrPhpClient into libraries

And here are my addenda for the reconfiguration

# Installing solr
$ sudo apt-get install solr-jetty

# We must listen on all interfaces (although the comments mention that it listens on all interfaces by default I found this not to be the case). Note: All we are doing is uncommenting the line (edit the file don't cat it).
$ cat /etc/default/jetty | grep JETTY_HOST JETTY_HOST=$(uname -n)

# Jetty uses a different port (8983) to Tomcat (8080)

# Open inbound ports on Solr and outbound ports on Drupal

# Test Jetty on localhost
$ telnet localhost 8983

# Test Jetty on Drupal host
$ telnet solr.example.com 8983

# Configure solr
http://example.com/admin/config/search/search_api/server/solr/edit
Solr host: solr.example.com
Solr port: 8983
Solr path: /solr

And lastly upgrade Solr and switch to a multicore configuration.

Ubuntu 12.04 (LTS) Precise has Solr 1.4.1. We needed 3.6.x. So we're reinstalling by hand. This is the guide I followed. But I'm after multicore so there are differences.
http://www.gazoakley.com/content/installing-apache-solr-3.6-3.x-ubuntu-d...

# Download and untar Solr

$ cd /usr/share
$ wget http://mirror.mel.bkb.net.au/pub/apache/lucene/solr/3.6.2/apache-solr-3.6.2.tgz
$ tar zxf apache-solr-3.6.2.tgz
$ mv apache-solr-3.6.2.tgz solr

# Create the Solr user, run Jetty on startup as per the tech note

# Move our old 1.4 config into the new directory and change the owner

$ rm -Rf /usr/share/solr/example/multicore/core0/conf
$ cp -Rp /etc/solr/conf /usr/share/solr/example/multicore/core0/conf
$ chown -R solr:solr /usr/share/solr/

# Point the solr config at our old dataDir

$ mkdir /var/lib/solr/coredata
$ cp -Rp /var/lib/solr/data /var/lib/solr/coredata/core0
$ cat /usr/share/solr/example/multicore/solr.xml | grep dataDir
    <core name="core0" instanceDir="core0" dataDir="/var/lib/solr/coredata/core0" />

# Configure Jetty (but this time use the multicore directory)

$ service jetty stop
$ cat > /etc/default/jetty << EOF 
JAVA_HOME=/usr/java/default 
JAVA_OPTIONS="-Dsolr.solr.home=/usr/share/solr/example/multicore \$JAVA_OPTIONS" 
JETTY_HOME=/usr/share/solr/example 
JETTY_USER=solr 
JETTY_LOGS=/var/log/solr 
JAVA_HOME=/usr/lib/jvm/default-java 
JDK_DIRS="/usr/lib/jvm/default-java /usr/lib/jvm/java-6-sun" 
EOF
$ service jetty start

# Test from Drupal side

$ curl http://solr.example.com:8983/solr/core0

# Reconfigure Drupal's search_api_solr
http://example.com/admin/config/search/search_api/server/solr/edit
Solr host: solr.example.com
Solr port: 8983
Solr path: /solr/core0