Apache Solr open-source search software
Migrate SOLR_HOST to SOLR_HOST_ADVERTISE (#3858)
Eric Pugh98e30eee8f01
diff --git a/solr/bin/solr b/solr/bin/solrindex 4d4b4d70bf2..a2ff10cbba5 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -1134,8 +1134,8 @@ if [ "${ENABLE_REMOTE_JMX_OPTS:-false}" == "true" ]; then"-Dcom.sun.management.jmxremote.rmi.port=$RMI_PORT")# if the host is set, then set that as the rmi server hostname- if [ "$SOLR_HOST" != "" ]; then- REMOTE_JMX_OPTS+=("-Djava.rmi.server.hostname=$SOLR_HOST")+ if [ "$SOLR_HOST_ADVERTISE" != "" ]; then+ REMOTE_JMX_OPTS+=("-Djava.rmi.server.hostname=$SOLR_HOST_ADVERTISE")fielseREMOTE_JMX_OPTS=()diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmdindex 47296a8dbd0..1d37b98056c 100755--- a/solr/bin/solr.cmd+++ b/solr/bin/solr.cmd@@ -557,7 +557,7 @@ IF "%firstChar%"=="-" (goto invalid_cmd_line)-set SOLR_HOST=%~2+set SOLR_HOST_ADVERTISE=%~2set "PASS_TO_RUN_EXAMPLE=--host %~2 !PASS_TO_RUN_EXAMPLE!"SHIFTSHIFTdiff --git a/solr/bin/solr.in.cmd b/solr/bin/solr.in.cmdindex 3e63af456ce..ebada5438c5 100755--- a/solr/bin/solr.in.cmd+++ b/solr/bin/solr.in.cmd@@ -66,7 +66,7 @@ REM set ZK_CLIENT_TIMEOUT=30000REM By default the start script uses "localhost"; override the hostname hereREM for production SolrCloud environments to control the hostname exposed to cluster state-REM set SOLR_HOST=192.168.1.1+REM set SOLR_HOST_ADVERTISE=192.168.1.1REM By default Solr will try to connect to Zookeeper with 30 seconds in timeout; override the timeout if neededREM set SOLR_CLOUD_WAIT_FOR_ZK_SECONDS=30diff --git a/solr/bin/solr.in.sh b/solr/bin/solr.in.shindex 8c50528b6f9..9db413a4219 100644--- a/solr/bin/solr.in.sh+++ b/solr/bin/solr.in.sh@@ -72,7 +72,7 @@# 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"+#SOLR_HOST_ADVERTISE="192.168.1.1"# By default Solr will try to connect to Zookeeper with 30 seconds in timeout; override the timeout if needed#SOLR_CLOUD_WAIT_FOR_ZK_SECONDS="30"diff --git a/solr/packaging/test/test_ssl.bats b/solr/packaging/test/test_ssl.batsindex 3115b7b619a..5075ec76338 100644--- a/solr/packaging/test/test_ssl.bats+++ b/solr/packaging/test/test_ssl.bats@@ -49,7 +49,7 @@ teardown() {export SOLR_SSL_TRUST_STORE_PASSWORD=secretexport SOLR_SSL_NEED_CLIENT_AUTH=falseexport SOLR_SSL_WANT_CLIENT_AUTH=false- export SOLR_HOST=localhost+ export SOLR_HOST_ADVERTISE=localhostsolr startsolr assert --started https://localhost:${SOLR_PORT} --timeout 5000@@ -87,7 +87,7 @@ teardown() {export SOLR_SSL_NEED_CLIENT_AUTH=falseexport SOLR_SSL_WANT_CLIENT_AUTH=falseexport SOLR_SSL_CHECK_PEER_NAME=false- export SOLR_HOST=127.0.0.1+ export SOLR_HOST_ADVERTISE=127.0.0.1solr startsolr assert --started https://localhost:${SOLR_PORT} --timeout 5000@@ -149,7 +149,7 @@ teardown() {export SOLR_SSL_NEED_CLIENT_AUTH=falseexport SOLR_SSL_WANT_CLIENT_AUTH=falseexport SOLR_SSL_CHECK_PEER_NAME=true- export SOLR_HOST=localhost+ export SOLR_HOST_ADVERTISE=localhostsolr startsolr assert --started https://localhost:${SOLR_PORT} --timeout 5000@@ -205,7 +205,7 @@ teardown() {export SOLR_SSL_NEED_CLIENT_AUTH=falseexport SOLR_SSL_WANT_CLIENT_AUTH=trueexport SOLR_SSL_CHECK_PEER_NAME=true- export SOLR_HOST=localhost+ export SOLR_HOST_ADVERTISE=localhostexport SOLR_SECURITY_MANAGER_ENABLED=truerun solr start@@ -320,7 +320,7 @@ teardown() {export SOLR_SSL_CHECK_PEER_NAME=true# Cannot set this to true, because the client certificate does not have the right hostname ("localhost") or IPexport SOLR_SSL_CLIENT_HOSTNAME_VERIFICATION=false- export SOLR_HOST=localhost+ export SOLR_HOST_ADVERTISE=localhostsolr startsolr start -z localhost:${ZK_PORT} -p ${SOLR2_PORT}@@ -459,7 +459,7 @@ teardown() {export SOLR_SSL_WANT_CLIENT_AUTH=trueexport SOLR_SSL_CHECK_PEER_NAME=trueexport SOLR_SSL_CLIENT_HOSTNAME_VERIFICATION=true- export SOLR_HOST=localhost+ export SOLR_HOST_ADVERTISE=localhostsolr startsolr start -z localhost:${ZK_PORT} -p ${SOLR2_PORT}@@ -521,7 +521,7 @@ teardown() {export SOLR_SSL_TRUST_STORE_PASSWORD=secretexport SOLR_SSL_NEED_CLIENT_AUTH=trueexport SOLR_SSL_WANT_CLIENT_AUTH=false- export SOLR_HOST=localhost+ export SOLR_HOST_ADVERTISE=localhost# server1 will run on $SOLR_PORT and will use server1.keystoreexport SOLR_SSL_KEY_STORE=$ssl_dir/server1.keystore.p12diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/solr-in-docker.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/solr-in-docker.adocindex 849e2a3294a..8012b18b0b0 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/solr-in-docker.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/solr-in-docker.adoc@@ -157,7 +157,7 @@ The third way is to use a separate container:[source,bash]-----docker run -e SOLR_HOST=solr1 --network docs_solr solr solr create -c gettingstarted3 -p 8983+docker run -e SOLR_HOST_ADVERTISE=solr1 --network docs_solr solr solr create -c gettingstarted3 -p 8983----The fourth way is to use the remote API, from the host or from one of the containers, or some new container on the same network (adjust the hostname accordingly):@@ -250,7 +250,7 @@ The same works if you use the xref:docker-compose[example docker compose cluster[source,bash]-----docker run -e SOLR_HOST=solr1 --network=mycluster_solr solr solr create -c books -p 8983+docker run -e SOLR_HOST_ADVERTISE=solr1 --network=mycluster_solr solr solr create -c books -p 8983docker run --rm -v "$PWD/mydata:/mydata" --network=mycluster_solr solr solr post -c books /mydata/books.csv --host solr1----diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/taking-solr-to-production.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/taking-solr-to-production.adocindex 81e63454bf1..e91be0fd62c 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/taking-solr-to-production.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/taking-solr-to-production.adoc@@ -295,11 +295,11 @@ SOLR_DELETE_UNKNOWN_CORES=true=== Solr Hostname-Use the `SOLR_HOST` variable in the include file to set the hostname of the Solr server.+Use the `SOLR_HOST_ADVERTISE` variable in the include file to set the hostname of the Solr server.[source,bash]-----SOLR_HOST=solr1.example.com+SOLR_HOST_ADVERTISE=solr1.example.com----Setting the hostname of the Solr server is recommended, especially when running in SolrCloud mode, as this determines the address of the node when it registers with ZooKeeper.diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/upgrading-a-solr-cluster.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/upgrading-a-solr-cluster.adocindex a2efff5a5aa..901bf7d487e 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/upgrading-a-solr-cluster.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/upgrading-a-solr-cluster.adoc@@ -41,7 +41,7 @@ You'll be doing a rolling restart of your cluster (each node, one-by-one), but w. Re-build and test all custom server-side components against the new Solr JAR files.. Determine the values of the following variables that are used by the Solr Control Scripts:* `ZK_HOST`: The ZooKeeper connection string your current SolrCloud nodes use to connect to ZooKeeper; this value will be the same for all nodes in the cluster.-* `SOLR_HOST`: The hostname each Solr node used to register with ZooKeeper when joining the SolrCloud cluster; this value will be used to set the *host* Java system property when starting the new Solr process.+* `SOLR_HOST_ADVERTISE`: The hostname each Solr node used to register with ZooKeeper when joining the SolrCloud cluster; this value will be used to set the *host* Java system property when starting the new Solr process.* `SOLR_PORT`: The port each Solr node is listening on, such as 8983.* `SOLR_HOME`: The absolute path to the Solr home directory for each Solr node.This value will be passed to the new Solr process using the `solr.solr.home` system property, see: xref:configuration-guide:configuring-solr-xml.adoc[].@@ -85,7 +85,7 @@ Open `/etc/default/solr.in.sh` with a text editor and verify that the following[source,properties]ZK_HOST=-SOLR_HOST=+SOLR_HOST_ADVERTISE=SOLR_PORT=SOLR_HOME=@@ -96,7 +96,7 @@ For instance, if you plan to run Solr as the "solr" user and `SOLR_HOME` is `/va=== Step 4: Start SolrYou are now ready to start the upgraded Solr node by doing: `sudo service solr start`.-The upgraded instance will join the existing cluster because you're using the same `SOLR_HOME`, `SOLR_PORT`, and `SOLR_HOST` settings used by the old Solr node; thus, the new server will look like the old node to the running cluster.+The upgraded instance will join the existing cluster because you're using the same `SOLR_HOME`, `SOLR_PORT`, and `SOLR_HOST_ADVERTISE` settings used by the old Solr node; thus, the new server will look like the old node to the running cluster.Be sure to look in `/var/solr/logs/solr.log` for errors during startup.=== Step 5: Run Healthcheckdiff --git a/solr/solrj/src/resources/EnvToSyspropMappings.properties b/solr/solrj/src/resources/EnvToSyspropMappings.propertiesindex df8a77f6402..93067020cf7 100644--- a/solr/solrj/src/resources/EnvToSyspropMappings.properties+++ b/solr/solrj/src/resources/EnvToSyspropMappings.properties@@ -10,7 +10,7 @@ SOLR_AUTH_JWT_ALLOW_OUTBOUND_HTTP=solr.auth.jwt.allowOutboundHttpSOLR_DISABLE_REQUEST_ID=solr.disableRequestIdSOLR_HIDDEN_SYS_PROPS=solr.hiddenSysPropsSOLR_HOME=solr.solr.home-SOLR_HOST=host+SOLR_HOST_ADVERTISE=hostSOLR_HTTP_DISABLE_COOKIES=solr.http.disableCookies# Couldn't we just use solr.ip.allowlist everywhere instead of solr.jetty.inetaccess.includes?SOLR_IP_ALLOWLIST=solr.jetty.inetaccess.includesdiff --git a/solr/solrj/src/test/org/apache/solr/common/util/EnvUtilsTest.java b/solr/solrj/src/test/org/apache/solr/common/util/EnvUtilsTest.javaindex 1a6eee1c227..7b360dd49cf 100644--- a/solr/solrj/src/test/org/apache/solr/common/util/EnvUtilsTest.java+++ b/solr/solrj/src/test/org/apache/solr/common/util/EnvUtilsTest.java@@ -30,7 +30,7 @@ public class EnvUtilsTest extends SolrTestCase {Map.of("SOLR_HOME", "/home/solr","SOLR_PORT_LISTEN", "8983",- "SOLR_HOST", "localhost",+ "SOLR_HOST_ADVERTISE", "localhost","SOLR_LOG_LEVEL", "INFO","SOLR_BOOLEAN", "true","SOLR_LONG", "1234567890",@@ -79,7 +79,7 @@ public class EnvUtilsTest extends SolrTestCase {public void testEnvsWithCustomKeyNameMappings() {// These have different names than the environment variablesassertEquals(ENV.get("SOLR_HOME"), EnvUtils.getProperty("solr.solr.home"));- assertEquals(ENV.get("SOLR_HOST"), EnvUtils.getProperty("host"));+ assertEquals(ENV.get("SOLR_HOST_ADVERTISE"), EnvUtils.getProperty("host"));assertEquals(ENV.get("SOLR_LOGS_DIR"), EnvUtils.getProperty("solr.logs.dir"));}