Apache Solr open-source search software
SOLR-6726: better strategy for selecting the JMX RMI port based on SOLR_PORT in bin/solr
Timothy Potter9806b86719ac
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex fc4f8d63851..8c233fb0c7c 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -286,13 +286,6 @@ Bug Fixesit caused long startup times on lage indexes even when it wasn't used.(yonik)-* SOLR-6662: better validation when parsing command-line options that expect a value- (Timothy Potter)--* SOLR-6705: Better strategy for dealing with JVM specific options in the start- scripts; remove -XX:+AggressiveOpts and only set -XX:-UseSuperWord for Java 1.7u40- to u51. (Uwe Schindler, janhoy, hossman, Timothy Potter)-* SOLR-6738: Admin UI - Escape Data on Plugins-View (steffkes)* SOLR-3774: Solr adds RequestHandler SolrInfoMBeans twice to the JMX server.@@ -401,10 +394,6 @@ Other Changes* SOLR-6651: Fix wrong timeout logged in waitForReplicasToComeUp. (shalin)-* SOLR-6661: Adjust all example configurations to allow overriding error-prone- relative paths for solrconfig.xml <lib> references with solr.install.dir- system property; bin/solr scripts will set it appropriately. (ehatcher)-* SOLR-6698: Solr is not consistent wrt ZkCredentialsProvider / ZkCredentialProvider.References to zkCredentialProvider in System properties or configurations should bechanged to zkCredentialsProvider. (Gregory Chanan)@@ -500,6 +489,26 @@ Bug Fixes* SOLR-6610: Slow startup of new clusters because ZkController.publishAndWaitForDownStatesalways times out. (Jessica Cheng Mallet, shalin, Noble Paul)+* SOLR-6662: better validation when parsing command-line options that expect a value+ (Timothy Potter)++* SOLR-6732: Fix handling of leader-initiated recovery state was String in older versions+ and is now a JSON map, caused backwards compatibility issues when doing rolling upgrades of+ a live cluster while indexing (Timothy Potter)++* SOLR-6705: Better strategy for dealing with JVM specific options in the start+ scripts; remove -XX:+AggressiveOpts and only set -XX:-UseSuperWord for Java 1.7u40+ to u51. (Uwe Schindler, janhoy, hossman, Timothy Potter)++* SOLR-6726: better strategy for selecting the JMX RMI port based on SOLR_PORT in bin/solr+ script (Timothy Potter)++Other Changes+----------------------++* SOLR-6661: Adjust all example configurations to allow overriding error-prone+ relative paths for solrconfig.xml <lib> references with solr.install.dir+ system property; bin/solr scripts will set it appropriately. (ehatcher)================== 4.10.2 ==================diff --git a/solr/bin/solr b/solr/bin/solrindex 954b795a18c..e2e0090de2b 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -150,6 +150,9 @@ function print_usage() {echo " -h <host> Specify the hostname for this Solr instance"echo ""echo " -p <port> Specify the port to start the Solr HTTP listener on; default is 8983"+ echo " The specified port (SOLR_PORT) will also be used to determine the stop port"+ echo " STOP_PORT=(\$SOLR_PORT-1000) and JMX RMI listen port RMI_PORT=(1\$SOLR_PORT). "+ echo " For instance, if you set -p 8985, then the STOP_PORT=7985 and RMI_PORT=18985"echo ""echo " -d <dir> Specify the Solr server directory; defaults to server"echo ""@@ -173,9 +176,9 @@ function print_usage() {echo " schemaless: Schema-less example"echo ""echo " -a Additional parameters to pass to the JVM when starting Solr, such as to setup"- echo " Java debug options. For example, to enable a Java debugger to attach to the Solr JVM"- echo " you could pass: -a \"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=18983\""- echo " In most cases, you should wrap the additional parameters in double quotes."+ echo " Java debug options. For example, to enable a Java debugger to attach to the Solr JVM"+ echo " you could pass: -a \"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=18983\""+ echo " In most cases, you should wrap the additional parameters in double quotes."echo ""echo " -noprompt Don't prompt for input; accept all defaults when running examples that accept user input"echo ""@@ -191,10 +194,6 @@ function print_usage() {echo ""echo " -all Find and stop all running Solr servers on this host"echo ""- echo " -V Verbose messages from this script"- echo ""- echo "NOTE: If port is not specified, then all running Solr servers are stopped."- echo ""elif [ "$CMD" == "healthcheck" ]; thenecho ""echo "Usage: solr healthcheck [-c collection] [-z zkHost]"@@ -876,8 +875,7 @@ if [[ "$SCRIPT_CMD" == "start" ]]; thenfiif [ "$SOLR_PID" != "" ]; then- echo -e "\nSolr already running on port $SOLR_PORT (pid: $SOLR_PID)!"- echo -e "Please use the 'restart' command if you want to restart this node.\n"+ echo -e "\nPort $SOLR_PORT is already being used by another process (pid: $SOLR_PID)\n"exitfielse@@ -964,12 +962,17 @@ fi# These are useful for attaching remove profilers like VisualVM/JConsoleif [ "$ENABLE_REMOTE_JMX_OPTS" == "true" ]; then++ if [ "$RMI_PORT" == "" ]; then+ RMI_PORT=1$SOLR_PORT+ fi+REMOTE_JMX_OPTS="-Dcom.sun.management.jmxremote \-Dcom.sun.management.jmxremote.local.only=false \-Dcom.sun.management.jmxremote.ssl=false \-Dcom.sun.management.jmxremote.authenticate=false \--Dcom.sun.management.jmxremote.port=10${SOLR_PORT: -2} \--Dcom.sun.management.jmxremote.rmi.port=10${SOLR_PORT: -2}"+-Dcom.sun.management.jmxremote.port=$RMI_PORT \+-Dcom.sun.management.jmxremote.rmi.port=$RMI_PORT"# if the host is set, then set that as the rmi server hostnameif [ "$SOLR_HOST" != "" ]; then@@ -1013,24 +1016,34 @@ function launch_solr() {if $verbose ; thenecho -e "\nStarting Solr using the following settings:"+ echo -e " JAVA = $JAVA"echo -e " SOLR_SERVER_DIR = $SOLR_SERVER_DIR"echo -e " SOLR_HOME = $SOLR_HOME"- echo -e " JAVA = $JAVA"echo -e " SOLR_HOST = $SOLR_HOST"echo -e " SOLR_PORT = $SOLR_PORT"+ echo -e " STOP_PORT = $STOP_PORT"+ echo -e " SOLR_JAVA_MEM = $SOLR_JAVA_MEM"echo -e " GC_TUNE = $GC_TUNE"echo -e " GC_LOG_OPTS = $GC_LOG_OPTS"- echo -e " SOLR_JAVA_MEM = $SOLR_JAVA_MEM"- echo -e " REMOTE_JMX_OPTS = $REMOTE_JMX_OPTS"- echo -e " CLOUD_MODE_OPTS = $CLOUD_MODE_OPTS"echo -e " SOLR_TIMEZONE = $SOLR_TIMEZONE"-++ if [ "$SOLR_MODE" == "solrcloud" ]; then+ echo -e " CLOUD_MODE_OPTS = $CLOUD_MODE_OPTS"+ fi+if [ "$SOLR_OPTS" != "" ]; thenecho -e " SOLR_OPTS = $SOLR_OPTS"fi+if [ "$SOLR_ADDL_ARGS" != "" ]; thenecho -e " SOLR_ADDL_ARGS = $SOLR_ADDL_ARGS"fi++ if [ "$ENABLE_REMOTE_JMX_OPTS" == "true" ]; then+ echo -e " RMI_PORT = $RMI_PORT"+ echo -e " REMOTE_JMX_OPTS = $REMOTE_JMX_OPTS"+ fi+ echo -e "\n"fi# need to launch solr from the server dirdiff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmdindex 6de3500f26a..e4bd24e016c 100644--- a/solr/bin/solr.cmd+++ b/solr/bin/solr.cmd@@ -172,8 +172,6 @@ goto done@echo.@echo -all Find and stop all running Solr servers on this host@echo.-@echo -V Verbose messages from this script-@echo.goto done:healthcheck_usage@@ -587,12 +585,13 @@ IF "%SOLR_MODE%"=="solrcloud" (REM These are useful for attaching remove profilers like VisualVM/JConsoleIF "%ENABLE_REMOTE_JMX_OPTS%"=="true" (+ IF "!RMI_PORT!"=="" set RMI_PORT=1%SOLR_PORT%set REMOTE_JMX_OPTS=-Dcom.sun.management.jmxremote ^-Dcom.sun.management.jmxremote.local.only=false ^-Dcom.sun.management.jmxremote.ssl=false ^-Dcom.sun.management.jmxremote.authenticate=false ^--Dcom.sun.management.jmxremote.port=10%SOLR_PORT:~-2,2% ^--Dcom.sun.management.jmxremote.rmi.port=10%SOLR_PORT:~-2,2%+-Dcom.sun.management.jmxremote.port=!RMI_PORT! ^+-Dcom.sun.management.jmxremote.rmi.port=!RMI_PORT!IF NOT "%SOLR_HOST%"=="" set REMOTE_JMX_OPTS=%REMOTE_JMX_OPTS% -Djava.rmi.server.hostname=%SOLR_HOST%) ELSE (@@ -636,18 +635,28 @@ IF "%verbose%"=="1" (@echo SOLR_HOME = %SOLR_HOME%@echo SOLR_HOST = %SOLR_HOST%@echo SOLR_PORT = %SOLR_PORT%+ @echo STOP_PORT = %STOP_PORT%+ @echo SOLR_JAVA_MEM = %SOLR_JAVA_MEM%@echo GC_TUNE = !GC_TUNE!@echo GC_LOG_OPTS = %GC_LOG_OPTS%- @echo SOLR_JAVA_MEM = %SOLR_JAVA_MEM%- @echo REMOTE_JMX_OPTS = %REMOTE_JMX_OPTS%- @echo CLOUD_MODE_OPTS = %CLOUD_MODE_OPTS%@echo SOLR_TIMEZONE = %SOLR_TIMEZONE%++ IF "%SOLR_MODE%"=="solrcloud" (+ @echo CLOUD_MODE_OPTS = %CLOUD_MODE_OPTS%+ )+IF NOT "%SOLR_OPTS%"=="" (@echo SOLR_OPTS = %SOLR_OPTS%)+IF NOT "%SOLR_ADDL_ARGS%"=="" (@echo SOLR_ADDL_ARGS = %SOLR_ADDL_ARGS%)++ IF "%ENABLE_REMOTE_JMX_OPTS%"=="true" (+ @echo RMI_PORT = !RMI_PORT!+ @echo REMOTE_JMX_OPTS = %REMOTE_JMX_OPTS%+ ))set START_OPTS=-Duser.timezone=%SOLR_TIMEZONE% -Djava.net.preferIPv4Stack=truediff --git a/solr/bin/solr.in.cmd b/solr/bin/solr.in.cmdindex 25e47ef208d..983110464a8 100644--- a/solr/bin/solr.in.cmd+++ b/solr/bin/solr.in.cmd@@ -63,6 +63,9 @@ REM JMX savvy tools like VisualVM remotely, set to "false" to disable that behavREM (recommended in production environments)set ENABLE_REMOTE_JMX_OPTS=true+REM The script will use SOLR_PORT+10000 for the RMI_PORT or you can set it here+REM set RMI_PORT=18983+REM Anything you add to the SOLR_OPTS variable will be included in the javaREM start command line as-is, in ADDITION to other options. If you specify theREM -a option on start script, those options will be appended as well. Examples:diff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.shindex ff7a6da5b79..b35395a575d 100644--- a/solr/bin/solr.in.sh+++ b/solr/bin/solr.in.sh@@ -61,6 +61,9 @@ GC_TUNE="-XX:NewRatio=3 \# (recommended in production environments)ENABLE_REMOTE_JMX_OPTS="true"+# 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: