mirror of https://github.com/apache/lucene.git
SOLR-3617: hardening command-line parsing and a few minor bug fixes found by QA testing.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1619025 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dd1e04cc0f
commit
7223a40b6d
137
solr/bin/solr
137
solr/bin/solr
|
@ -46,7 +46,13 @@
|
|||
|
||||
SOLR_SCRIPT="$0"
|
||||
verbose=false
|
||||
isLegacyExampleDir=false
|
||||
THIS_OS=`uname -s`
|
||||
# for now, we don't support running this script from cygwin due to problems
|
||||
# like not having lsof, ps waux, curl, and awkward directory handling
|
||||
if [ "${THIS_OS:0:6}" == "CYGWIN" ]; then
|
||||
echo -e "This script does not support cygwin due to severe limitations and lack of adherence\nto BASH standards, such as lack of lsof, curl, and ps options.\n\nPlease use the native solr.cmd script on Windows!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Resolve symlinks to this script
|
||||
while [ -h "$SOLR_SCRIPT" ] ; do
|
||||
|
@ -69,7 +75,6 @@ if [ -e "$SOLR_TIP/server/start.jar" ]; then
|
|||
DEFAULT_SERVER_DIR=$SOLR_TIP/server
|
||||
else
|
||||
DEFAULT_SERVER_DIR=$SOLR_TIP/example
|
||||
isLegacyExampleDir=true
|
||||
fi
|
||||
|
||||
if [ "$SOLR_JAVA_HOME" != "" ]; then
|
||||
|
@ -93,7 +98,7 @@ function print_usage() {
|
|||
ERROR_MSG="$2"
|
||||
|
||||
if [ "$ERROR_MSG" != "" ]; then
|
||||
echo "$ERROR_MSG"
|
||||
echo -e "\nERROR: $ERROR_MSG\n"
|
||||
fi
|
||||
|
||||
if [ "$CMD" == "" ]; then
|
||||
|
@ -147,7 +152,7 @@ function print_usage() {
|
|||
echo ""
|
||||
echo " -k <key> Stop key; default is solrrocks"
|
||||
echo ""
|
||||
echo " -p <port> Specify the port to start the Solr HTTP listener on; default is 8983"
|
||||
echo " -p <port> Specify the port the Solr HTTP listener is bound to; default is 8983"
|
||||
echo ""
|
||||
echo " -V Verbose messages from this script"
|
||||
echo ""
|
||||
|
@ -301,15 +306,23 @@ if [ "$SCRIPT_CMD" == "healthcheck" ]; then
|
|||
while true; do
|
||||
case $1 in
|
||||
-c|-collection)
|
||||
if [ "${2:0:1}" == "-" ]; then
|
||||
print_usage "$SCRIPT_CMD" "$2 is not a valid collection!"
|
||||
exit 1
|
||||
fi
|
||||
HEALTHCHECK_COLLECTION=$2
|
||||
shift 2
|
||||
;;
|
||||
-z|-zkhost)
|
||||
-z|-zkhost)
|
||||
if [ "${2:0:1}" == "-" ]; then
|
||||
print_usage "$SCRIPT_CMD" "$2 is not a valid ZooKeeper connnection string!"
|
||||
exit 1
|
||||
fi
|
||||
ZK_HOST="$2"
|
||||
shift 2
|
||||
;;
|
||||
-help|-usage)
|
||||
print_usage "$SCRIPT_CMD" ""
|
||||
print_usage "$SCRIPT_CMD"
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
|
@ -318,8 +331,7 @@ if [ "$SCRIPT_CMD" == "healthcheck" ]; then
|
|||
;;
|
||||
*)
|
||||
if [ "$1" != "" ]; then
|
||||
echo "Error parsing argument $1!" >&2
|
||||
print_usage "$SCRIPT_CMD"
|
||||
print_usage "$SCRIPT_CMD" "Unrecognized or misplaced argument: $1!"
|
||||
exit 1
|
||||
else
|
||||
break # out-of-args, stop looping
|
||||
|
@ -332,6 +344,12 @@ if [ "$SCRIPT_CMD" == "healthcheck" ]; then
|
|||
if [ "$ZK_HOST" == "" ]; then
|
||||
ZK_HOST=localhost:9983
|
||||
fi
|
||||
|
||||
if [ "$HEALTHCHECK_COLLECTION" == "" ]; then
|
||||
echo "collection parameter is required!"
|
||||
print_usage "healthcheck"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run_tool healthcheck -zkHost $ZK_HOST -collection $HEALTHCHECK_COLLECTION
|
||||
|
||||
|
@ -373,6 +391,11 @@ if [ $# -gt 0 ]; then
|
|||
shift
|
||||
;;
|
||||
-d|-dir)
|
||||
if [ "${2:0:1}" == "-" ]; then
|
||||
print_usage "$SCRIPT_CMD" "$2 is not a valid directory!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# see if the arg value is relative to the tip vs full path
|
||||
if [ -d "$SOLR_TIP/$2" ]; then
|
||||
SOLR_SERVER_DIR="$SOLR_TIP/$2"
|
||||
|
@ -382,6 +405,10 @@ if [ $# -gt 0 ]; then
|
|||
shift 2
|
||||
;;
|
||||
-e|-example)
|
||||
if [ "${2:0:1}" == "-" ]; then
|
||||
print_usage "$SCRIPT_CMD" "$2 is not a valid example!"
|
||||
exit 1
|
||||
fi
|
||||
EXAMPLE="$2"
|
||||
shift 2
|
||||
;;
|
||||
|
@ -390,23 +417,40 @@ if [ $# -gt 0 ]; then
|
|||
shift
|
||||
;;
|
||||
-h|-host)
|
||||
if [ "${2:0:1}" == "-" ]; then
|
||||
print_usage "$SCRIPT_CMD" "$2 is not a valid hostname!"
|
||||
exit 1
|
||||
fi
|
||||
SOLR_HOST="$2"
|
||||
shift 2
|
||||
;;
|
||||
-m|-memory)
|
||||
if [ "${2:0:1}" == "-" ]; then
|
||||
print_usage "$SCRIPT_CMD" "$2 is not a valid memory setting!"
|
||||
exit 1
|
||||
fi
|
||||
SOLR_HEAP="$2"
|
||||
shift 2
|
||||
;;
|
||||
-p|-port)
|
||||
if [ "${2:0:1}" == "-" ]; then
|
||||
print_usage "$SCRIPT_CMD" "$2 is not a valid port!"
|
||||
exit 1
|
||||
fi
|
||||
SOLR_PORT="$2"
|
||||
shift 2
|
||||
;;
|
||||
-z|-zkhost)
|
||||
if [ "${2:0:1}" == "-" ]; then
|
||||
print_usage "$SCRIPT_CMD" "$2 is not a valid ZooKeeper connection string!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ZK_HOST="$2"
|
||||
shift 2
|
||||
;;
|
||||
-help|-usage)
|
||||
print_usage "$SCRIPT_CMD" ""
|
||||
print_usage "$SCRIPT_CMD"
|
||||
exit 0
|
||||
;;
|
||||
-noprompt)
|
||||
|
@ -423,8 +467,7 @@ if [ $# -gt 0 ]; then
|
|||
;;
|
||||
*)
|
||||
if [ "$1" != "" ]; then
|
||||
echo "Error parsing argument $1!" >&2
|
||||
print_usage "$SCRIPT_CMD"
|
||||
print_usage "$SCRIPT_CMD" "Error parsing argument $1!"
|
||||
exit 1
|
||||
else
|
||||
break # out-of-args, stop looping
|
||||
|
@ -636,7 +679,13 @@ if [ "$SOLR_MODE" == "solrcloud" ]; then
|
|||
fi
|
||||
|
||||
CLOUD_MODE_OPTS="$CLOUD_MODE_OPTS -DzkRun"
|
||||
|
||||
# and if collection1 needs to be bootstrapped
|
||||
if [ -e "$SOLR_HOME/collection1/core.properties" ]; then
|
||||
CLOUD_MODE_OPTS="$CLOUD_MODE_OPTS -Dbootstrap_confdir=./solr/collection1/conf -Dcollection.configName=myconf"
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# These are useful for attaching remove profilers like VisualVM/JConsole
|
||||
|
@ -723,6 +772,7 @@ $SOLR_HOST_ARG -Djetty.port=$SOLR_PORT \
|
|||
# run Solr in the background
|
||||
nohup $JAVA $SOLR_START_OPTS $SOLR_ADDL_ARGS -XX:OnOutOfMemoryError="$SOLR_TIP/bin/oom_solr.sh $SOLR_PORT" -jar start.jar 1>$SOLR_TIP/bin/solr-$SOLR_PORT-console.log 2>&1 &
|
||||
|
||||
# no lsof on cygwin though
|
||||
echo -n "Waiting to see Solr listening on port $SOLR_PORT"
|
||||
# Launch in a subshell to show the spinner
|
||||
(loops=0
|
||||
|
@ -745,7 +795,6 @@ $SOLR_HOST_ARG -Djetty.port=$SOLR_PORT \
|
|||
fi
|
||||
done) &
|
||||
spinner $!
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -760,14 +809,9 @@ else
|
|||
SOLR_PORT=${CLOUD_PORTS[0]}
|
||||
echo -e "\nStarting up SolrCloud node1 on port ${CLOUD_PORTS[0]} using command:\n"
|
||||
echo -e "solr start -cloud -d node1 -p $SOLR_PORT \n\n"
|
||||
|
||||
if $isLegacyExampleDir ; then
|
||||
# have to pass these when working with the legacy example directory
|
||||
BOOTSTRAP_ARGS="-Dbootstrap_confdir=./solr/collection1/conf -Dcollection.configName=myconf"
|
||||
fi
|
||||
|
||||
|
||||
# can't launch this node in the foreground else we can't run anymore commands
|
||||
launch_solr "false" "$BOOTSTRAP_ARGS"
|
||||
launch_solr "false" ""
|
||||
|
||||
zk_port=$[$SOLR_PORT+1000]
|
||||
zk_host=localhost:$zk_port
|
||||
|
@ -784,20 +828,20 @@ else
|
|||
|
||||
# TODO: better (shorter) name??
|
||||
CLOUD_COLLECTION=gettingstarted
|
||||
|
||||
# if the new default config directory is available, then use it,
|
||||
# otherwise, use the schema-less example
|
||||
if [ -d "$SOLR_TIP/server/solr/default_conf" ]; then
|
||||
CLOUD_CONFIG_DIR=$SOLR_TIP/server/solr/default_conf
|
||||
else
|
||||
CLOUD_CONFIG_DIR=$SOLR_TIP/example/example-schemaless/solr/collection1/conf
|
||||
fi
|
||||
|
||||
CLOUD_CONFIG=schemaless
|
||||
|
||||
|
||||
if $noprompt ; then
|
||||
CLOUD_NUM_SHARDS=2
|
||||
CLOUD_REPFACT=2
|
||||
CLOUD_REPFACT=2
|
||||
# if the new default config directory is available, then use it,
|
||||
# otherwise, use the legacy collection1 example
|
||||
# TODO: this will need to change when SOLR-3619 is resolved
|
||||
if [ -d "$SOLR_TIP/server/solr/configsets/schemaless" ]; then
|
||||
CLOUD_CONFIG_DIR=$SOLR_TIP/server/solr/configsets/schemaless
|
||||
CLOUD_CONFIG=schemaless
|
||||
else
|
||||
CLOUD_CONFIG_DIR=$SOLR_TIP/example/solr/collection1/conf
|
||||
CLOUD_CONFIG=default
|
||||
fi
|
||||
else
|
||||
echo -e "\nNow let's create a new collection for indexing documents in your $CLOUD_NUM_NODES-node cluster.\n"
|
||||
read -e -p "Please provide a name for your new collection: [gettingstarted] " USER_INPUT
|
||||
|
@ -810,6 +854,7 @@ else
|
|||
fi
|
||||
echo $CLOUD_COLLECTION
|
||||
|
||||
USER_INPUT=
|
||||
read -e -p "How many shards would you like to split $CLOUD_COLLECTION into? [2] " USER_INPUT
|
||||
# trim whitespace out of the user input
|
||||
CLOUD_NUM_SHARDS=`echo $USER_INPUT | tr -d ' '`
|
||||
|
@ -820,6 +865,7 @@ else
|
|||
fi
|
||||
echo $CLOUD_NUM_SHARDS
|
||||
|
||||
USER_INPUT=
|
||||
read -e -p "How many replicas per shard would you like to create? [2] " USER_INPUT
|
||||
# trim whitespace out of the user input
|
||||
CLOUD_REPFACT=`echo $USER_INPUT | tr -d ' '`
|
||||
|
@ -830,8 +876,28 @@ else
|
|||
fi
|
||||
echo $CLOUD_REPFACT
|
||||
|
||||
USER_INPUT=
|
||||
read -e -p "Please choose a configuration for the $CLOUD_COLLECTION collection, available options are: default or schemaless [default] " USER_INPUT
|
||||
# trim whitespace out of the user input
|
||||
CLOUD_CONFIG=`echo $USER_INPUT | tr -d ' '`
|
||||
|
||||
# handle the default selection or empty input
|
||||
if [ "$CLOUD_CONFIG" == "" ]; then
|
||||
CLOUD_CONFIG=default
|
||||
fi
|
||||
echo $CLOUD_CONFIG
|
||||
|
||||
if [ "$CLOUD_CONFIG" == "schemaless" ]; then
|
||||
if [ -d "$SOLR_TIP/server/solr/configsets/schemaless" ]; then
|
||||
CLOUD_CONFIG_DIR=$SOLR_TIP/server/solr/configsets/schemaless
|
||||
else
|
||||
CLOUD_CONFIG_DIR=$SOLR_TIP/example/example-schemaless/solr/collection1/conf
|
||||
fi
|
||||
else
|
||||
CLOUD_CONFIG_DIR=$SOLR_TIP/example/solr/collection1/conf
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo -e "\nDeploying default Solr configuration files to embedded ZooKeeper using command:\n"
|
||||
echo -e "$DEFAULT_SERVER_DIR/scripts/cloud-scripts/zkcli.sh -zkhost $zk_host -cmd upconfig -confdir $CLOUD_CONFIG_DIR -confname $CLOUD_CONFIG\n"
|
||||
# upload the config directory to ZooKeeper
|
||||
|
@ -842,7 +908,7 @@ else
|
|||
$JAVA -Dlog4j.configuration=file:$DEFAULT_SERVER_DIR/scripts/cloud-scripts/log4j.properties \
|
||||
-classpath "$DEFAULT_SERVER_DIR/solr-webapp/webapp/WEB-INF/lib/*:$DEFAULT_SERVER_DIR/lib/ext/*" \
|
||||
org.apache.solr.cloud.ZkCLI -zkhost $zk_host -cmd upconfig -confdir $CLOUD_CONFIG_DIR -confname $CLOUD_CONFIG > /dev/null 2>&1
|
||||
echo -e "Successfully deployed $CLOUD_CONFIG to ZooKeeper\n"
|
||||
echo -e "Successfully deployed the $CLOUD_CONFIG_DIR configuration directory to ZooKeeper as $CLOUD_CONFIG\n"
|
||||
|
||||
# note use of ceiling logic in case of remainder
|
||||
MAX_SHARDS_PER_NODE=$((($CLOUD_NUM_SHARDS*$CLOUD_REPFACT+$CLOUD_NUM_NODES-1)/$CLOUD_NUM_NODES))
|
||||
|
@ -850,9 +916,8 @@ else
|
|||
COLLECTIONS_API=http://localhost:$SOLR_PORT/solr/admin/collections
|
||||
|
||||
CLOUD_CREATE_COLLECTION_CMD="$COLLECTIONS_API?action=CREATE&name=$CLOUD_COLLECTION&replicationFactor=$CLOUD_REPFACT&numShards=$CLOUD_NUM_SHARDS&collection.configName=$CLOUD_CONFIG&maxShardsPerNode=$MAX_SHARDS_PER_NODE&wt=json&indent=2"
|
||||
echo -e "\n\nCreating new collection $CLOUD_COLLECTION with $CLOUD_NUM_SHARDS shards and replication factor $CLOUD_REPFACT using Collections API command:\n\n$CLOUD_CREATE_COLLECTION_CMD\n\nFor more information about the Collections API, please see: https://cwiki.apache.org/confluence/display/solr/Collections+API\n"
|
||||
curl "$CLOUD_CREATE_COLLECTION_CMD"
|
||||
|
||||
echo -e "\n\nCreating new collection $CLOUD_COLLECTION with $CLOUD_NUM_SHARDS shards and replication factor $CLOUD_REPFACT using Collections API command:\n\n$CLOUD_CREATE_COLLECTION_CMD\n\nFor more information about the Collections API, please see: https://cwiki.apache.org/confluence/display/solr/Collections+API\n"
|
||||
curl "$CLOUD_CREATE_COLLECTION_CMD"
|
||||
echo -e "\n\nSolrCloud example running, please visit http://localhost:$SOLR_PORT/solr \n\n"
|
||||
fi
|
||||
|
||||
|
|
|
@ -207,6 +207,14 @@ SHIFT
|
|||
goto parse_args
|
||||
|
||||
:set_server_dir
|
||||
|
||||
set "arg=%2"
|
||||
set firstChar=%arg:~0,1%
|
||||
IF "%firstChar%"=="-" (
|
||||
set SCRIPT_ERROR=%2 is not a valid directory!
|
||||
goto invalid_cmd_line
|
||||
)
|
||||
|
||||
REM See if they are using a short-hand name relative from the Solr tip directory
|
||||
IF EXIST "%SOLR_TIP%\%2" (
|
||||
set "SOLR_SERVER_DIR=%SOLR_TIP%\%2"
|
||||
|
@ -218,12 +226,28 @@ SHIFT
|
|||
goto parse_args
|
||||
|
||||
:set_example
|
||||
|
||||
set "arg=%2"
|
||||
set firstChar=%arg:~0,1%
|
||||
IF "%firstChar%"=="-" (
|
||||
set SCRIPT_ERROR=%2 is not a valid example!
|
||||
goto invalid_cmd_line
|
||||
)
|
||||
|
||||
set EXAMPLE=%2
|
||||
SHIFT
|
||||
SHIFT
|
||||
goto parse_args
|
||||
|
||||
:set_memory
|
||||
|
||||
set "arg=%2"
|
||||
set firstChar=%arg:~0,1%
|
||||
IF "%firstChar%"=="-" (
|
||||
set SCRIPT_ERROR=%2 is not a valid memory setting!
|
||||
goto invalid_cmd_line
|
||||
)
|
||||
|
||||
set SOLR_HEAP=%2
|
||||
@echo SOLR_HEAP=%SOLR_HEAP%
|
||||
SHIFT
|
||||
|
@ -231,18 +255,40 @@ SHIFT
|
|||
goto parse_args
|
||||
|
||||
:set_host
|
||||
set "arg=%2"
|
||||
set firstChar=%arg:~0,1%
|
||||
IF "%firstChar%"=="-" (
|
||||
set SCRIPT_ERROR=%2 is not a valid hostname!
|
||||
goto invalid_cmd_line
|
||||
)
|
||||
|
||||
set SOLR_HOST=%2
|
||||
SHIFT
|
||||
SHIFT
|
||||
goto parse_args
|
||||
|
||||
:set_port
|
||||
set "arg=%2"
|
||||
set firstChar=%arg:~0,1%
|
||||
IF "%firstChar%"=="-" (
|
||||
set SCRIPT_ERROR=%2 is not a valid port!
|
||||
goto invalid_cmd_line
|
||||
)
|
||||
|
||||
set SOLR_PORT=%2
|
||||
SHIFT
|
||||
SHIFT
|
||||
goto parse_args
|
||||
|
||||
:set_zookeeper
|
||||
|
||||
set "arg=%2"
|
||||
set firstChar=%arg:~0,1%
|
||||
IF "%firstChar%"=="-" (
|
||||
set SCRIPT_ERROR=%2 is not a valid ZooKeeper connection string!
|
||||
goto invalid_cmd_line
|
||||
)
|
||||
|
||||
set "ZK_HOST=%2"
|
||||
SHIFT
|
||||
SHIFT
|
||||
|
@ -272,7 +318,7 @@ REM TODO: Change this to "server" when we resolve SOLR-3619
|
|||
IF "%SOLR_SERVER_DIR%"=="" set SOLR_SERVER_DIR=%DEFAULT_SERVER_DIR%
|
||||
|
||||
IF NOT EXIST "%SOLR_SERVER_DIR%" (
|
||||
set SCRIPT_ERROR='Solr server directory %SOLR_SERVER_DIR% not found!'
|
||||
set SCRIPT_ERROR=Solr server directory %SOLR_SERVER_DIR% not found!
|
||||
goto err
|
||||
)
|
||||
|
||||
|
@ -348,16 +394,17 @@ REM if verbose gc logging enabled, setup the location of the log file
|
|||
IF NOT "%GC_LOG_OPTS%"=="" set GC_LOG_OPTS=%GC_LOG_OPTS% -Xloggc:"%SOLR_SERVER_DIR%/logs/solr_gc.log"
|
||||
|
||||
IF "%SOLR_MODE%"=="solrcloud" (
|
||||
IF "%ZK_CLIENT_TIMEOUT%"=="" set ZK_CLIENT_TIMEOUT=15000
|
||||
IF "%ZK_CLIENT_TIMEOUT%"=="" set "ZK_CLIENT_TIMEOUT=15000"
|
||||
|
||||
set CLOUD_MODE_OPTS=-DzkClientTimeout=%ZK_CLIENT_TIMEOUT%
|
||||
set "CLOUD_MODE_OPTS=-DzkClientTimeout=!ZK_CLIENT_TIMEOUT!"
|
||||
|
||||
IF NOT "%ZK_HOST%"=="" (
|
||||
set "CLOUD_MODE_OPTS=%CLOUD_MODE_OPTS% -DzkHost=%ZK_HOST%"
|
||||
set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -DzkHost=%ZK_HOST%"
|
||||
) ELSE (
|
||||
IF "%verbose%"=="1" echo 'Configuring SolrCloud to launch an embedded ZooKeeper using -DzkRun'
|
||||
set "CLOUD_MODE_OPTS=%CLOUD_MODE_OPTS% -DzkRun"
|
||||
)
|
||||
IF "%verbose%"=="1" echo Configuring SolrCloud to launch an embedded ZooKeeper using -DzkRun
|
||||
set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -DzkRun"
|
||||
IF EXIST "%SOLR_HOME%\collection1\core.properties" set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -Dbootstrap_confdir=./solr/collection1/conf -Dcollection.configName=myconf"
|
||||
)
|
||||
) ELSE (
|
||||
set CLOUD_MODE_OPTS=
|
||||
)
|
||||
|
@ -397,12 +444,12 @@ IF "%verbose%"=="1" (
|
|||
|
||||
set START_OPTS=-Duser.timezone=%SOLR_TIMEZONE% -Djava.net.preferIPv4Stack=true -Dsolr.autoSoftCommit.maxTime=3000
|
||||
set START_OPTS=%START_OPTS% %GC_TUNE% %GC_LOG_OPTS%
|
||||
IF NOT "%CLOUD_MODE_OPTS%"=="" set START_OPTS=%START_OPTS% %CLOUD_MODE_OPTS%
|
||||
IF NOT "!CLOUD_MODE_OPTS!"=="" set START_OPTS=%START_OPTS% !CLOUD_MODE_OPTS!
|
||||
IF NOT "%REMOTE_JMX_OPTS%"=="" set START_OPTS=%START_OPTS% %REMOTE_JMX_OPTS%
|
||||
IF NOT "%SOLR_ADDL_ARGS%"=="" set START_OPTS=%START_OPTS% %SOLR_ADDL_ARGS%
|
||||
IF NOT "%SOLR_HOST_ARG%"=="" set START_OPTS=%START_OPTS% %SOLR_HOST_ARG%
|
||||
|
||||
cd %SOLR_SERVER_DIR%
|
||||
cd "%SOLR_SERVER_DIR%"
|
||||
@echo.
|
||||
@echo Starting Solr on port %SOLR_PORT% from %SOLR_SERVER_DIR%
|
||||
@echo.
|
||||
|
@ -411,7 +458,7 @@ IF "%FG%"=="1" (
|
|||
"%JAVA%" -server -Xss256k %SOLR_JAVA_MEM% %START_OPTS% -DSTOP.PORT=%STOP_PORT% -DSTOP.KEY=%STOP_KEY% ^
|
||||
-Djetty.port=%SOLR_PORT% -Dsolr.solr.home="%SOLR_HOME%" -jar start.jar
|
||||
) ELSE (
|
||||
START %JAVA% -server -Xss256k %SOLR_JAVA_MEM% %START_OPTS% -DSTOP.PORT=%STOP_PORT% -DSTOP.KEY=%STOP_KEY% ^
|
||||
START "" "%JAVA%" -server -Xss256k %SOLR_JAVA_MEM% %START_OPTS% -DSTOP.PORT=%STOP_PORT% -DSTOP.KEY=%STOP_KEY% ^
|
||||
-Djetty.port=%SOLR_PORT% -Dsolr.solr.home="%SOLR_HOME%" -jar start.jar > "%SOLR_TIP%\bin\solr-%SOLR_PORT%-console.log"
|
||||
)
|
||||
|
||||
|
@ -482,12 +529,12 @@ for /l %%x in (1, 1, !CLOUD_NUM_NODES!) do (
|
|||
|
||||
IF %%x EQU 1 (
|
||||
set EXAMPLE=
|
||||
START %SDIR%\solr -f -c -p !NODE_PORT! -d node1
|
||||
START "" "%SDIR%\solr" -f -c -p !NODE_PORT! -d node1
|
||||
set NODE1_PORT=!NODE_PORT!
|
||||
) ELSE (
|
||||
set /A ZK_PORT=!NODE1_PORT!+1000
|
||||
set "ZK_HOST=localhost:!ZK_PORT!"
|
||||
START %SDIR%\solr -f -c -p !NODE_PORT! -d node%%x -z !ZK_HOST!
|
||||
START "" "%SDIR%\solr" -f -c -p !NODE_PORT! -d node%%x -z !ZK_HOST!
|
||||
)
|
||||
|
||||
timeout /T 10
|
||||
|
@ -500,6 +547,8 @@ IF "%NO_USER_PROMPT%"=="1" (
|
|||
set CLOUD_COLLECTION=gettingstarted
|
||||
set CLOUD_NUM_SHARDS=2
|
||||
set CLOUD_REPFACT=2
|
||||
set CLOUD_CONFIG=default
|
||||
set "CLOUD_CONFIG_DIR=%SOLR_TIP%\example\solr\collection1\conf"
|
||||
goto create_collection
|
||||
) ELSE (
|
||||
goto get_create_collection_params
|
||||
|
@ -522,25 +571,35 @@ set /P "USER_INPUT=How many replicas per shard would you like to create? [2] "
|
|||
IF "!USER_INPUT!"=="" set USER_INPUT=2
|
||||
set CLOUD_REPFACT=!USER_INPUT!
|
||||
echo !CLOUD_REPFACT!
|
||||
set USER_INPUT=
|
||||
echo.
|
||||
set /P "USER_INPUT=Please choose a configuration for the !CLOUD_COLLECTION! collection, available options are: default or schemaless [default] "
|
||||
IF "!USER_INPUT!"=="" set USER_INPUT=default
|
||||
set CLOUD_CONFIG=!USER_INPUT!
|
||||
echo !CLOUD_CONFIG!
|
||||
|
||||
IF "!CLOUD_CONFIG!"=="schemaless" (
|
||||
IF EXIST "%SOLR_TIP%\server\solr\configsets\schemaless" set "CLOUD_CONFIG_DIR=%SOLR_TIP%\server\solr\configsets\schemaless"
|
||||
IF NOT EXIST "%SOLR_TIP%\server\solr\configsets\schemaless" set "CLOUD_CONFIG_DIR=%SOLR_TIP%\example\example-schemaless\solr\collection1\conf"
|
||||
) ELSE (
|
||||
set "CLOUD_CONFIG_DIR=%SOLR_TIP%\example\solr\collection1\conf"
|
||||
)
|
||||
|
||||
goto create_collection
|
||||
|
||||
:create_collection
|
||||
set /A MAX_SHARDS_PER_NODE=((!CLOUD_NUM_SHARDS!*!CLOUD_REPFACT!)/!CLOUD_NUM_NODES!)+1
|
||||
|
||||
IF EXIST "%SOLR_TIP%\server\solr\default_conf" set "CLOUD_CONFIG_DIR=%SOLR_TIP%\server\solr\default_conf"
|
||||
IF NOT EXIST "%SOLR_TIP%\server\solr\default_conf" set "CLOUD_CONFIG_DIR=%SOLR_TIP%\example\example-schemaless\solr\collection1\conf"
|
||||
set CLOUD_CONFIG=schemaless
|
||||
|
||||
echo.
|
||||
echo Deploying default Solr configuration files to embedded ZooKeeper
|
||||
echo.
|
||||
"%JAVA%" -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
|
||||
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
|
||||
org.apache.solr.cloud.ZkCLI -zkhost %zk_host% -cmd upconfig -confdir "%CLOUD_CONFIG_DIR%" -confname %CLOUD_CONFIG%
|
||||
org.apache.solr.cloud.ZkCLI -zkhost %zk_host% -cmd upconfig -confdir "!CLOUD_CONFIG_DIR!" -confname !CLOUD_CONFIG!
|
||||
|
||||
set COLLECTIONS_API=http://localhost:!NODE1_PORT!/solr/admin/collections
|
||||
|
||||
set "CLOUD_CREATE_COLLECTION_CMD=%COLLECTIONS_API%?action=CREATE&name=%CLOUD_COLLECTION%&replicationFactor=%CLOUD_REPFACT%&numShards=%CLOUD_NUM_SHARDS%&collection.configName=%CLOUD_CONFIG%&maxShardsPerNode=%MAX_SHARDS_PER_NODE%&wt=json&indent=2"
|
||||
set "CLOUD_CREATE_COLLECTION_CMD=%COLLECTIONS_API%?action=CREATE&name=%CLOUD_COLLECTION%&replicationFactor=%CLOUD_REPFACT%&numShards=%CLOUD_NUM_SHARDS%&collection.configName=!CLOUD_CONFIG!&maxShardsPerNode=%MAX_SHARDS_PER_NODE%&wt=json&indent=2"
|
||||
echo Creating new collection %CLOUD_COLLECTION% with %CLOUD_NUM_SHARDS% shards and replication factor %CLOUD_REPFACT% using Collections API command:
|
||||
echo.
|
||||
@echo "%CLOUD_CREATE_COLLECTION_CMD%"
|
||||
|
@ -618,7 +677,11 @@ goto done
|
|||
|
||||
:invalid_cmd_line
|
||||
@echo.
|
||||
@echo Invalid command-line option: %1
|
||||
IF "!SCRIPT_ERROR!"=="" (
|
||||
@echo Invalid command-line option: %1
|
||||
) ELSE (
|
||||
@echo ERROR: !SCRIPT_ERROR!
|
||||
)
|
||||
@echo.
|
||||
IF "%FIRST_ARG%"=="start" (
|
||||
goto start_usage
|
||||
|
@ -644,7 +707,7 @@ goto done
|
|||
|
||||
:err
|
||||
@echo.
|
||||
@echo %SCRIPT_ERROR%
|
||||
@echo ERROR: !SCRIPT_ERROR!
|
||||
@echo.
|
||||
exit /b 1
|
||||
|
||||
|
|
|
@ -43,8 +43,11 @@ GC_TUNE="-XX:-UseSuperWord \
|
|||
-XX:+ParallelRefProcEnabled \
|
||||
-XX:+AggressiveOpts"
|
||||
|
||||
# Mac OSX and Cygwin don't seem to like the UseLargePages flag
|
||||
thisOs=`uname -s`
|
||||
if [ "$thisOs" != "Darwin" ]; then
|
||||
# for now, we don't support running this script from cygwin due to problems
|
||||
# like not having lsof, ps waux, curl, and awkward directory handling
|
||||
if [[ "$thisOs" != "Darwin" && "${thisOs:0:6}" != "CYGWIN" ]]; then
|
||||
# UseLargePages flag causes JVM crash on Mac OSX
|
||||
GC_TUNE="$GC_TUNE -XX:+UseLargePages"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue