Tuesday, March 17, 2015

How to setup Solr on Linux machine?

System Environment
Linux Version: 2.6.32-358.23.2.el6.x86_64
Solr Version: 5.0.0

Need to upgrade JDK to version and above for Solr to work

1. Download JDK version 1.7.0_75 (jdk-7u75-linux-x64.tar.gz)
2. Copy jdk-7u75-linux-x64.tar.gz to "/usr/lib" directory
3. Run the command to untar the zip files
tar xzf jdk-7u75-linux-x64.tar.gz
4. Run  the command below to install the JDK
alternatives --install /usr/bin/java java /usr/lib/jdk1.7.0_75/bin/java 2
5. Run the command below to select the java command to use
alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
*+ 1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
   2           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   3           /usr/lib/jdk1.7.0_75/bin/java

Enter to keep the current selection[+], or type selection number: 3
6. Run the command below to install

alternatives --install /usr/bin/jar jar /usr/lib/jdk1.7.0_75/bin/jar 2
alternatives --install /usr/bin/javac javac /usr/lib/jdk1.7.0_75/bin/javac 2
alternatives --set jar /usr/lib/jdk1.7.0_75/bin/jar
alternatives --set javac /usr/lib/jdk1.7.0_75/bin/javac 

Solr Installation

1. Download Solr from Apache website. Note: "solr-5.0.0.tgz" has been downloaded
2. Copy solr-5.0.0.tgz to "/opt" directory
3. Run the command below to unzip the Solr installer
tar zxf solr-5.0.0.tgz
3. Run the command below to start the Solr instance. The default port is 8983
# cd /opt/solr-5.0.0/
# bin/solr start
4. To shutdown the Solr instance, run the command below.
# bin/solr stop

Open Firewall to allow port 8983

1. Run the command below to open port 8983 on the machine
# iptables -I INPUT -p tcp -m tcp --dport 8983 -j ACCEPT
#service iptables save
2. Type the URL (http://[server_address]:8983/) in any browser, Solr admin screen will be displayed.

No comments: