2013.11.01 – I ran into an issue with a Solr configuration that was working for me locally, but not on our CentOS 6.4 server. I’ve documented below all of the issues I encountered along the way, as the upgrade from Solr 4.2 to 4.3+ is a pretty nasty one, due to major changes in the logging system (LOG4J / SLF4J)
Lucene/Solr 4.3+ : The Beginning
The awesome guys at Open Source Connections had created a custom tokenizer for Solr for The State Decoded, which was suddenly throwing this new error:java.lang.IllegalArgumentException: No enum const class org.apache.lucene.util.Version.LUCENE_43
solr_home/conf/solrconfig.xml file
<luceneMatchVersion>LUCENE_43</luceneMatchVersion>
LUCENE_42
but received even more intimidating errors:
org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] fieldType "descendent_facet_hierarchical": Plugin init failure for [schema.xml] analyzer/tokenizer: Error instantiating class: 'com.o19s.RegexPathHierarchyTokenizerFactory'
Maven
To do that, first I had to install Maven, which was missing from CentOS. Following the instructions here, I went to the Maven site and found the download link for the latest version (in my case, that was 3.1.1). I grabbed that file and stored it in my /usr/local directory (for ease of use), unzipping as usual:cd;
wget http://apache.tradebit.com/pub/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz
tar -xzf ./apache-maven-3.1.1-bin.tar.gz -C /usr/local
sudo ln -s apache-maven-3.1.1 maven
sudo vi /etc/profile.d/maven.sh
export M2_HOME=/usr/local/maven
export PATH=${M2_HOME}/bin:${PATH}
JDK
Now, after all of that, apparently I still did not have the Java Development Kit (aka JDK) installed. You’d think that the package OpenJDK would provide this, by the name, but it turns out that that only contains the Java Virual Machine (JVM). I discovered this as maven complained about a missing filetools.jar
So, I checked yum
for the latest version and installed it:
sudo yum list jdk
sudo yum install java-1.6.0-openjdk-devel
sudo vi /etc/profile.d/java.sh
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64
Upgrading to Solr4.3+
Now, between Solr 4.2 and Solr 4.3, they removed the native LOG4J support that is by default needed to run Solr. So there are a lot of extra steps here.A note on Tomcat logging
As you’re going through and starting and restarting tomcat (sudo service tomcat6 restart
),
you’ll probably want to keep an eye on the log file here:
less /var/log/tomcat6/localhost.[DATE].log
/etc/tomcat6/Catalina/localhost/solr.xml
<Context docBase="/opt/solr/solr.war" debug="0" crossContext="false" >
<Environment name="solr/home" type="java.lang.String" value="/opt/solr" override="true"/>
</Context>
Now back to the good part
Now, I was finally ready to install the latest version of Solr. I headed over to the Solr downloads page and found that 4.5.1 was the latest. I grabbed the download from that page (after several redirects in between), and extracted it to my home directory:wget http://mirrors.gigenet.com/apache/lucene/solr/4.5.1/solr-4.5.1.tgz
tar -xzf ./solr-4.5.1.tgz
/opt/solr
, and just in case I broke everything, I wanted to keep a copy of that. If you’re not upgrading from a previous version, you don’t need to do this to move that out of the way:
sudo mv /opt/solr /opt/solr-4.2.1
sudo cp -R ~/solr-4.5.1/example/solr /opt/solr-4.5.1
cd /opt
sudo ln -s solr-4.5.1 solr
cd /opt/solr
sudo cp ~/solr-4.5.1/dist/solr-4.5.1.war ./
sudo ln -s solr-4.5.1.war solr.war
SEVERE: Exception starting filter SolrRequestFilter
org.apache.solr.common.SolrException: <strong>Could not find necessary SLF4j logging jars.</strong> If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers, the corresponding directory should be used. For more information, see: http://wiki.apache.org/solr/SolrLogging
sudo cp ~/solr-4.5.1/example/lib/ext/* /var/lib/tomcat6/lib/
sudo cp ~/solr-4.5.1/dist/solrj-lib/* /var/lib/tomcat6/lib/
sudo cp -R ~/solr-4.5.1/dist/* /opt/solr/lib/
sudo cp ~/solr-4.5.1/dist/solrj-lib/* /var/lib/tomcat6/webapps/solr/WEB-INF/lib/
sudo vi /opt/solr/solr.xml
<cores adminPath="/admin/cores" defaultCoreName="collection1" host="${host:}" hostPort="${jetty.port:}" hostConte xt="${hostContext:}" zkClientTimeout="${zkClientTimeout:15000}">
<core name="collection1" instanceDir="collection1" />
<core name="baltimorecode_dev_www" instanceDir="baltimorecode/www/staging/statedecoded" />
</cores>
Finally Rebuilding the custom Solr tokenizer
From there, I just needed to rebuild the custom tokenizer that we had.cd /opt/solr/baltimorecode/www/staging/statedecoded/src/
sudo mvn package
cp target/regex-path-tokenizer-0.0.1-SNAPSHOT.jar ../lib/regex-path-tokenizer-0.0.1-SNAPSHOT.jar
sudo service tomcat6 restart
lynx http://localhost:8080/solr/baltimorecode_dev_www/admin/ping
ssh -L 8009:localhost:8080 user@removtehost.org -N
http://localhost:8009/solr/
and solr was running perfectly.
Finishing Up
The last little thing that caught me up in my sleep-deprived state was that the PHP Solarium package requiresallow_url_fopen
to be set to On
. This seems rather obvious, but is not the default value on CentOS.
That was a long day.
Here are a few of the articles that I used to get this far:
- Patrick Reilly: How to install maven on CentOS
- Solr: MultiCore
- Apache Tomcat configuration: HTTP Connectors
- Andrew Jaimes: Installing Lucene/Solr on CentOS with Tomcat
- Hipsnip Cookbooks issues: Solr Fails to start missing SLF4j
- StackOverflow: Solr 4.3 Tomcat6 Ubuntu installation exception (More confusing than helpful.)