Last active
September 5, 2017 08:01
-
-
Save mansurali901/d23c77abc43a8f40c42d79ceebcb2282 to your computer and use it in GitHub Desktop.
Apache Solr 4.10.4 Setup with Centos 6.X
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script will install Apache Solr 4.10.4 | |
# Author Mansur Ul Hasan | |
# Sr, Network & Sys Admin | |
# GFK Etilize | |
### Main Installer Function | |
MainFunc () { | |
################## Setting up JAVA ################## | |
echo "Downloading JAVA JDK 1.8 from Local repository......" | |
https://www.dropbox.com/s/dwsqw6gofynaf5e/jdk1.8.0_91.tar?dl=0 | |
echo "Installing JAVA JDK 1.8" | |
mkdir -p /usr/java | |
mv jdk1.8.0_91.tar /usr/java/ | |
cd /usr/java/ | |
tar xvf jdk1.8.0_91.tar | |
ln -s jdk1.8.0_91 latest | |
echo "Creating Links of binaries" | |
ln -s /usr/java/latest/bin/java /usr/bin/java | |
ln -s /usr/java/latest/bin/javac /usr/bin/javac | |
ln -s /usr/java/latest/bin/javah /usr/bin/javah | |
ln -s /usr/java/latest/bin/javap /usr/bin/javap | |
ln -s /usr/java/latest/bin/javadoc /usr/bin/javadoc | |
ln -s /usr/java/latest/bin/javaws /usr/bin/javaws | |
echo "Checking JAVA Version" | |
java -version | |
################## Java Setup Completed ################## | |
################## Solr Setup Started ################## | |
wget https://www.dropbox.com/s/q8p6mx5d7vor819/solr-4.10.4.tgz?dl=0 | |
tar zxvf solr-4.10.2.tgz | |
echo "Moving to Repository" | |
mv solr-4.10.2 /opt/solr | |
echo "Adding Solr User" | |
useradd -r -d /opt/solr -M -c "Apache Solr" solr | |
echo "Changing Permission" | |
chown -R solr:solr /opt/solr/ | |
echo "Creating Service File" | |
echo " | |
#!/bin/bash | |
# | |
# solr APACHE SOLR 4.10 | |
# | |
# chkconfig: 2345 85 15 | |
# description: Startup Script for APACHE SOLR 4.10 | |
# | |
# processname: solr | |
# Author Mansur Ul Hasan | |
# Sr, Network & Sys Admin | |
# GFK Etilize Pak | |
SOLR_BIN="/opt/solr/bin/solr" | |
SOLR_PORT="8983" | |
start() { | |
$SOLR_BIN start -p $SOLR_PORT | |
RETVAL=$? | |
return $RETVAL | |
} | |
stop() { | |
$SOLR_BIN stop -p $SOLR_PORT | |
RETVAL=$? | |
return $RETVAL | |
} | |
restart() { | |
$SOLR_BIN restart -p $SOLR_PORT | |
RETVAL=$? | |
return $RETVAL | |
} | |
status() { | |
$SOLR_BIN -i | |
RETVAL=$? | |
return $RETVAL | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
status) | |
status | |
;; | |
*) | |
echo "Usage: service solr {start|stop|restart|status}" | |
esac | |
exit $RETVAL | |
" >/etc/init.d/solr | |
echo "Change file to be executable" | |
chmod +x /etc/init.d/solr | |
echo "Enabling in startup" | |
chkconfig solr on | |
chkconfig --list solr | |
echo "Starting Solr Service" | |
/etc/init.d/solr start | |
} | |
################## Solr Setup Finished ################## | |
################## Pre Requisites checking ################## | |
Prepoc () { | |
echo "Welcome to Solr 4.10.4 Setup" | |
echo " | |
=========================================================== | |
| Pre requisited ....... | | |
| 1 - Your hostname must be resolveable | | |
| 2 - Java JDK 1.7 or greater must be install | | |
=========================================================== | |
" | |
HName=`hostname` | |
name=`nslookup $HName` | |
case $HName in | |
*server can't find*) | |
echo "Please set the Hostname on the DNS for machine add into hosts file." | |
;; | |
*) | |
MainFunc | |
;; | |
esac | |
} | |
################## Pre req check end ################## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment