Skip to content

Commit 09280bb

Browse files
authored
SOLR-17467: Start solr in Cloud mode, introduce --user-managed switch for User Managed mode (#2729)
Flip the default start mode to SolrCloud. Update the docs and the tests and the tutorials. This PR doesn't do anything to help an existing setup upgrade however.
1 parent 19cf21e commit 09280bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+120
-112
lines changed

dev-docs/running-in-docker.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ To run Solr in a container and expose the Solr port, run:
88
99
In order to start Solr in cloud mode, run the following.
1010
11-
`docker run -p 8983:8983 solr solr-fg -c`
11+
`docker run -p 8983:8983 solr solr-fg`
1212
1313
For documentation on using the official docker builds, please refer to the https://hub.docker.com/_/solr[DockerHub page].
1414
Up-to-date documentation for running locally built images of this branch can be found in the xref:_running_solr_in_docker[local reference guide].
@@ -30,4 +30,4 @@ For more info on building an image, run:
3030
`./gradlew helpDocker`
3131

3232
== Additional Information
33-
You can find additional information in the https://solr.apache.org/guide/solr/latest/deployment-guide/solr-in-docker.html[Solr Ref Guide Docker Page]
33+
You can find additional information in the https://solr.apache.org/guide/solr/latest/deployment-guide/solr-in-docker.html[Solr Ref Guide Docker Page]

solr/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ New Features
1010
---------------------
1111
* SOLR-14496: Solr CLI commands now can interact with a Solr secured using Basic Authentication. (Eric Pugh)
1212

13+
* SOLR-17467: Solr CLI bin/solr start defaults to starting Solr in Cloud mode, use --user-managed switch for User Managed (aka Standalone) mode. (Eric Pugh)
14+
1315
Improvements
1416
---------------------
1517

solr/bin/solr

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,13 @@ function print_usage() {
367367

368368
if [[ "$CMD" == "start" || "$CMD" == "restart" ]]; then
369369
echo ""
370-
echo "Usage: solr $CMD [-f] [-c] [--host host] [-p port] [--server-dir directory] [-z zkHost] [-m memory] [-e example] [--solr-home solr.solr.home] [--data-home solr.data.home] [--jvm-opts \"jvm-opts\"] [-V]"
370+
echo "Usage: solr $CMD [-f] [--user-managed] [--host host] [-p port] [--server-dir directory] [-z zkHost] [-m memory] [-e example] [--solr-home solr.solr.home] [--data-home solr.data.home] [--jvm-opts \"jvm-opts\"] [--verbose]"
371371
echo ""
372372
echo " -f Start Solr in foreground; default starts Solr in the background"
373373
echo " and sends stdout / stderr to solr-PORT-console.log"
374374
echo ""
375-
echo " -c or --cloud Start Solr in SolrCloud mode; if -z not supplied and ZK_HOST not defined in"
376-
echo " solr.in.sh, an embedded ZooKeeper instance is started on Solr port+1000,"
377-
echo " such as 9983 if Solr is bound to 8983"
375+
echo " --user-managed Start Solr in user managed aka standalone mode"
376+
echo " See the Ref Guide for more details: https://solr.apache.org/guide/solr/latest/deployment-guide/cluster-types.html"
378377
echo ""
379378
echo " --host <host> Specify the hostname for this Solr instance"
380379
echo ""
@@ -385,7 +384,7 @@ function print_usage() {
385384
echo ""
386385
echo " --server-dir <dir> Specify the Solr server directory; defaults to server"
387386
echo ""
388-
echo " -z/--zk-host <zkHost> Zookeeper connection string; only used when running in SolrCloud mode using -c"
387+
echo " -z/--zk-host <zkHost> Zookeeper connection string; ignored when running in User Managed (--user-managed) mode."
389388
echo " If neither ZK_HOST is defined in solr.in.sh nor the -z parameter is specified,"
390389
echo " an embedded ZooKeeper instance will be launched."
391390
echo " Set the ZK_CREATE_CHROOT environment variable to true if your ZK host has a chroot path, and you want to create it automatically."
@@ -733,13 +732,14 @@ FORCE=false
733732
SOLR_OPTS=(${SOLR_OPTS:-})
734733
SCRIPT_SOLR_OPTS=()
735734
PASS_TO_RUN_EXAMPLE=()
735+
SOLR_MODE="solrcloud"
736736

737737
if [ $# -gt 0 ]; then
738738
while true; do
739739
case "${1:-}" in
740-
-c|--cloud|-cloud)
741-
SOLR_MODE="solrcloud"
742-
PASS_TO_RUN_EXAMPLE+=("-c")
740+
--user-managed)
741+
SOLR_MODE="user-managed"
742+
PASS_TO_RUN_EXAMPLE+=("--user-managed")
743743
shift
744744
;;
745745
-d|--dir|-dir|--server-dir)
@@ -821,7 +821,6 @@ if [ $# -gt 0 ]; then
821821
exit 1
822822
fi
823823
ZK_HOST="$2"
824-
SOLR_MODE="solrcloud"
825824
PASS_TO_RUN_EXAMPLE+=("-z" "$ZK_HOST")
826825
shift 2
827826
;;
@@ -1141,11 +1140,6 @@ if [ "${#GC_LOG_OPTS[@]}" -gt 0 ]; then
11411140
fi
11421141
fi
11431142

1144-
# If ZK_HOST is defined, the assume SolrCloud mode
1145-
if [[ -n "${ZK_HOST:-}" ]]; then
1146-
SOLR_MODE="solrcloud"
1147-
fi
1148-
11491143
if [ "${SOLR_MODE:-}" == 'solrcloud' ]; then
11501144
: "${ZK_CLIENT_TIMEOUT:=30000}"
11511145
CLOUD_MODE_OPTS=("-DzkClientTimeout=$ZK_CLIENT_TIMEOUT")

solr/bin/solr.cmd

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -307,14 +307,13 @@ goto done
307307

308308
:start_usage
309309
@echo.
310-
@echo Usage: solr %SCRIPT_CMD% [-f] [-c] [--host hostname] [-p port] [--server-dir directory] [-z zkHost] [-m memory] [-e example] [--solr-home solr.solr.home] [--data-home solr.data.home] [--jvm-opts "jvm-opts"] [-V]
310+
@echo Usage: solr %SCRIPT_CMD% [-f] [--user-managed] [--host hostname] [-p port] [--server-dir directory] [-z zkHost] [-m memory] [-e example] [--solr-home solr.solr.home] [--data-home solr.data.home] [--jvm-opts "jvm-opts"] [--verbose]
311311
@echo.
312312
@echo -f Start Solr in foreground; default starts Solr in the background
313313
@echo and sends stdout / stderr to solr-PORT-console.log
314314
@echo.
315-
@echo -c or --cloud Start Solr in SolrCloud mode; if -z not supplied and ZK_HOST not defined in
316-
@echo solr.in.cmd, an embedded ZooKeeper instance is started on Solr port+1000,
317-
@echo such as 9983 if Solr is bound to 8983
315+
@echo --user-managed Start Solr in user managed aka standalone mode"
316+
@echo See the Ref Guide for more details: https://solr.apache.org/guide/solr/latest/deployment-guide/cluster-types.html
318317
@echo.
319318
@echo --host host Specify the hostname for this Solr instance
320319
@echo.
@@ -401,9 +400,7 @@ IF "%1"=="--verbose" goto set_verbose
401400
IF "%1"=="-v" goto set_verbose
402401
IF "%1"=="-q" goto set_warn
403402
IF "%1"=="--quiet" goto set_warn
404-
IF "%1"=="-c" goto set_cloud_mode
405-
IF "%1"=="-cloud" goto set_cloud_mode
406-
IF "%1"=="--cloud" goto set_cloud_mode
403+
IF "%1"=="--user-managed" goto set_user_managed_mode
407404
IF "%1"=="-d" goto set_server_dir
408405
IF "%1"=="--dir" goto set_server_dir
409406
IF "%1"=="--server-dir" goto set_server_dir
@@ -462,8 +459,8 @@ set SOLR_LOG_LEVEL=WARN
462459
SHIFT
463460
goto parse_args
464461

465-
:set_cloud_mode
466-
set SOLR_MODE=solrcloud
462+
:set_user_managed_mode
463+
set SOLR_MODE=user-managed
467464
SHIFT
468465
goto parse_args
469466

@@ -875,7 +872,7 @@ IF "%SCRIPT_CMD%"=="start" (
875872
)
876873
)
877874
)
878-
875+
879876
IF "%EMPTY_ADDL_JVM_ARGS%"=="true" (
880877
set "SCRIPT_ERROR=JVM options are required when using the -a or --jvm-opts option!"
881878
goto err
@@ -907,6 +904,7 @@ if !JAVA_MAJOR_VERSION! LSS 9 (
907904
)
908905

909906
IF NOT "%ZK_HOST%"=="" set SOLR_MODE=solrcloud
907+
IF NOT "%SOLR_MODE%"=="" set SOLR_MODE=solrcloud
910908

911909
IF "%SOLR_MODE%"=="solrcloud" (
912910
IF "%ZK_CLIENT_TIMEOUT%"=="" set "ZK_CLIENT_TIMEOUT=30000"
@@ -942,7 +940,8 @@ IF "%SOLR_MODE%"=="solrcloud" (
942940

943941
IF EXIST "%SOLR_HOME%\collection1\core.properties" set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -Dbootstrap_confdir=./solr/collection1/conf -Dcollection.configName=myconf -DnumShards=1"
944942
) ELSE (
945-
set CLOUD_MODE_OPTS=
943+
REM change Cloud mode to User Managed mode with flag
944+
set "CLOUD_MODE_OPTS=--user-managed"
946945
IF NOT EXIST "%SOLR_HOME%\solr.xml" (
947946
IF "%SOLR_SOLRXML_REQUIRED%"=="true" (
948947
set "SCRIPT_ERROR=Solr home directory %SOLR_HOME% must contain solr.xml!"

solr/core/src/java/org/apache/solr/cli/RunExampleTool.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,10 @@ public List<Option> getOptions() {
167167
.required(false)
168168
.desc("Specify the hostname for this Solr instance.")
169169
.build(),
170-
Option.builder("c")
171-
.longOpt("cloud")
170+
Option.builder()
171+
.longOpt("user-managed")
172172
.required(false)
173-
.desc(
174-
"Start Solr in SolrCloud mode; if -z not supplied, an embedded ZooKeeper instance is started on Solr port+1000, such as 9983 if Solr is bound to 8983.")
173+
.desc("Start Solr in User Managed mode.")
175174
.build(),
176175
Option.builder("m")
177176
.longOpt("memory")
@@ -263,7 +262,7 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception
263262
String configSet =
264263
"techproducts".equals(exampleName) ? "sample_techproducts_configs" : "_default";
265264

266-
boolean isCloudMode = cli.hasOption('c');
265+
boolean isCloudMode = !cli.hasOption("user-managed");
267266
String zkHost = cli.getOptionValue('z');
268267
int port =
269268
Integer.parseInt(
@@ -536,7 +535,7 @@ protected void runCloudExample(CommandLine cli) throws Exception {
536535
// start the other nodes
537536
for (int n = 1; n < numNodes; n++)
538537
startSolr(
539-
new File(cloudDir, "node" + (n + 1) + "/solr"), true, cli, cloudPorts[n], zkHost, 30);
538+
new File(cloudDir, "node" + (n + 1) + "/solr"), false, cli, cloudPorts[n], zkHost, 30);
540539
}
541540

542541
String solrUrl = (String) nodeStatus.get("baseUrl");
@@ -612,9 +611,9 @@ protected Map<String, Object> startSolr(
612611
String hostArg = (host != null && !"localhost".equals(host)) ? " --host " + host : "";
613612
String zkHostArg = (zkHost != null) ? " -z " + zkHost : "";
614613
String memArg = (memory != null) ? " -m " + memory : "";
615-
String cloudModeArg = cloudMode ? "--cloud " : "";
614+
String cloudModeArg = cloudMode ? "" : "--user-managed";
616615
String forceArg = cli.hasOption("force") ? " --force" : "";
617-
String verboseArg = verbose ? "-V" : "";
616+
String verboseArg = verbose ? "--verbose" : "";
618617

619618
String jvmOpts =
620619
cli.hasOption("jvm-opts") ? cli.getOptionValue("jvm-opts") : cli.getOptionValue('a');

solr/core/src/java/org/apache/solr/cli/SolrCLI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ private static void printHelp() {
676676
" SolrCloud example (start Solr running in SolrCloud mode using localhost:2181 to connect to Zookeeper, with 1g max heap size and remote Java debug options enabled):");
677677
print("");
678678
printGreen(
679-
" ./solr start -c -m 1g -z localhost:2181 --jvm-opts \"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044\"");
679+
" ./solr start -m 1g -z localhost:2181 --jvm-opts \"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044\"");
680680
print("");
681681
print(
682682
" Omit '-z localhost:2181' from the above command if you have defined ZK_HOST in solr.in.sh.");

solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public int execute(org.apache.commons.exec.CommandLine cmd) throws IOException {
115115
if (exe.endsWith("solr")) {
116116
String[] args = cmd.getArguments();
117117
if ("start".equals(args[0])) {
118-
if (!hasFlag("--cloud", args) && !hasFlag("-c", args)) {
118+
if (hasFlag("--user-managed", args)) {
119119
return startStandaloneSolr(args);
120120
}
121121

@@ -336,9 +336,12 @@ public void testFilmsExample() throws Exception {
336336
}
337337

338338
protected void testExample(String exampleName) throws Exception {
339+
// Occasionally we want to test in User Managed mode, not the default SolrCloud mode.
340+
String testStandaloneMode = LuceneTestCase.rarely() ? "--user-managed" : "";
339341
File solrHomeDir = new File(ExternalPaths.SERVER_HOME);
340-
if (!solrHomeDir.isDirectory())
342+
if (!solrHomeDir.isDirectory()) {
341343
fail(solrHomeDir.getAbsolutePath() + " not found and is required to run this test!");
344+
}
342345

343346
Path tmpDir = createTempDir();
344347
File solrExampleDir = tmpDir.toFile();
@@ -355,10 +358,15 @@ protected void testExample(String exampleName) throws Exception {
355358

356359
String[] toolArgs =
357360
new String[] {
358-
"-e", exampleName,
359-
"--server-dir", solrServerDir.getAbsolutePath(),
360-
"--example-dir", solrExampleDir.getAbsolutePath(),
361-
"-p", String.valueOf(bindPort)
361+
"-e",
362+
exampleName,
363+
"--server-dir",
364+
solrServerDir.getAbsolutePath(),
365+
"--example-dir",
366+
solrExampleDir.getAbsolutePath(),
367+
"-p",
368+
String.valueOf(bindPort),
369+
testStandaloneMode
362370
};
363371

364372
// capture tool output to stdout

solr/docker/gradle-help.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ Each input tasks a comma separated list of test names.
7878

7979
Run specific tests:
8080
EnvVar: SOLR_DOCKER_TESTS_INCLUDE
81-
Gradle Property: -Psolr.docker.tests.include
81+
Gradle Property: -Psolr.docker.tests.include=cloud_multi_node_embedded_zk,demo
8282

8383
Exclude specific tests:
8484
EnvVar: SOLR_DOCKER_TESTS_EXCLUDE
85-
Gradle Property: -Psolr.docker.tests.exclude
85+
Gradle Property: -Psolr.docker.tests.exclude=cloud_multi_node_embedded_zk,demo
8686

8787
The docker tests can also be run concurrently, if explicitly specified.
8888
The parallelization is set by the number of gradle workers you have defined, this cannot be specified separately.

solr/docker/scripts/solr-create

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ else
7575
fi
7676
fi
7777

78-
exec solr-fg
78+
exec solr-fg --user-managed

solr/docker/scripts/solr-demo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ else
5050
fi
5151
fi
5252

53-
exec solr-fg
53+
exec solr-fg --user-managed

0 commit comments

Comments
 (0)