Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
Added solr role
Browse files Browse the repository at this point in the history
  • Loading branch information
cudevmaxwell committed Sep 20, 2018
1 parent 88b6d7d commit bc15301
Show file tree
Hide file tree
Showing 9 changed files with 381 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
roles/fedora4/files/fcrepo-webapp-*.war
roles/solr/files/solr-*.tgz
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ However, some software is installed at a specific version:

* Java 1.8 (OpenJDK)
* Fedora Repository 4.7.5
* Solr 7.4.0

Nginx is installed using that project's pre-built packages for the stable version, and not the default distribution repositories.
50 changes: 37 additions & 13 deletions prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly SCRIPT_DIR

# Fedora 4 constants
readonly FEDORA4_WAR_FILE="fcrepo-webapp-4.7.5.war"
readonly FEDORA4_DOWNLOAD_URL="https://github.com/fcrepo4/fcrepo4/releases/download/fcrepo-4.7.5/fcrepo-webapp-4.7.5.war"
readonly FEDORA4_MD5_HASH="97f265441da5641baa1a8df73ae77765"
readonly FEDORA4_WAR_FILE_LOCATION="$SCRIPT_DIR/roles/fedora4/files/$FEDORA4_WAR_FILE"
readonly FEDORA4_FILE_LOCATION="$SCRIPT_DIR/roles/fedora4/files/fcrepo-webapp-4.7.5.war"

# Solr 7 constants
readonly SOLR7_DOWNLOAD_URL="https://mirror.csclub.uwaterloo.ca/apache/lucene/solr/7.4.0/solr-7.4.0.tgz"
readonly SOLR7_SHA1_HASH="18ac829bcda555de3ff679a0ccd4e263ed9d49a8"
readonly SOLR7_FILE_LOCATION="$SCRIPT_DIR/roles/solr/files/solr-7.4.0.tgz"


