Bommelding
Bommelding

Reputation: 52

Typo3 Solr, how to setup solr 5.X

Goodday!

We are trying to setup Solr to work with TYPO3 6.2 but we haven't had any success. Our first try was with the "install-solr.sh" script that TYPO3 provides to run Solr 4.8 with Tomcat 6.

Unfortunately the script didn't install Solr on our (Debian) server and i can't get it running.

Second thing we tried is to install Solr (5.x) without Tomcat but we can't get it configured for TYPO3.

What is the best way to setup Solr for TYPO3 6.2, and how to configure that for TYPO3?

Kind regards!

Upvotes: 1

Views: 391

Answers (2)

Jost
Jost

Reputation: 5840

I have tried the same, and failed. I came to the conclusion that Solr 5.x is not compatible with the extension solr in versions 3.0.0 and 3.0.1, even if you install it manually. There are configurations in EXT:solr that don't work anymore with Solr 5.x. I tried to fix that, but it where too many changes.

I can confirm that the latest version of the 4.x branch (4.10.4) works fine with EXT:solr, after manual installation. It should not be a problem to use an older version, or even 4.8, since the Solr server is not exposed to the web.

To use Solr 4.x, just download the Solr archive and extract it somewhere on the disk. Here is a simple script for starting and stopping a Solr 4.x-Server, you just need to enter the paths. I'm not quite sure where I got it, maybe it is even included in EXT:solr:

##################################################
# Environment
##################################################

# Adapt those paths
JAVA="/usr/bin/java"
SOLR_DATA_DIR="/path/to/your/project/.../typo3conf/ext/solr/Resources/Solr"
SOLR_CODE_DIR="/path/where/you/extracted/solr/to/..."

SOLR_PID="$SOLR_DATA_DIR/solr.pid"
SOLR_PORT="8983"
SOLR_HOST="127.0.0.1"
SOLR_RUNDIR="$SOLR_CODE_DIR/example"
SOLR_JAR="$SOLR_RUNDIR/start.jar"
SOLR_HOME="$SOLR_DATA_DIR"

RUN_ARGS=("-Dsolr.solr.home=$SOLR_HOME" "-Djetty.port=$SOLR_PORT" "-Djetty.host=$SOLR_HOST" -jar "$SOLR_JAR")

##################################################
# Helper functions
##################################################
usage()
{
    echo "Usage: ${0##*/} {start|stop|status}"
    exit 1
}

running()
{
  local PID=$(cat "$1" 2>/dev/null) || return 1
  kill -0 "$PID" 2>/dev/null
}

##################################################
# Do the action
##################################################
case "$1" in
  start)
    echo "Starting Solr: "

    if start-stop-daemon --verbose --start --pidfile "$SOLR_PID" --make-pidfile --chdir "$SOLR_RUNDIR" --background --exec "$JAVA" -- "${RUN_ARGS[@]}" --daemon
    then
      sleep 2
      if running "$SOLR_PID"
      then
    echo "OK"
      else
    echo "FAILED"
      fi
    fi

    ;;

  stop)
    echo "Stopping Solr: "

    start-stop-daemon --stop --pidfile "$SOLR_PID" --chdir "$SOLR_RUNDIR" --exec "$JAVA" --signal HUP

    TIMEOUT=30
    while running "$SOLR_PID"; do
      sleep 1

      if (( TIMEOUT-- == 0 )); then
    echo "Process is still running after 30 seconds. Wait a bit longer, or stop it manually."
    exit 1
      fi
    done

    rm -f "$SOLR_PID"
    echo OK

    ;;

  status)
    if [ -f "$SOLR_PID" ]
    then
      echo "Solr is running, pid=$(< "$SOLR_PID")"
      exit 0
    fi
    echo "Solr is not running"
    exit 1
    ;;

  *)
    usage

    ;;
esac

If Solr does not start correctly when using the script, try to execute the following command line manually, so you can see the stack traces (replace the variables with their actual values manually):

/usr/bin/java -Dsolr.solr.home=$SOLR_HOME -Djetty.port=$SOLR_PORT -Djetty.host=$SOLR_HOST -jar $SOLR_JAR

Upvotes: 1

Bommelding
Bommelding

Reputation: 52

Jost answered it perfectly, but I want to add the following.

If you ever want install Solr trough the "install-solr.ssh" script Typo3 provides, be aware that the link in the file, to get solr, doesn't exist anymore. So when you run it, it will only install tomcat.

If you want to change it, do the following.

Search cecho "Downloading Apache Solr $SOLR_VERSION" $green wget --progress=bar:force http://mirror.dkd.de/apache/lucene/solr/$SOLR_VERSION/solr-$SOLR_VERSION.zip 2>&1 | progressfilt

And replace it with:

cecho "Downloading Apache Solr $SOLR_VERSION" $green wget --progress=bar:force http://archive.apache.org/dist/lucene/solr/$SOLR_VERSION/solr-$SOLR_VERSION.zip 2>&1 | progressfilt

Then it will install normally.

Upvotes: 0

Related Questions