Instantly share code, notes, and snippets.

Embed
What would you like to do?
Solr Setup with relative path configuration
############ kurulum icin basit ayarlar, istedigimiz sekilde degistirebiliriz ###########
export SOLR_DIR='solr4' # tum uygulama, konfigurasyon ve datalarin olacagi klasor
export SOLR_PORT='8082' # solr'i kullanmak istedigimiz port
export TOMCAT_MPORT='8006' # tomcat yonetim portu
export SOLR_VER='4.7.0' # kullanmak istedigimiz solr versionu
export TOMCAT_VER='8.0.3' # kullanmak istedigimiz tomcat versionu
export SOLR_HOME='solr_home' # solr'a ait data ve konfigurasyonlarin bulunacagi klasor
if [ -d "/Applications/" ]
then
export JRE_URL='http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jre-7u51-macosx-x64.tar.gz' # MacOS x64
else
export JRE_URL='http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jre-7u51-linux-x64.tar.gz' # linux x64
fi
############ kurulum icin basit ayarlar, istedigimiz sekilde degistirebiliriz ###########
mkdir $SOLR_DIR # solr klasorunu olustur
cd $SOLR_DIR # solr klasorune gir
# ilgili solr, tomcat ve jre versiyonunu indir
wget "http://www.eu.apache.org/dist/lucene/solr/$SOLR_VER/solr-$SOLR_VER.zip"
wget "http://www.eu.apache.org/dist/tomcat/tomcat-`echo $TOMCAT_VER |cut -d'.' -f1`/v$TOMCAT_VER/bin/apache-tomcat-$TOMCAT_VER.zip"
wget -O jre.tar.gz --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" $JRE_URL jre.tar.gz
# indirilen zipli solr ve tomcat dosyalarini ac ve zipli dosyalari sil
unzip "apache-tomcat-$TOMCAT_VER.zip" && unzip "solr-$SOLR_VER.zip"
rm "apache-tomcat-$TOMCAT_VER.zip" && rm "solr-$SOLR_VER.zip"
# jre' yi arsivden cikart ve arsiv dosyasini sil
tar -xzvf jre.tar.gz && rm jre.tar.gz
# cikarlina jre klasorunu jre olarak yeniden adlandir
for file in jre*.jre; do mv "$file" "jre"; done
# sistem varsayilan JRE 'si yerine indirdigimiz jre'yi kullan
if [ -d "/Applications/" ]
then
echo "JRE_HOME=./jre/Contents/Home" > apache-tomcat-$TOMCAT_VER/bin/setenv.sh # MacOS x64
else
echo "JRE_HOME=./jre" > apache-tomcat-$TOMCAT_VER/bin/setenv.sh # linux x64
fi
# tomcat portunu istenilen portla degistir
sed -i.bak 's%<Connector port="8080" protocol="HTTP/1.1"%<Connector port="'$SOLR_PORT'" protocol="HTTP/1.1"%g' apache-tomcat-$TOMCAT_VER/conf/server.xml
# tomcat server (yonetim) portunu istenilen portla degistir
sed -i.bak 's%<Server port="8005" shutdown="SHUTDOWN">%<Server port="'$TOMCAT_MPORT'" shutdown="SHUTDOWN">%g' apache-tomcat-$TOMCAT_VER/conf/server.xml
# tomcat/bin klasoru icindeki .sh uzantili dosyalara calistirma izni ver
chmod +x ./apache-tomcat-$TOMCAT_VER/bin/*.sh
./apache-tomcat-$TOMCAT_VER/bin/startup.sh # tomcat'i baslat
sleep 8 # tomcat'in hazir olmasi icin bir sure bekle (8 saniye)
./apache-tomcat-$TOMCAT_VER/bin/shutdown.sh # tomcat'i durdur
# solr ile gelen kutuphaneleri tomcat/lib klasorune kopyala
cp solr-$SOLR_VER/example/lib/ext/* apache-tomcat-$TOMCAT_VER/lib/
mkdir $SOLR_HOME # solr home klasorunu olustur
# solr ile gelen ornek solr uygulamasini solr home dizinine kopyala
cp -r solr-$SOLR_VER/example/solr/* $SOLR_HOME/
# solr'in basvuracagi kutuphane yolunu guncelle
sed -i.bak 's%<lib dir="../../../%<lib dir="../../solr-'$SOLR_VER'/%g' $SOLR_HOME/collection1/conf/solrconfig.xml
# solr uygulamasini tomcat' e ekle (path olarak)
echo '<?xml version="1.0" encoding="UTF-8" ?>
<Context
docBase="./solr-'$SOLR_VER'/example/webapps/solr.war"
allowlinking="true"
crosscontext="true"
debug="0"
antiResourceLocking="false"
privileged="true">
<Environment name="solr/home" override="true" type="java.lang.String" value="./'$SOLR_HOME'" />
</Context>
' > apache-tomcat-$TOMCAT_VER/conf/Catalina/localhost/solr.xml
# solr'i tek core ile calisacak sekilde konfigure et
echo '<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true">
<cores adminPath="/admin/cores"
host="${host:}" hostPort="'$SOLR_PORT'" hostContext="${hostContext:}">
<core config="solrconfig.xml" name="collection1" instanceDir="collection1" schema="schema.xml" dataDir="data"/>
</cores>
</solr>
' > $SOLR_HOME/solr.xml
# tomcat'i baslat
./apache-tomcat-$TOMCAT_VER/bin/startup.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment