mirror of
https://github.com/bitnami/containers.git
synced 2026-03-14 14:58:01 +08:00
Support multiple cores via SOLR_CORES (#37)
Introduces the ability to support creating multiple Solr cores when using Solr in standalone mode. The Cores API will only support creating additional cores IF the core data and configuration directories already exist. This new environment variable SOLR_CORES supports a comma, semi-colon or space separated list of cores to create at first run.
This commit is contained in:
committed by
GitHub
parent
681ffabf98
commit
e347addc0b
@@ -112,7 +112,7 @@ solr_validate() {
|
||||
! is_yes_no_value "$SOLR_ENABLE_CLOUD_MODE" && print_validation_error "SOLR_ENABLE_CLOUD_MODE possible values are yes or no"
|
||||
is_boolean_yes "$SOLR_ENABLE_CLOUD_MODE" && [[ -z "$SOLR_ZK_HOSTS" ]] && print_validation_error "You need to provide the Zookeper node list in SOLR_ZK_HOSTS"
|
||||
|
||||
! is_boolean_yes "$SOLR_CLOUD_BOOTSTRAP" && is_boolean_yes "$SOLR_ENABLE_CLOUD_MODE" && [[ -n "$SOLR_CORE" ]] && info "This node is not a boostrap node and will not create the collection"
|
||||
! is_boolean_yes "$SOLR_CLOUD_BOOTSTRAP" && is_boolean_yes "$SOLR_ENABLE_CLOUD_MODE" && [[ -n "$SOLR_CORES" ]] && info "This node is not a boostrap node and will not create the collection"
|
||||
|
||||
! is_true_false_value "$SOLR_SSL_CHECK_PEER_NAME" && print_validation_error "SOLR_SSL_CHECK_PEER_NAME possible values are true or false"
|
||||
|
||||
@@ -171,12 +171,11 @@ solr_wait_for_zookeeper() {
|
||||
# Globals:
|
||||
# SOLR_*
|
||||
# Arguments:
|
||||
# $1 - Core name
|
||||
# None
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
solr_create_core() {
|
||||
local -r core="${1:?Missing core}"
|
||||
solr_create_cores() {
|
||||
local -r exec="curl"
|
||||
local command_args=("--silent" "--fail")
|
||||
local protocol="http"
|
||||
@@ -185,20 +184,24 @@ solr_create_core() {
|
||||
|
||||
is_boolean_yes "$SOLR_ENABLE_AUTHENTICATION" && command_args+=("--user" "${SOLR_ADMIN_USERNAME}:${SOLR_ADMIN_PASSWORD}")
|
||||
|
||||
mkdir -p "${SOLR_SERVER_DIR}/solr/${core}/data"
|
||||
mkdir -p "${SOLR_SERVER_DIR}/solr/${core}/conf"
|
||||
cp -r "${SOLR_CORE_CONF_DIR}"/* "${SOLR_SERVER_DIR}/solr/${core}/conf/"
|
||||
read -r -a cores <<< "$(tr ',;' ' ' <<< "${SOLR_CORES}")"
|
||||
info "Creating cores..."
|
||||
for core in "${cores[@]}"; do
|
||||
mkdir -p "${SOLR_SERVER_DIR}/solr/${core}/data"
|
||||
mkdir -p "${SOLR_SERVER_DIR}/solr/${core}/conf"
|
||||
cp -r "${SOLR_CORE_CONF_DIR}"/* "${SOLR_SERVER_DIR}/solr/${core}/conf/"
|
||||
|
||||
command_args+=("${protocol}://localhost:${SOLR_PORT_NUMBER}/solr/admin/cores?action=CREATE&name=${core}&instanceDir=${core}&dataDir=data")
|
||||
command_args+=("${protocol}://localhost:${SOLR_PORT_NUMBER}/solr/admin/cores?action=CREATE&name=${core}&instanceDir=${core}&dataDir=data")
|
||||
|
||||
info "Creating solr core: ${SOLR_CORE}"
|
||||
info "Creating solr core: ${core}"
|
||||
|
||||
if ! debug_execute "$exec" "${command_args[@]}" >/dev/null; then
|
||||
error "There was an error when creating the core"
|
||||
exit 1
|
||||
else
|
||||
info "Core created"
|
||||
fi
|
||||
if ! debug_execute "$exec" "${command_args[@]}" >/dev/null; then
|
||||
error "There was an error when creating the core"
|
||||
exit 1
|
||||
else
|
||||
info "Core created"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#########################
|
||||
@@ -623,7 +626,7 @@ solr_initialize() {
|
||||
|
||||
is_boolean_yes "$SOLR_ENABLE_AUTHENTICATION" && solr_update_password "$SOLR_ADMIN_USERNAME" "$SOLR_ADMIN_PASSWORD"
|
||||
|
||||
[[ -n "$SOLR_CORE" ]] && solr_create_core "$SOLR_CORE"
|
||||
[[ -n "$SOLR_CORES" ]] && solr_create_cores
|
||||
|
||||
solr_stop
|
||||
fi
|
||||
|
||||
@@ -27,7 +27,7 @@ solr_env_vars=(
|
||||
SOLR_HEAP
|
||||
SOLR_JAVA_MEM
|
||||
SOLR_PORT_NUMBER
|
||||
SOLR_CORE
|
||||
SOLR_CORES
|
||||
SOLR_COLLECTION
|
||||
SOLR_COLLECTION_REPLICAS
|
||||
SOLR_COLLECTION_SHARDS
|
||||
@@ -77,7 +77,7 @@ export SOLR_HEAP="${SOLR_HEAP:-}"
|
||||
export SOLR_JAVA_MEM="${SOLR_JAVA_MEM:--Xms512m -Xmx512m}"
|
||||
export SOLR_PORT_NUMBER="${SOLR_PORT_NUMBER:-8983}"
|
||||
export SOLR_PID_FILE="${SOLR_PID_DIR}/solr-${SOLR_PORT_NUMBER}.pid"
|
||||
export SOLR_CORE="${SOLR_CORE:-}"
|
||||
export SOLR_CORES="${SOLR_CORES:-}"
|
||||
SOLR_COLLECTION="${SOLR_COLLECTION:-"${SOLR_COLLECTION:-}"}"
|
||||
export SOLR_COLLECTION="${SOLR_COLLECTION:-}"
|
||||
export SOLR_COLLECTION_REPLICAS="${SOLR_COLLECTION_REPLICAS:-1}"
|
||||
|
||||
@@ -150,7 +150,7 @@ When you start the solr image, you can adjust the configuration of the instance
|
||||
|
||||
- `SOLR_PORT_NUMBER`: Port used by Solr server. Default: **8983**
|
||||
- `SOLR_SERVER_DIR`: Specify the Solr server directory. Default: **/opt/bitnami/solr/server**
|
||||
- `SOLR_CORE`: Core name to create at first run. By default, it will not create a core. (E.g.: '**my_core**')
|
||||
- `SOLR_CORES`: Comma, semi-colon or space separated list of cores to create at first run. By default, it will not create a core. (E.g.: '**my_dev_core,my_test_core**')
|
||||
- `SOLR_CORE_CONF_DIR`: Configuration directory to copy when creating a new core. Default: **data_driven_schema_configs**
|
||||
|
||||
Cluster related environment variables:
|
||||
@@ -186,14 +186,14 @@ This requires a minor change to the [`docker-compose.yml`](https://github.com/bi
|
||||
solr:
|
||||
...
|
||||
environment:
|
||||
- SOLR_CORE=my_core
|
||||
- SOLR_CORES=my_core
|
||||
...
|
||||
```
|
||||
|
||||
### Specifying Environment Variables on the Docker command line
|
||||
|
||||
```console
|
||||
$ docker run -d -e SOLR_CORE=my_core --name solr bitnami/solr:latest
|
||||
$ docker run -d -e SOLR_CORES=my_core --name solr bitnami/solr:latest
|
||||
```
|
||||
|
||||
## Using your Apache Solr Cores configuration files
|
||||
|
||||
Reference in New Issue
Block a user