# Print message to stderr and exit
err() {
Expand All @@ -37,12 +42,21 @@ err() {
# file_location
# expected_hash
check_hash_match() {
local file_location="$1"
local expected_hash="$2"
local hash_function="$1"
local file_location="$2"
local expected_hash="$3"
local current_hash
current_hash=$(md5sum $1 | cut -d ' ' -f 1)

if [ "$hash_function" == "md5" ]; then
current_hash=$(md5sum $file_location | cut -d ' ' -f 1)
elif [ "$hash_function" == "sha1" ]; then
current_hash=$(sha1sum $file_location | cut -d ' ' -f 1)
else
err "Error - Unexpected hash function $hash_function."
fi

if [ ! "$current_hash" == "$expected_hash" ]; then
err "Error - File at $1 has the wrong MD5 hash. It is recommended that the file be deleted and re-downloaded. Got $current_hash, expected $expected_hash."
err "Error - File at $1 has the wrong $hash_function hash. It is recommended that the file be deleted and re-downloaded. Got $current_hash, expected $expected_hash."
fi
}

Expand All @@ -54,18 +68,28 @@ check_command_exists(){
fi
}

# Download any files required by the fedora4 role
prepare_fedora4_role() {
if [ ! -f $FEDORA4_WAR_FILE_LOCATION ]; then
echo "$FEDORA4_WAR_FILE does not exist in the expected location, downloading from $FEDORA4_DOWNLOAD_URL"
curl --silent --show-error -L $FEDORA4_DOWNLOAD_URL --output $FEDORA4_WAR_FILE_LOCATION
# Download a file and verify its integrity.
# Arguments:
# file_location
# download_url
# hash_function
# expected_hash
download_and_verify() {
local file_location="$1"
local download_url="$2"
local hash_function="$3"
local expected_hash="$4"
if [ ! -f $file_location ]; then
echo "$file_location does not exist, downloading from $download_url"
curl --silent --show-error -L $download_url --output $file_location
fi
check_hash_match $FEDORA4_WAR_FILE_LOCATION $FEDORA4_MD5_HASH
check_hash_match $hash_function $file_location $expected_hash
}

main() {
check_command_exists curl
prepare_fedora4_role
download_and_verify $FEDORA4_FILE_LOCATION $FEDORA4_DOWNLOAD_URL md5 $FEDORA4_MD5_HASH
download_and_verify $SOLR7_FILE_LOCATION $SOLR7_DOWNLOAD_URL sha1 $SOLR7_SHA1_HASH
}
main

25 changes: 25 additions & 0 deletions roles/solr/files/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Logging level
solr.log=logs
log4j.rootLogger=INFO, file, CONSOLE

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender

log4j.appender.CONSOLE.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%-4r %-5p (%t) [%X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n

#- size rotation with log cleanup.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=4MB
log4j.appender.file.MaxBackupIndex=9

#- File to log to and log format
log4j.appender.file.File=/var/log/solr/solr.log
log4j.appender.file.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p (%t) [%X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m\n

log4j.logger.org.apache.zookeeper=WARN
log4j.logger.org.apache.hadoop=WARN

# set to INFO to enable infostream log messages
log4j.logger.org.apache.solr.update.LoggingInfoStream=OFF

118 changes: 118 additions & 0 deletions roles/solr/files/solr.in.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# By default the script will use JAVA_HOME to determine which java
# to use, but you can set a specific path for Solr to use without
# affecting other Java applications on your server/workstation.
#SOLR_JAVA_HOME=""

# Increase Java Heap as needed to support your indexing / query needs
#SOLR_HEAP="512m"

# Expert: If you want finer control over memory options, specify them directly
# Comment out SOLR_HEAP if you are using this though, that takes precedence
SOLR_JAVA_MEM="-Xms1g -Xmx4g"

# Enable verbose GC logging
GC_LOG_OPTS="-verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails \
-XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime"

# These GC settings have shown to work well for a number of common Solr workloads
GC_TUNE="-XX:NewRatio=3 \
-XX:SurvivorRatio=4 \
-XX:TargetSurvivorRatio=90 \
-XX:MaxTenuringThreshold=8 \
-XX:+UseConcMarkSweepGC \
-XX:+UseParNewGC \
-XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 \
-XX:+CMSScavengeBeforeRemark \
-XX:PretenureSizeThreshold=64m \
-XX:+UseCMSInitiatingOccupancyOnly \
-XX:CMSInitiatingOccupancyFraction=50 \
-XX:CMSMaxAbortablePrecleanTime=6000 \
-XX:+CMSParallelRemarkEnabled \
-XX:+ParallelRefProcEnabled"

# Set the ZooKeeper connection string if using an external ZooKeeper ensemble
# e.g. host1:2181,host2:2181/chroot
# Leave empty if not using SolrCloud
#ZK_HOST=""

# Set the ZooKeeper client timeout (for SolrCloud mode)
#ZK_CLIENT_TIMEOUT="15000"

# By default the start script uses "localhost"; override the hostname here
# for production SolrCloud environments to control the hostname exposed to cluster state
#SOLR_HOST="192.168.1.1"

# By default the start script uses UTC; override the timezone if needed
#SOLR_TIMEZONE="UTC"

# Set to true to activate the JMX RMI connector to allow remote JMX client applications
# to monitor the JVM hosting Solr; set to "false" to disable that behavior
# (false is recommended in production environments)
ENABLE_REMOTE_JMX_OPTS="false"

# The script will use SOLR_PORT+10000 for the RMI_PORT or you can set it here
# RMI_PORT=18983

# Anything you add to the SOLR_OPTS variable will be included in the java
# start command line as-is, in ADDITION to other options. If you specify the
# -a option on start script, those options will be appended as well. Examples:
#SOLR_OPTS="$SOLR_OPTS -Dsolr.autoSoftCommit.maxTime=3000"
#SOLR_OPTS="$SOLR_OPTS -Dsolr.autoCommit.maxTime=60000"
#SOLR_OPTS="$SOLR_OPTS -Dsolr.clustering.enabled=true"

# Location where the bin/solr script will save PID files for running instances
# If not set, the script will create PID files in $SOLR_TIP/bin
SOLR_PID_DIR=/var/solr

# Path to a directory for Solr to store cores and their data. By default, Solr will use server/solr
# If solr.xml is not stored in ZooKeeper, this directory needs to contain solr.xml
SOLR_HOME=/var/solr/data

# Solr provides a default Log4J configuration properties file in server/resources
# however, you may want to customize the log settings and file appender location
# so you can point the script to use a different log4j.properties file
LOG4J_PROPS=/var/solr/log4j.properties

# Location where Solr should write logs to; should agree with the file appender
# settings in server/resources/log4j.properties
SOLR_LOGS_DIR=/var/log/solr

# Sets the port Solr binds to, default is 8983
SOLR_PORT=8983

# Uncomment to set SSL-related system properties
# Be sure to update the paths to the correct keystore for your environment
#SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks
#SOLR_SSL_KEY_STORE_PASSWORD=secret
#SOLR_SSL_TRUST_STORE=etc/solr-ssl.keystore.jks
#SOLR_SSL_TRUST_STORE_PASSWORD=secret
#SOLR_SSL_NEED_CLIENT_AUTH=false
#SOLR_SSL_WANT_CLIENT_AUTH=false

# Uncomment if you want to override previously defined SSL values for HTTP client
# otherwise keep them commented and the above values will automatically be set for HTTP clients
#SOLR_SSL_CLIENT_KEY_STORE=
#SOLR_SSL_CLIENT_KEY_STORE_PASSWORD=
#SOLR_SSL_CLIENT_TRUST_STORE=
#SOLR_SSL_CLIENT_TRUST_STORE_PASSWORD=

# Settings for authentication
#SOLR_AUTHENTICATION_CLIENT_CONFIGURER=
#SOLR_AUTHENTICATION_OPTS=


13 changes: 13 additions & 0 deletions roles/solr/files/solr.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Apache Solr
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
EnvironmentFile=/var/solr/solr.in.sh
PIDFile=/var/solr/solr-8983.pid
ExecStart=/opt/solr/bin/solr start
User=solr
ExecReload=/opt/solr/bin/solr reload
ExecStop=/opt/solr/bin/solr stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
52 changes: 52 additions & 0 deletions roles/solr/files/solr.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!--
This is an example of a simple "solr.xml" file for configuring one or
more Solr Cores, as well as allowing Cores to be added, removed, and
reloaded via HTTP requests.
More information about options available in this configuration file,
and Solr Core administration can be found online:
http://wiki.apache.org/solr/CoreAdmin
-->

<solr>

<solrcloud>

<str name="host">${host:}</str>
<int name="hostPort">${jetty.port:8983}</int>
<str name="hostContext">${hostContext:solr}</str>

<bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>

<int name="zkClientTimeout">${zkClientTimeout:30000}</int>
<int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:600000}</int>
<int name="distribUpdateConnTimeout">${distribUpdateConnTimeout:60000}</int>

</solrcloud>

<shardHandlerFactory name="shardHandlerFactory"
class="HttpShardHandlerFactory">
<int name="socketTimeout">${socketTimeout:600000}</int>
<int name="connTimeout">${connTimeout:60000}</int>
</shardHandlerFactory>

</solr>

7 changes: 7 additions & 0 deletions roles/solr/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# Handlers

- name: restart solr
service:
name: solr
state: restarted
Loading

0 comments on commit bc15301

Please sign in to comment.