Kevin Warrington

Loading clever subtitle...

Installing Solr 4 on CentOS 6

Verify CentOS Version

1
cat /etc/centos-release

Install Tomcat

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# install java-1.7.0-openjdk
sudo yum -y install java-1.7.0-openjdk
# install tomcat6
sudo yum -y install tomcat6 tomcat6-webapps tomcat6-admin-webapps
# change port
sudo sed -i s/8080/8983/g /etc/tomcat6/server.xml
# install Simple Logging Facade for Java
wget -qO- http://www.slf4j.org/dist/slf4j-1.7.12.tar.gz | tar xvz
sudo cp -a slf4j-1.7.12/slf4j-*.jar /usr/share/tomcat6/lib
# remove android files that mess up startup
sudo rm -rf /usr/share/tomcat6/lib/slf4j-android*
# install Apache Commons Logging
wget -qO- http://apache.mirror.rafal.ca//commons/logging/binaries/commons-logging-1.2-bin.tar.gz | tar xvz
sudo cp -a commons-logging-1.2/commons-logging-1.2*.jar /usr/share/tomcat6/lib

To use the manager webapp you need to create a user with the role “manager”. Add a user to <tomcat-users> in /etc/tomcat6/tomcat-users.xml

1
2
3
<role rolename="manager" />
<role rolename="admin" />
<user username="admin" password="password" roles="manager,admin" />

Start tomcat

1
sudo service tomcat6 start

Open the Tomcat Web Application Manager

Install Solr

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
wget http://archive.apache.org/dist/lucene/solr/4.6.1/solr-4.6.1.tgz
tar xvf solr-4.6.1.tgz
# install solr app
sudo cp -a solr-4.6.1/dist/solr-4.6.1.war /var/lib/tomcat6/webapps/solr.war
# copy default example config to home, where data will live
sudo cp -a solr-4.6.1/example/solr /home/
# set appropriate permissions
sudo chown -R tomcat:tomcat /home/solr /var/lib/tomcat6/webapps/solr
# update solr home directory in WEB-INF
#    <env-entry>
#       <env-entry-name>solr/home</env-entry-name>
#       <env-entry-value>/home/solr</env-entry-value>
#       <env-entry-type>java.lang.String</env-entry-type>
#    </env-entry>
sudo vim /var/lib/tomcat6/webapps/solr/WEB-INF/web.xml
# restart so tomcat creates directory
sudo service tomcat6 restart

Create a new core

1
2
3
4
5
6
7
8
cd /home/solr
sudo cp -a collection1 document_library
# update core name
echo 'name=document_library' | sudo tee document_library/core.properties
# clean data directory
sudo rm -rf document_library/data
sudo mkdir document_library/data
sudo chown -R tomcat:tomcat document_library

Add drupal solr configuration to new core

1
2
3
sudo cp /vagrant/htdocs/sites/all/modules/apachesolr/solr-conf/solr-4.x/* /home/solr/document_library/conf/
sudo chown -R tomcat:tomcat document_library
sudo service tomcat6 restart

Comments