mirror of
https://github.com/apache/lucene.git
synced 2025-02-08 02:58:58 +00:00
SOLR-6952: bin/solr create action should copy configset directory instead of reusing an existing configset in ZooKeeper by default; commit also includes fix for SOLR-6933 - create alias
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1651231 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5326c924d2
commit
c36180cdf8
@ -856,7 +856,7 @@ def testSolrExample(unpackPath, javaPath, isSrc):
|
|||||||
|
|
||||||
print(' startup done')
|
print(' startup done')
|
||||||
# Create the techproducts config (used to be collection1)
|
# Create the techproducts config (used to be collection1)
|
||||||
subprocess.call(['bin/solr','create_core','-n','techproducts','-c','sample_techproducts_configs'])
|
subprocess.call(['bin/solr','create_core','-c','techproducts','-d','sample_techproducts_configs'])
|
||||||
os.chdir('example')
|
os.chdir('example')
|
||||||
print(' test utf8...')
|
print(' test utf8...')
|
||||||
run('sh ./exampledocs/test_utf8.sh http://localhost:8983/solr/techproducts', 'utf8.log')
|
run('sh ./exampledocs/test_utf8.sh http://localhost:8983/solr/techproducts', 'utf8.log')
|
||||||
|
@ -674,6 +674,13 @@ Other Changes
|
|||||||
|
|
||||||
* SOLR-6324: Set finite default timeouts for select and update. (Ramkumar Aiyengar via Mark Miller)
|
* SOLR-6324: Set finite default timeouts for select and update. (Ramkumar Aiyengar via Mark Miller)
|
||||||
|
|
||||||
|
* SOLR-6952: bin/solr create action should copy configset directory instead of reusing
|
||||||
|
an existing configset in ZooKeeper by default (Timothy Potter)
|
||||||
|
|
||||||
|
* SOLR-6933: bin/solr should provide a single "create" action that creates a core
|
||||||
|
or collection depending on whether Solr is running in standalone or cloud mode
|
||||||
|
(Timothy Potter)
|
||||||
|
|
||||||
================== 4.10.3 ==================
|
================== 4.10.3 ==================
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
|
@ -32,32 +32,28 @@ To start Solr for the first time after installation, simply do:
|
|||||||
|
|
||||||
bin/solr start
|
bin/solr start
|
||||||
|
|
||||||
This will launch a Solr server in the background of your shell, bound
|
This will launch a standalone Solr server in the background of your shell,
|
||||||
to port 8983. After starting Solr, you can create a new core for indexing
|
listening on port 8983. Alternatively, you can launch Solr in "cloud" mode,
|
||||||
your data by doing:
|
which allows you to scale out using sharding and replication. To launch Solr
|
||||||
|
in cloud mode, do:
|
||||||
bin/solr create_core -n <name>
|
|
||||||
|
|
||||||
This will create a core that uses a data-driven schema which tries to guess
|
|
||||||
the correct field type when you add documents to the index. To see all available
|
|
||||||
options for creating a new core, execute:
|
|
||||||
|
|
||||||
bin/solr create_core -help
|
|
||||||
|
|
||||||
Alternatively, you can launch Solr in "cloud" mode, which allows you to scale
|
|
||||||
out using sharding and replication. To launch Solr in cloud mode, do:
|
|
||||||
|
|
||||||
bin/solr start -cloud
|
bin/solr start -cloud
|
||||||
|
|
||||||
After starting Solr in cloud mode, you can create a new collection for indexing
|
|
||||||
your data by doing:
|
|
||||||
|
|
||||||
bin/solr create_collection -n <name>
|
|
||||||
|
|
||||||
To see all available options for starting Solr, please do:
|
To see all available options for starting Solr, please do:
|
||||||
|
|
||||||
bin/solr start -help
|
bin/solr start -help
|
||||||
|
|
||||||
|
After starting Solr, create either a core or collection depending on whether
|
||||||
|
Solr is running in standalone (core) or SolrCloud mode (collection) by doing:
|
||||||
|
|
||||||
|
bin/solr create -n <name>
|
||||||
|
|
||||||
|
This will create a collection that uses a data-driven schema which tries to guess
|
||||||
|
the correct field type when you add documents to the index. To see all available
|
||||||
|
options for creating a new collection, execute:
|
||||||
|
|
||||||
|
bin/solr create -help
|
||||||
|
|
||||||
After starting Solr, direct your Web browser to the Solr Admin Console at:
|
After starting Solr, direct your Web browser to the Solr Admin Console at:
|
||||||
|
|
||||||
http://localhost:8983/solr/
|
http://localhost:8983/solr/
|
||||||
@ -98,18 +94,6 @@ For more information about Solr examples please read...
|
|||||||
* http://wiki.apache.org/solr/SolrResources
|
* http://wiki.apache.org/solr/SolrResources
|
||||||
For a list of other tutorials and introductory articles.
|
For a list of other tutorials and introductory articles.
|
||||||
|
|
||||||
|
|
||||||
In addition, Solr ships with several example configurations that
|
|
||||||
help you learn about Solr. To run one of the examples, you would do:
|
|
||||||
|
|
||||||
bin/solr -e <EXAMPLE> where <EXAMPLE> is one of:
|
|
||||||
|
|
||||||
cloud : SolrCloud example
|
|
||||||
dih : Data Import Handler (rdbms, mail, rss, tika)
|
|
||||||
schemaless : Schema-less example (schema is inferred from data during indexing)
|
|
||||||
techproducts : Kitchen sink example providing comprehensive examples of Solr features
|
|
||||||
|
|
||||||
|
|
||||||
A tutorial is available at:
|
A tutorial is available at:
|
||||||
|
|
||||||
http://lucene.apache.org/solr/tutorial.html
|
http://lucene.apache.org/solr/tutorial.html
|
||||||
|
139
solr/bin/solr
139
solr/bin/solr
@ -123,7 +123,7 @@ function print_usage() {
|
|||||||
if [ -z "$CMD" ]; then
|
if [ -z "$CMD" ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "Usage: solr COMMAND OPTIONS"
|
echo "Usage: solr COMMAND OPTIONS"
|
||||||
echo " where COMMAND is one of: start, stop, restart, status, healthcheck, create_core, create_collection"
|
echo " where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection"
|
||||||
echo ""
|
echo ""
|
||||||
echo " Standalone server example (start Solr running in the background on port 8984):"
|
echo " Standalone server example (start Solr running in the background on port 8984):"
|
||||||
echo ""
|
echo ""
|
||||||
@ -209,49 +209,76 @@ function print_usage() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo " NOTE: This command will show the status of all running Solr servers"
|
echo " NOTE: This command will show the status of all running Solr servers"
|
||||||
echo ""
|
echo ""
|
||||||
|
elif [ "$CMD" == "create" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Usage: solr create [-c name] [-d confdir] [-n configName] [-shards #] [-replicationFactor #] [-p port]"
|
||||||
|
echo ""
|
||||||
|
echo " Create a core or collection depending on whether Solr is running in standalone (core) or SolrCloud"
|
||||||
|
echo " mode (collection). In other words, this action detects which mode Solr is running in, and then takes"
|
||||||
|
echo " the appropriate action (either create_core or create_collection). For detailed usage instructions, do:"
|
||||||
|
echo ""
|
||||||
|
echo " bin/solr create_core -help"
|
||||||
|
echo ""
|
||||||
|
echo " or"
|
||||||
|
echo ""
|
||||||
|
echo " bin/solr create_collection -help"
|
||||||
|
echo ""
|
||||||
elif [ "$CMD" == "create_core" ]; then
|
elif [ "$CMD" == "create_core" ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "Usage: solr create_core [-n name] [-c configset]"
|
echo "Usage: solr create_core [-c core] [-d confdir] [-p port]"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -n <name> Name of core to create"
|
echo " -c <core> Name of core to create"
|
||||||
|
echo ""
|
||||||
|
echo " -d <confdir> Configuration directory to copy when creating the new core, built-in options are:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -c <configset> Name of configuration directory to use, built-in options are:"
|
|
||||||
echo " basic_configs: Minimal Solr configuration"
|
echo " basic_configs: Minimal Solr configuration"
|
||||||
echo " data_driven_schema_configs: Managed schema with field-guessing support enabled"
|
echo " data_driven_schema_configs: Managed schema with field-guessing support enabled"
|
||||||
echo " sample_techproducts_configs: Example configuration with many optional features enabled to"
|
echo " sample_techproducts_configs: Example configuration with many optional features enabled to"
|
||||||
echo " demonstrate the full power of Solr"
|
echo " demonstrate the full power of Solr"
|
||||||
|
echo ""
|
||||||
echo " If not specified, default is: data_driven_schema_configs"
|
echo " If not specified, default is: data_driven_schema_configs"
|
||||||
echo ""
|
echo ""
|
||||||
echo " Alternatively, you can pass the path to your own configuration directory instead of using"
|
echo " Alternatively, you can pass the path to your own configuration directory instead of using"
|
||||||
echo " one of the built-in configurations, such as: bin/solr create_core -n mycore -c /tmp/myconfig"
|
echo " one of the built-in configurations, such as: bin/solr create_core -c mycore -d /tmp/myconfig"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -p <port> Port of a local Solr instance where you want to create the new core"
|
echo " -p <port> Port of a local Solr instance where you want to create the new core"
|
||||||
echo " If not specified, the script will search the local system for a running"
|
echo " If not specified, the script will search the local system for a running"
|
||||||
echo " Solr instance and will use the port of the first server it finds."
|
echo " Solr instance and will use the port of the first server it finds."
|
||||||
echo ""
|
echo ""
|
||||||
elif [ "$CMD" == "create_collection" ]; then
|
elif [ "$CMD" == "create_collection" ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "Usage: solr create_collection [-n name] [-c configset] [-shards #] [-replicationFactor #]"
|
echo "Usage: solr create_collection [-c collection] [-d confdir] [-n configName] [-shards #] [-replicationFactor #] [-p port]"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -n <name> Name of collection to create"
|
echo " -c <collection> Name of collection to create"
|
||||||
|
echo ""
|
||||||
|
echo " -d <confdir> Configuration directory to copy when creating the new collection, built-in options are:"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -c <configset> Name of configuration directory to use, built-in options are:"
|
|
||||||
echo " basic_configs: Minimal Solr configuration"
|
echo " basic_configs: Minimal Solr configuration"
|
||||||
echo " data_driven_schema_configs: Managed schema with field-guessing support enabled"
|
echo " data_driven_schema_configs: Managed schema with field-guessing support enabled"
|
||||||
echo " sample_techproducts_configs: Example configuration with many optional features enabled to"
|
echo " sample_techproducts_configs: Example configuration with many optional features enabled to"
|
||||||
echo " demonstrate the full power of Solr"
|
echo " demonstrate the full power of Solr"
|
||||||
|
echo ""
|
||||||
echo " If not specified, default is: data_driven_schema_configs"
|
echo " If not specified, default is: data_driven_schema_configs"
|
||||||
echo ""
|
echo ""
|
||||||
echo " Alternatively, you can pass the path to your own configuration directory instead of using"
|
echo " Alternatively, you can pass the path to your own configuration directory instead of using"
|
||||||
echo " one of the built-in configurations, such as: bin/solr create_collection -n mycoll -c /tmp/myconfig"
|
echo " one of the built-in configurations, such as: bin/solr create_collection -c mycoll -d /tmp/myconfig"
|
||||||
|
echo ""
|
||||||
|
echo " By default the script will upload the specified confdir directory into ZooKeeper using the same"
|
||||||
|
echo " name as the collection (-c) option. Alternatively, if you want to reuse an existing directory"
|
||||||
|
echo " or create a confdir in ZooKeeper that can be shared by multiple collections, use the -n option"
|
||||||
|
echo ""
|
||||||
|
echo " -n <configName> Name the configuration directory in ZooKeeper; by default, the configuration"
|
||||||
|
echo " will be uploaded to ZooKeeper using the collection name (-c), but if you want"
|
||||||
|
echo " to use an existing directory or override the name of the configuration in"
|
||||||
|
echo " ZooKeeper, then use the -c option."
|
||||||
echo ""
|
echo ""
|
||||||
echo " -shards <#> Number of shards to split the collection into; default is 1"
|
echo " -shards <#> Number of shards to split the collection into; default is 1"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -replicationFactor <#> Number of copies of each document in the collection, default is 1 (no replication)"
|
echo " -replicationFactor <#> Number of copies of each document in the collection, default is 1 (no replication)"
|
||||||
echo ""
|
echo ""
|
||||||
echo " -p <port> Port of a local Solr instance where you want to create the new collection"
|
echo " -p <port> Port of a local Solr instance where you want to create the new collection"
|
||||||
echo " If not specified, the script will search the local system for a running"
|
echo " If not specified, the script will search the local system for a running"
|
||||||
echo " Solr instance and will use the port of the first server it finds."
|
echo " Solr instance and will use the port of the first server it finds."
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
} # end print_usage
|
} # end print_usage
|
||||||
@ -486,32 +513,36 @@ if [ "$SCRIPT_CMD" == "healthcheck" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# create a core or collection
|
# create a core or collection
|
||||||
if [[ "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMD" == "create_collection" ]]; then
|
if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMD" == "create_collection" ]]; then
|
||||||
|
|
||||||
CREATE_TYPE=collection
|
|
||||||
CREATE_NUM_SHARDS=1
|
CREATE_NUM_SHARDS=1
|
||||||
CREATE_REPFACT=1
|
CREATE_REPFACT=1
|
||||||
if [ "$SCRIPT_CMD" == "create_core" ]; then
|
|
||||||
CREATE_TYPE=core
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
while true; do
|
while true; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-n|-name)
|
-c|-core|-collection)
|
||||||
if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
|
if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
|
||||||
print_usage "$SCRIPT_CMD" "$CREATE_TYPE name is required when using the $1 option!"
|
print_usage "$SCRIPT_CMD" "name is required when using the $1 option!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
CREATE_NAME=$2
|
CREATE_NAME=$2
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
-c|-configset)
|
-n|-confname)
|
||||||
if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
|
if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
|
||||||
print_usage "$SCRIPT_CMD" "Configset name is required when using the $1 option!"
|
print_usage "$SCRIPT_CMD" "Configuration name is required when using the $1 option!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
CREATE_CONFIGSET="$2"
|
CREATE_CONFNAME="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
-d|-confdir)
|
||||||
|
if [[ -z "$2" || "${2:0:1}" == "-" ]]; then
|
||||||
|
print_usage "$SCRIPT_CMD" "Configuration directory is required when using the $1 option!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
CREATE_CONFDIR="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
-s|-shards)
|
-s|-shards)
|
||||||
@ -558,22 +589,27 @@ if [[ "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMD" == "create_collection" ]];
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$CREATE_CONFIGSET" ]; then
|
if [ -z "$CREATE_CONFDIR" ]; then
|
||||||
CREATE_CONFIGSET=data_driven_schema_configs
|
CREATE_CONFDIR=data_driven_schema_configs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# validate the configset arg
|
# validate the confdir arg
|
||||||
if [[ ! -d "$SOLR_TIP/server/solr/configsets/$CREATE_CONFIGSET" && ! -d "$CREATE_CONFIGSET" ]]; then
|
if [[ ! -d "$SOLR_TIP/server/solr/configsets/$CREATE_CONFDIR" && ! -d "$CREATE_CONFDIR" ]]; then
|
||||||
echo -e "\nSpecified configset $CREATE_CONFIGSET not found!\n"
|
echo -e "\nSpecified configuration directory $CREATE_CONFDIR not found!\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$CREATE_NAME" ]; then
|
if [ -z "$CREATE_NAME" ]; then
|
||||||
echo "$CREATE_TYPE name is required!"
|
echo "Name (-c) argument is required!"
|
||||||
print_usage "$SCRIPT_CMD"
|
print_usage "$SCRIPT_CMD"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If not defined, use the collection name for the name of the configuration in ZooKeeper
|
||||||
|
if [ -z "$CREATE_CONFNAME" ]; then
|
||||||
|
CREATE_CONFNAME=$CREATE_NAME
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$CREATE_PORT" ]; then
|
if [ -z "$CREATE_PORT" ]; then
|
||||||
for ID in `ps auxww | grep java | grep start.jar | awk '{print $2}' | sort -r`
|
for ID in `ps auxww | grep java | grep start.jar | awk '{print $2}' | sort -r`
|
||||||
do
|
do
|
||||||
@ -586,17 +622,19 @@ if [[ "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMD" == "create_collection" ]];
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$CREATE_PORT" ]; then
|
if [ -z "$CREATE_PORT" ]; then
|
||||||
echo "Failed to determine the port of a local Solr instance, cannot create $CREATE_TYPE $CREATE_NAME"
|
echo "Failed to determine the port of a local Solr instance, cannot create $CREATE_NAME!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$SCRIPT_CMD" == "create_collection" ]; then
|
if [ "$SCRIPT_CMD" == "create_core" ]; then
|
||||||
run_tool create_collection -name $CREATE_NAME -shards $CREATE_NUM_SHARDS -replicationFactor $CREATE_REPFACT \
|
run_tool create_core -name $CREATE_NAME -solrUrl http://localhost:$CREATE_PORT/solr \
|
||||||
-config $CREATE_CONFIGSET -configsetsDir $SOLR_TIP/server/solr/configsets -solrUrl http://localhost:$CREATE_PORT/solr
|
-confdir $CREATE_CONFDIR -configsetsDir $SOLR_TIP/server/solr/configsets
|
||||||
exit $?
|
exit $?
|
||||||
else
|
else
|
||||||
run_tool create_core -name $CREATE_NAME -solrUrl http://localhost:$CREATE_PORT/solr \
|
run_tool $SCRIPT_CMD -name $CREATE_NAME -shards $CREATE_NUM_SHARDS -replicationFactor $CREATE_REPFACT \
|
||||||
-config $CREATE_CONFIGSET -configsetsDir $SOLR_TIP/server/solr/configsets
|
-confname $CREATE_CONFNAME -confdir $CREATE_CONFDIR \
|
||||||
|
-configsetsDir $SOLR_TIP/server/solr/configsets \
|
||||||
|
-solrUrl http://localhost:$CREATE_PORT/solr
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -1211,18 +1249,11 @@ if [ "$EXAMPLE" != "cloud" ]; then
|
|||||||
EXAMPLE_NAME=$EXAMPLE
|
EXAMPLE_NAME=$EXAMPLE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$SOLR_MODE" == "solrcloud" ]; then
|
run_tool create -name $EXAMPLE_NAME -shards 1 -replicationFactor 1 \
|
||||||
run_tool create_collection -name $EXAMPLE_NAME -shards 1 -replicationFactor 1 \
|
-confname $EXAMPLE_NAME -confdir $EXAMPLE_CONFIGSET \
|
||||||
-config $EXAMPLE_CONFIGSET -configsetsDir $SOLR_TIP/server/solr/configsets -solrUrl http://localhost:$SOLR_PORT/solr
|
-configsetsDir $SOLR_TIP/server/solr/configsets -solrUrl http://localhost:$SOLR_PORT/solr
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
|
||||||
else
|
|
||||||
run_tool create_core -name $EXAMPLE_NAME -solrUrl http://localhost:$SOLR_PORT/solr \
|
|
||||||
-config $EXAMPLE_CONFIGSET -configsetsDir $SOLR_TIP/server/solr/configsets
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$EXAMPLE" == "techproducts" ]; then
|
if [ "$EXAMPLE" == "techproducts" ]; then
|
||||||
@ -1253,7 +1284,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\nStarting up SolrCloud node1 on port ${CLOUD_PORTS[0]} using command:\n"
|
echo -e "\nStarting up SolrCloud node1 on port ${CLOUD_PORTS[0]} using command:\n"
|
||||||
echo -e "solr start -cloud -s $SOLR_HOME -p $SOLR_PORT $DASHZ $DASHM $DASHA\n\n"
|
echo -e "solr start -cloud -s example/cloud/node1/solr -p $SOLR_PORT $DASHZ $DASHM $DASHA\n\n"
|
||||||
|
|
||||||
# can't launch this node in the foreground else we can't run anymore commands
|
# can't launch this node in the foreground else we can't run anymore commands
|
||||||
launch_solr "false" "$ADDITIONAL_CMD_OPTS"
|
launch_solr "false" "$ADDITIONAL_CMD_OPTS"
|
||||||
@ -1270,7 +1301,7 @@ else
|
|||||||
ndx=$[$s+1]
|
ndx=$[$s+1]
|
||||||
next_port=${CLOUD_PORTS[$s]}
|
next_port=${CLOUD_PORTS[$s]}
|
||||||
echo -e "\n\nStarting node$ndx on port $next_port using command:\n"
|
echo -e "\n\nStarting node$ndx on port $next_port using command:\n"
|
||||||
echo -e "solr start -cloud -s $SOLR_TIP/example/cloud/node$ndx/solr -p $next_port -z $zk_host $DASHM $DASHA \n\n"
|
echo -e "solr start -cloud -s example/cloud/node$ndx/solr -p $next_port -z $zk_host $DASHM $DASHA \n\n"
|
||||||
# call this script again with correct args for next node
|
# call this script again with correct args for next node
|
||||||
$SOLR_TIP/bin/solr start -cloud -s $SOLR_TIP/example/cloud/node$ndx/solr -p $next_port -z $zk_host $DASHM $DASHA
|
$SOLR_TIP/bin/solr start -cloud -s $SOLR_TIP/example/cloud/node$ndx/solr -p $next_port -z $zk_host $DASHM $DASHA
|
||||||
done
|
done
|
||||||
@ -1329,7 +1360,7 @@ else
|
|||||||
CLOUD_CONFIG=data_driven_schema_configs
|
CLOUD_CONFIG=data_driven_schema_configs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# validate the configset arg
|
# validate the confdir arg
|
||||||
if [[ ! -d "$SOLR_TIP/server/solr/configsets/$CLOUD_CONFIG" && ! -d "$CLOUD_CONFIG" ]]; then
|
if [[ ! -d "$SOLR_TIP/server/solr/configsets/$CLOUD_CONFIG" && ! -d "$CLOUD_CONFIG" ]]; then
|
||||||
echo -e "\nOops! Specified configuration $CLOUD_CONFIG not found!"
|
echo -e "\nOops! Specified configuration $CLOUD_CONFIG not found!"
|
||||||
read -e -p "Choose one of: basic_configs, data_driven_schema_configs, or sample_techproducts_configs [data_driven_schema_configs] " USER_INPUT
|
read -e -p "Choose one of: basic_configs, data_driven_schema_configs, or sample_techproducts_configs [data_driven_schema_configs] " USER_INPUT
|
||||||
@ -1342,7 +1373,9 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
run_tool create_collection -name $CLOUD_COLLECTION -shards $CLOUD_NUM_SHARDS -replicationFactor $CLOUD_REPFACT \
|
run_tool create_collection -name $CLOUD_COLLECTION -shards $CLOUD_NUM_SHARDS -replicationFactor $CLOUD_REPFACT \
|
||||||
-config $CLOUD_CONFIG -configsetsDir $SOLR_TIP/server/solr/configsets -solrUrl http://localhost:$SOLR_PORT/solr
|
-confname $CLOUD_COLLECTION -confdir $CLOUD_CONFIG \
|
||||||
|
-configsetsDir $SOLR_TIP/server/solr/configsets -solrUrl http://localhost:$SOLR_PORT/solr
|
||||||
|
|
||||||
echo -e "\n\nSolrCloud example running, please visit http://localhost:$SOLR_PORT/solr \n\n"
|
echo -e "\n\nSolrCloud example running, please visit http://localhost:$SOLR_PORT/solr \n\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -76,6 +76,11 @@ IF "%1"=="healthcheck" (
|
|||||||
SHIFT
|
SHIFT
|
||||||
goto parse_healthcheck_args
|
goto parse_healthcheck_args
|
||||||
)
|
)
|
||||||
|
IF "%1"=="create" (
|
||||||
|
set SCRIPT_CMD=create
|
||||||
|
SHIFT
|
||||||
|
goto parse_create_args
|
||||||
|
)
|
||||||
IF "%1"=="create_core" (
|
IF "%1"=="create_core" (
|
||||||
set SCRIPT_CMD=create_core
|
set SCRIPT_CMD=create_core
|
||||||
SHIFT
|
SHIFT
|
||||||
@ -98,6 +103,7 @@ IF "%SCRIPT_CMD%"=="start" goto start_usage
|
|||||||
IF "%SCRIPT_CMD%"=="restart" goto start_usage
|
IF "%SCRIPT_CMD%"=="restart" goto start_usage
|
||||||
IF "%SCRIPT_CMD%"=="stop" goto stop_usage
|
IF "%SCRIPT_CMD%"=="stop" goto stop_usage
|
||||||
IF "%SCRIPT_CMD%"=="healthcheck" goto healthcheck_usage
|
IF "%SCRIPT_CMD%"=="healthcheck" goto healthcheck_usage
|
||||||
|
IF "%SCRIPT_CMD%"=="create" goto create_usage
|
||||||
IF "%SCRIPT_CMD%"=="create_core" goto create_core_usage
|
IF "%SCRIPT_CMD%"=="create_core" goto create_core_usage
|
||||||
IF "%SCRIPT_CMD%"=="create_collection" goto create_collection_usage
|
IF "%SCRIPT_CMD%"=="create_collection" goto create_collection_usage
|
||||||
goto done
|
goto done
|
||||||
@ -105,7 +111,7 @@ goto done
|
|||||||
:script_usage
|
:script_usage
|
||||||
@echo.
|
@echo.
|
||||||
@echo Usage: solr COMMAND OPTIONS
|
@echo Usage: solr COMMAND OPTIONS
|
||||||
@echo where COMMAND is one of: start, stop, restart, healthcheck, create_core, create_collection
|
@echo where COMMAND is one of: start, stop, restart, healthcheck, create, create_core, create_collection
|
||||||
@echo.
|
@echo.
|
||||||
@echo Standalone server example (start Solr running in the background on port 8984):
|
@echo Standalone server example (start Solr running in the background on port 8984):
|
||||||
@echo.
|
@echo.
|
||||||
@ -188,45 +194,80 @@ goto done
|
|||||||
@echo.
|
@echo.
|
||||||
goto done
|
goto done
|
||||||
|
|
||||||
|
:create_usage
|
||||||
|
echo.
|
||||||
|
echo Usage: solr create [-c name] [-d confdir] [-n confname] [-shards #] [-replicationFactor #] [-p port]
|
||||||
|
echo.
|
||||||
|
echo Create a core or collection depending on whether Solr is running in standalone (core) or SolrCloud
|
||||||
|
echo mode (collection). In other words, this action detects which mode Solr is running in, and then takes
|
||||||
|
echo the appropriate action (either create_core or create_collection). For detailed usage instructions, do:
|
||||||
|
echo.
|
||||||
|
echo bin\solr create_core -help
|
||||||
|
echo.
|
||||||
|
echo or
|
||||||
|
echo.
|
||||||
|
echo bin\solr create_collection -help
|
||||||
|
echo.
|
||||||
|
goto done
|
||||||
|
|
||||||
:create_core_usage
|
:create_core_usage
|
||||||
echo.
|
echo.
|
||||||
echo Usage: solr create_core [-n name] [-c configset]
|
echo Usage: solr create_core [-c name] [-d confdir] [-p port]
|
||||||
echo.
|
echo.
|
||||||
echo -n name Name of core to create
|
echo -c name Name of core to create
|
||||||
|
echo.
|
||||||
|
echo -d confdir Configuration directory to copy when creating the new core, built-in options are:
|
||||||
echo.
|
echo.
|
||||||
echo -c configset Name of configuration directory to use, valid options are:
|
|
||||||
echo basic_configs: Minimal Solr configuration
|
echo basic_configs: Minimal Solr configuration
|
||||||
echo data_driven_schema_configs: Managed schema with field-guessing support enabled
|
echo data_driven_schema_configs: Managed schema with field-guessing support enabled
|
||||||
echo sample_techproducts_configs: Example configuration with many optional features enabled to
|
echo sample_techproducts_configs: Example configuration with many optional features enabled to
|
||||||
echo demonstrate the full power of Solr
|
echo demonstrate the full power of Solr
|
||||||
|
echo.
|
||||||
echo If not specified, default is: data_driven_schema_configs
|
echo If not specified, default is: data_driven_schema_configs
|
||||||
echo.
|
echo.
|
||||||
echo -p port Port of a local Solr instance where you want to create the new core
|
echo Alternatively, you can pass the path to your own configuration directory instead of using
|
||||||
echo If not specified, the script will search the local system for a running
|
echo one of the built-in configurations, such as: bin\solr create_core -c mycore -d c:/tmp/myconfig
|
||||||
echo Solr instance and will use the port of the first server it finds.
|
echo.
|
||||||
|
echo -p port Port of a local Solr instance where you want to create the new core
|
||||||
|
echo If not specified, the script will search the local system for a running
|
||||||
|
echo Solr instance and will use the port of the first server it finds.
|
||||||
echo.
|
echo.
|
||||||
goto done
|
goto done
|
||||||
|
|
||||||
:create_collection_usage
|
:create_collection_usage
|
||||||
echo.
|
echo.
|
||||||
echo Usage: solr create_collection [-n name] [-c configset] [-shards #] [-replicationFactor #]
|
echo Usage: solr create_collection [-c name] [-d confdir] [-n confname] [-shards #] [-replicationFactor #] [-p port]
|
||||||
echo.
|
echo.
|
||||||
echo -n name Name of collection to create
|
echo -c name Name of collection to create
|
||||||
|
echo.
|
||||||
|
echo -d confdir Configuration directory to copy when creating the new collection, built-in options are:
|
||||||
echo.
|
echo.
|
||||||
echo -c configset Name of configuration directory to use, valid options are:
|
|
||||||
echo basic_configs: Minimal Solr configuration
|
echo basic_configs: Minimal Solr configuration
|
||||||
echo data_driven_schema_configs: Managed schema with field-guessing support enabled
|
echo data_driven_schema_configs: Managed schema with field-guessing support enabled
|
||||||
echo sample_techproducts_configs: Example configuration with many optional features enabled to
|
echo sample_techproducts_configs: Example configuration with many optional features enabled to
|
||||||
echo demonstrate the full power of Solr
|
echo demonstrate the full power of Solr
|
||||||
|
echo.
|
||||||
echo If not specified, default is: data_driven_schema_configs
|
echo If not specified, default is: data_driven_schema_configs
|
||||||
echo.
|
echo.
|
||||||
|
echo Alternatively, you can pass the path to your own configuration directory instead of using
|
||||||
|
echo one of the built-in configurations, such as: bin\solr create_collection -c mycoll -d c:/tmp/myconfig
|
||||||
|
echo.
|
||||||
|
echo By default the script will upload the specified confdir directory into ZooKeeper using the same
|
||||||
|
echo name as the collection (-c) option. Alternatively, if you want to reuse an existing directory
|
||||||
|
echo or create a confdir in ZooKeeper that can be shared by multiple collections, use the -n option
|
||||||
|
echo.
|
||||||
|
echo -n configName Name the configuration directory in ZooKeeper; by default, the configuration
|
||||||
|
echo will be uploaded to ZooKeeper using the collection name (-c), but if you want
|
||||||
|
echo to use an existing directory or override the name of the configuration in
|
||||||
|
echo ZooKeeper, then use the -c option.
|
||||||
|
echo.
|
||||||
echo -shards # Number of shards to split the collection into
|
echo -shards # Number of shards to split the collection into
|
||||||
echo.
|
echo.
|
||||||
echo -replicationFactor # Number of copies of each document in the collection
|
echo -replicationFactor # Number of copies of each document in the collection
|
||||||
echo.
|
echo.
|
||||||
echo -p port Port of a local Solr instance where you want to create the new collection
|
echo -p port Port of a local Solr instance where you want to create the new collection
|
||||||
echo If not specified, the script will search the local system for a running
|
echo If not specified, the script will search the local system for a running
|
||||||
echo Solr instance and will use the port of the first server it finds.
|
echo Solr instance and will use the port of the first server it finds.
|
||||||
echo.
|
echo.
|
||||||
goto done
|
goto done
|
||||||
|
|
||||||
@ -758,12 +799,12 @@ IF NOT "!CREATE_EXAMPLE_CONFIG!"=="" (
|
|||||||
"%JAVA%" -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
|
"%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\*" ^
|
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
|
||||||
org.apache.solr.util.SolrCLI create_collection -name !EXAMPLE_NAME! -shards 1 -replicationFactor 1 ^
|
org.apache.solr.util.SolrCLI create_collection -name !EXAMPLE_NAME! -shards 1 -replicationFactor 1 ^
|
||||||
-config !CREATE_EXAMPLE_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets" -solrUrl http://localhost:%SOLR_PORT%/solr
|
-confdir !CREATE_EXAMPLE_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets" -solrUrl http://localhost:%SOLR_PORT%/solr
|
||||||
) ELSE (
|
) ELSE (
|
||||||
"%JAVA%" -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
|
"%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\*" ^
|
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
|
||||||
org.apache.solr.util.SolrCLI create_core -name !EXAMPLE_NAME! -solrUrl http://localhost:%SOLR_PORT%/solr ^
|
org.apache.solr.util.SolrCLI create_core -name !EXAMPLE_NAME! -solrUrl http://localhost:%SOLR_PORT%/solr ^
|
||||||
-config !CREATE_EXAMPLE_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets"
|
-confdir !CREATE_EXAMPLE_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -929,7 +970,7 @@ goto create_collection
|
|||||||
"%JAVA%" -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
|
"%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\*" ^
|
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
|
||||||
org.apache.solr.util.SolrCLI create_collection -name !CLOUD_COLLECTION! -shards !CLOUD_NUM_SHARDS! -replicationFactor !CLOUD_REPFACT! ^
|
org.apache.solr.util.SolrCLI create_collection -name !CLOUD_COLLECTION! -shards !CLOUD_NUM_SHARDS! -replicationFactor !CLOUD_REPFACT! ^
|
||||||
-config !CLOUD_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets" -zkHost %zk_host%
|
-confdir !CLOUD_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets" -zkHost %zk_host%
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo SolrCloud example is running, please visit http://localhost:%NODE1_PORT%/solr"
|
echo SolrCloud example is running, please visit http://localhost:%NODE1_PORT%/solr"
|
||||||
@ -996,26 +1037,38 @@ goto done
|
|||||||
|
|
||||||
:parse_create_args
|
:parse_create_args
|
||||||
IF [%1]==[] goto run_create
|
IF [%1]==[] goto run_create
|
||||||
IF "%1"=="-c" goto set_create_config
|
IF "%1"=="-c" goto set_create_name
|
||||||
IF "%1"=="-configset" goto set_create_config
|
IF "%1"=="-core" goto set_create_name
|
||||||
IF "%1"=="-n" goto set_create_name
|
IF "%1"=="-collection" goto set_create_name
|
||||||
IF "%1"=="-name" goto set_create_name
|
IF "%1"=="-d" goto set_create_confdir
|
||||||
|
IF "%1"=="-confdir" goto set_create_confdir
|
||||||
|
IF "%1"=="-n" goto set_create_confname
|
||||||
|
IF "%1"=="-confname" goto set_create_confname
|
||||||
|
IF "%1"=="-s" goto set_create_shards
|
||||||
IF "%1"=="-shards" goto set_create_shards
|
IF "%1"=="-shards" goto set_create_shards
|
||||||
|
IF "%1"=="-rf" goto set_create_rf
|
||||||
IF "%1"=="-replicationFactor" goto set_create_rf
|
IF "%1"=="-replicationFactor" goto set_create_rf
|
||||||
IF "%1"=="-p" goto set_create_port
|
IF "%1"=="-p" goto set_create_port
|
||||||
|
IF "%1"=="-port" goto set_create_port
|
||||||
IF "%1"=="-help" goto usage
|
IF "%1"=="-help" goto usage
|
||||||
IF "%1"=="-usage" goto usage
|
IF "%1"=="-usage" goto usage
|
||||||
IF "%1"=="/?" goto usage
|
IF "%1"=="/?" goto usage
|
||||||
goto run_create
|
goto run_create
|
||||||
|
|
||||||
:set_create_configset
|
:set_create_name
|
||||||
set CREATE_CONFIGSET=%~2
|
set CREATE_NAME=%~2
|
||||||
SHIFT
|
SHIFT
|
||||||
SHIFT
|
SHIFT
|
||||||
goto parse_create_args
|
goto parse_create_args
|
||||||
|
|
||||||
:set_create_name
|
:set_create_confdir
|
||||||
set CREATE_NAME=%~2
|
set CREATE_CONFDIR=%~2
|
||||||
|
SHIFT
|
||||||
|
SHIFT
|
||||||
|
goto parse_create_args
|
||||||
|
|
||||||
|
:set_create_confname
|
||||||
|
set CREATE_CONFNAME=%~2
|
||||||
SHIFT
|
SHIFT
|
||||||
SHIFT
|
SHIFT
|
||||||
goto parse_create_args
|
goto parse_create_args
|
||||||
@ -1040,12 +1093,13 @@ goto parse_create_args
|
|||||||
|
|
||||||
:run_create
|
:run_create
|
||||||
IF "!CREATE_NAME!"=="" (
|
IF "!CREATE_NAME!"=="" (
|
||||||
set "SCRIPT_ERROR=Name (-n) is a required parameter for %SCRIPT_CMD%"
|
set "SCRIPT_ERROR=Name (-c) is a required parameter for %SCRIPT_CMD%"
|
||||||
goto invalid_cmd_line
|
goto invalid_cmd_line
|
||||||
)
|
)
|
||||||
IF "!CREATE_CONFIGSET!"=="" set CREATE_CONFIGSET=data_driven_schema_configs
|
IF "!CREATE_CONFDIR!"=="" set CREATE_CONFDIR=data_driven_schema_configs
|
||||||
IF "!CREATE_NUM_SHARDS!"=="" set CREATE_NUM_SHARDS=1
|
IF "!CREATE_NUM_SHARDS!"=="" set CREATE_NUM_SHARDS=1
|
||||||
IF "!CREATE_REPFACT!"=="" set CREATE_REPFACT=1
|
IF "!CREATE_REPFACT!"=="" set CREATE_REPFACT=1
|
||||||
|
IF "!CREATE_CONFNAME!"=="" set CREATE_CONFNAME=!CREATE_NAME!
|
||||||
|
|
||||||
REM Find a port that Solr is running on
|
REM Find a port that Solr is running on
|
||||||
if "!CREATE_PORT!"=="" (
|
if "!CREATE_PORT!"=="" (
|
||||||
@ -1064,19 +1118,18 @@ if "!CREATE_PORT!"=="" (
|
|||||||
goto err
|
goto err
|
||||||
)
|
)
|
||||||
|
|
||||||
@echo Found Solr node running on port !CREATE_PORT!
|
|
||||||
|
|
||||||
if "%SCRIPT_CMD%"=="create_core" (
|
if "%SCRIPT_CMD%"=="create_core" (
|
||||||
"%JAVA%" -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
|
"%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\*" ^
|
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
|
||||||
org.apache.solr.util.SolrCLI create_core -name !CREATE_NAME! -solrUrl http://localhost:!CREATE_PORT!/solr ^
|
org.apache.solr.util.SolrCLI create_core -name !CREATE_NAME! -solrUrl http://localhost:!CREATE_PORT!/solr ^
|
||||||
-config !CREATE_CONFIGSET! -configsetsDir "%SOLR_TIP%\server\solr\configsets"
|
-confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets"
|
||||||
) else (
|
) else (
|
||||||
"%JAVA%" -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^
|
"%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\*" ^
|
-classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
|
||||||
org.apache.solr.util.SolrCLI create_collection -name !CREATE_NAME! -shards !CREATE_NUM_SHARDS! -replicationFactor !CREATE_REPFACT! ^
|
org.apache.solr.util.SolrCLI create -name !CREATE_NAME! -shards !CREATE_NUM_SHARDS! -replicationFactor !CREATE_REPFACT! ^
|
||||||
-config !CREATE_CONFIGSET! -configsetsDir "%SOLR_TIP%\server\solr\configsets" -solrUrl http://localhost:!CREATE_PORT!/solr
|
-confname !CREATE_CONFNAME! -confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets" -solrUrl http://localhost:!CREATE_PORT!/solr
|
||||||
)
|
)
|
||||||
|
|
||||||
goto done
|
goto done
|
||||||
|
|
||||||
:invalid_cmd_line
|
:invalid_cmd_line
|
||||||
@ -1097,6 +1150,8 @@ IF "%FIRST_ARG%"=="start" (
|
|||||||
goto stop_usage
|
goto stop_usage
|
||||||
) ELSE IF "%FIRST_ARG%"=="healthcheck" (
|
) ELSE IF "%FIRST_ARG%"=="healthcheck" (
|
||||||
goto healthcheck_usage
|
goto healthcheck_usage
|
||||||
|
) ELSE IF "%FIRST_ARG%"=="create" (
|
||||||
|
goto create_usage
|
||||||
) ELSE IF "%FIRST_ARG%"=="create_core" (
|
) ELSE IF "%FIRST_ARG%"=="create_core" (
|
||||||
goto create_core_usage
|
goto create_core_usage
|
||||||
) ELSE IF "%FIRST_ARG%"=="create_collection" (
|
) ELSE IF "%FIRST_ARG%"=="create_collection" (
|
||||||
|
@ -127,7 +127,7 @@ public class SolrCLI {
|
|||||||
// since this is a CLI, spare the user the stacktrace
|
// since this is a CLI, spare the user the stacktrace
|
||||||
String excMsg = exc.getMessage();
|
String excMsg = exc.getMessage();
|
||||||
if (excMsg != null) {
|
if (excMsg != null) {
|
||||||
System.err.println("\nERROR:"+excMsg+"\n");
|
System.err.println("\nERROR: "+excMsg+"\n");
|
||||||
exitStatus = 1;
|
exitStatus = 1;
|
||||||
} else {
|
} else {
|
||||||
throw exc;
|
throw exc;
|
||||||
@ -215,6 +215,8 @@ public class SolrCLI {
|
|||||||
return new CreateCollectionTool();
|
return new CreateCollectionTool();
|
||||||
else if ("create_core".equals(toolType))
|
else if ("create_core".equals(toolType))
|
||||||
return new CreateCoreTool();
|
return new CreateCoreTool();
|
||||||
|
else if ("create".equals(toolType))
|
||||||
|
return new CreateTool();
|
||||||
|
|
||||||
// If you add a built-in tool to this class, add it here to avoid
|
// If you add a built-in tool to this class, add it here to avoid
|
||||||
// classpath scanning
|
// classpath scanning
|
||||||
@ -235,6 +237,7 @@ public class SolrCLI {
|
|||||||
formatter.printHelp("api", getToolOptions(new ApiTool()));
|
formatter.printHelp("api", getToolOptions(new ApiTool()));
|
||||||
formatter.printHelp("create_collection", getToolOptions(new CreateCollectionTool()));
|
formatter.printHelp("create_collection", getToolOptions(new CreateCollectionTool()));
|
||||||
formatter.printHelp("create_core", getToolOptions(new CreateCoreTool()));
|
formatter.printHelp("create_core", getToolOptions(new CreateCoreTool()));
|
||||||
|
formatter.printHelp("create", getToolOptions(new CreateTool()));
|
||||||
|
|
||||||
List<Class<Tool>> toolClasses = findToolClassesInPackage("org.apache.solr.util");
|
List<Class<Tool>> toolClasses = findToolClassesInPackage("org.apache.solr.util");
|
||||||
for (Class<Tool> next : toolClasses) {
|
for (Class<Tool> next : toolClasses) {
|
||||||
@ -993,6 +996,64 @@ public class SolrCLI {
|
|||||||
}
|
}
|
||||||
} // end HealthcheckTool
|
} // end HealthcheckTool
|
||||||
|
|
||||||
|
private static final Option[] CREATE_COLLECTION_OPTIONS = new Option[] {
|
||||||
|
OptionBuilder
|
||||||
|
.withArgName("HOST")
|
||||||
|
.hasArg()
|
||||||
|
.isRequired(false)
|
||||||
|
.withDescription("Address of the Zookeeper ensemble; defaults to: "+ZK_HOST)
|
||||||
|
.create("zkHost"),
|
||||||
|
OptionBuilder
|
||||||
|
.withArgName("HOST")
|
||||||
|
.hasArg()
|
||||||
|
.isRequired(false)
|
||||||
|
.withDescription("Base Solr URL, which can be used to determine the zkHost if that's not known")
|
||||||
|
.create("solrUrl"),
|
||||||
|
OptionBuilder
|
||||||
|
.withArgName("NAME")
|
||||||
|
.hasArg()
|
||||||
|
.isRequired(true)
|
||||||
|
.withDescription("Name of collection to create.")
|
||||||
|
.create("name"),
|
||||||
|
OptionBuilder
|
||||||
|
.withArgName("#")
|
||||||
|
.hasArg()
|
||||||
|
.isRequired(false)
|
||||||
|
.withDescription("Number of shards; default is 1")
|
||||||
|
.create("shards"),
|
||||||
|
OptionBuilder
|
||||||
|
.withArgName("#")
|
||||||
|
.hasArg()
|
||||||
|
.isRequired(false)
|
||||||
|
.withDescription("Number of copies of each document across the collection (replicas per shard); default is 1")
|
||||||
|
.create("replicationFactor"),
|
||||||
|
OptionBuilder
|
||||||
|
.withArgName("#")
|
||||||
|
.hasArg()
|
||||||
|
.isRequired(false)
|
||||||
|
.withDescription("Maximum number of shards per Solr node; default is determined based on the number of shards, replication factor, and live nodes.")
|
||||||
|
.create("maxShardsPerNode"),
|
||||||
|
OptionBuilder
|
||||||
|
.withArgName("NAME")
|
||||||
|
.hasArg()
|
||||||
|
.isRequired(false)
|
||||||
|
.withDescription("Configuration directory to copy when creating the new collection; default is "+DEFAULT_CONFIG_SET)
|
||||||
|
.create("confdir"),
|
||||||
|
OptionBuilder
|
||||||
|
.withArgName("NAME")
|
||||||
|
.hasArg()
|
||||||
|
.isRequired(false)
|
||||||
|
.withDescription("Configuration name; default is the collection name")
|
||||||
|
.create("confname"),
|
||||||
|
OptionBuilder
|
||||||
|
.withArgName("DIR")
|
||||||
|
.hasArg()
|
||||||
|
.isRequired(true)
|
||||||
|
.withDescription("Path to configsets directory on the local system.")
|
||||||
|
.create("configsetsDir")
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supports create_collection command in the bin/solr script.
|
* Supports create_collection command in the bin/solr script.
|
||||||
*/
|
*/
|
||||||
@ -1006,56 +1067,7 @@ public class SolrCLI {
|
|||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
@Override
|
@Override
|
||||||
public Option[] getOptions() {
|
public Option[] getOptions() {
|
||||||
return new Option[] {
|
return CREATE_COLLECTION_OPTIONS;
|
||||||
OptionBuilder
|
|
||||||
.withArgName("HOST")
|
|
||||||
.hasArg()
|
|
||||||
.isRequired(false)
|
|
||||||
.withDescription("Address of the Zookeeper ensemble; defaults to: "+ZK_HOST)
|
|
||||||
.create("zkHost"),
|
|
||||||
OptionBuilder
|
|
||||||
.withArgName("HOST")
|
|
||||||
.hasArg()
|
|
||||||
.isRequired(false)
|
|
||||||
.withDescription("Base Solr URL, which can be used to determine the zkHost if that's not known")
|
|
||||||
.create("solrUrl"),
|
|
||||||
OptionBuilder
|
|
||||||
.withArgName("NAME")
|
|
||||||
.hasArg()
|
|
||||||
.isRequired(true)
|
|
||||||
.withDescription("Name of collection to create.")
|
|
||||||
.create("name"),
|
|
||||||
OptionBuilder
|
|
||||||
.withArgName("#")
|
|
||||||
.hasArg()
|
|
||||||
.isRequired(false)
|
|
||||||
.withDescription("Number of shards; default is 1")
|
|
||||||
.create("shards"),
|
|
||||||
OptionBuilder
|
|
||||||
.withArgName("#")
|
|
||||||
.hasArg()
|
|
||||||
.isRequired(false)
|
|
||||||
.withDescription("Number of copies of each document across the collection (replicas per shard); default is 1")
|
|
||||||
.create("replicationFactor"),
|
|
||||||
OptionBuilder
|
|
||||||
.withArgName("#")
|
|
||||||
.hasArg()
|
|
||||||
.isRequired(false)
|
|
||||||
.withDescription("Maximum number of shards per Solr node; default is determined based on the number of shards, replication factor, and live nodes.")
|
|
||||||
.create("maxShardsPerNode"),
|
|
||||||
OptionBuilder
|
|
||||||
.withArgName("NAME")
|
|
||||||
.hasArg()
|
|
||||||
.isRequired(false)
|
|
||||||
.withDescription("Name of the configuration for this collection; default is "+DEFAULT_CONFIG_SET)
|
|
||||||
.create("config"),
|
|
||||||
OptionBuilder
|
|
||||||
.withArgName("DIR")
|
|
||||||
.hasArg()
|
|
||||||
.isRequired(true)
|
|
||||||
.withDescription("Path to configsets directory on the local system.")
|
|
||||||
.create("configsetsDir")
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int runTool(CommandLine cli) throws Exception {
|
public int runTool(CommandLine cli) throws Exception {
|
||||||
@ -1137,6 +1149,8 @@ public class SolrCLI {
|
|||||||
"there is at least 1 live node in the cluster.");
|
"there is at least 1 live node in the cluster.");
|
||||||
String firstLiveNode = liveNodes.iterator().next();
|
String firstLiveNode = liveNodes.iterator().next();
|
||||||
|
|
||||||
|
String collectionName = cli.getOptionValue("name");
|
||||||
|
|
||||||
// build a URL to create the collection
|
// build a URL to create the collection
|
||||||
int numShards = optionAsInt(cli, "shards", 1);
|
int numShards = optionAsInt(cli, "shards", 1);
|
||||||
int replicationFactor = optionAsInt(cli, "replicationFactor", 1);
|
int replicationFactor = optionAsInt(cli, "replicationFactor", 1);
|
||||||
@ -1150,48 +1164,51 @@ public class SolrCLI {
|
|||||||
maxShardsPerNode = ((numShards*replicationFactor)+numNodes-1)/numNodes;
|
maxShardsPerNode = ((numShards*replicationFactor)+numNodes-1)/numNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
String configSet = cli.getOptionValue("config", DEFAULT_CONFIG_SET);
|
String confname = cli.getOptionValue("confname", collectionName);
|
||||||
String configSetNameInZk = configSet;
|
boolean configExistsInZk =
|
||||||
File configSetDir = null;
|
cloudSolrClient.getZkStateReader().getZkClient().exists("/configs/"+confname, true);
|
||||||
// we try to be flexible and allow the user to specify a configuration directory instead of a configset name
|
|
||||||
File possibleConfigDir = new File(configSet);
|
if (configExistsInZk) {
|
||||||
if (possibleConfigDir.isDirectory()) {
|
System.out.println("Re-using existing configuration directory "+confname);
|
||||||
configSetDir = possibleConfigDir;
|
|
||||||
configSetNameInZk = possibleConfigDir.getName();
|
|
||||||
} else {
|
} else {
|
||||||
File configsetsDir = new File(cli.getOptionValue("configsetsDir"));
|
String configSet = cli.getOptionValue("confdir", DEFAULT_CONFIG_SET);
|
||||||
if (!configsetsDir.isDirectory())
|
File configSetDir = null;
|
||||||
throw new FileNotFoundException(configsetsDir.getAbsolutePath()+" not found!");
|
// we try to be flexible and allow the user to specify a configuration directory instead of a configset name
|
||||||
|
File possibleConfigDir = new File(configSet);
|
||||||
// upload the configset if it exists
|
if (possibleConfigDir.isDirectory()) {
|
||||||
configSetDir = new File(configsetsDir, configSet);
|
configSetDir = possibleConfigDir;
|
||||||
if (!configSetDir.isDirectory()) {
|
|
||||||
throw new FileNotFoundException("Specified config " + configSet +
|
|
||||||
" not found in " + configsetsDir.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
File confDir = new File(configSetDir, "conf");
|
|
||||||
if (!confDir.isDirectory()) {
|
|
||||||
// config dir should contain a conf sub-directory but if not and there's a solrconfig.xml, then use it
|
|
||||||
if ((new File(configSetDir, "solrconfig.xml")).isFile()) {
|
|
||||||
confDir = configSetDir;
|
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Specified configuration directory "+configSetDir.getAbsolutePath()+
|
File configsetsDir = new File(cli.getOptionValue("configsetsDir"));
|
||||||
" is invalid;\nit should contain either conf sub-directory or solrconfig.xml");
|
if (!configsetsDir.isDirectory())
|
||||||
return 1;
|
throw new FileNotFoundException(configsetsDir.getAbsolutePath()+" not found!");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// test to see if that config exists in ZK
|
// upload the configset if it exists
|
||||||
if (!cloudSolrClient.getZkStateReader().getZkClient().exists("/configs/"+configSetNameInZk, true)) {
|
configSetDir = new File(configsetsDir, configSet);
|
||||||
|
if (!configSetDir.isDirectory()) {
|
||||||
|
throw new FileNotFoundException("Specified config " + configSet +
|
||||||
|
" not found in " + configsetsDir.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File confDir = new File(configSetDir, "conf");
|
||||||
|
if (!confDir.isDirectory()) {
|
||||||
|
// config dir should contain a conf sub-directory but if not and there's a solrconfig.xml, then use it
|
||||||
|
if ((new File(configSetDir, "solrconfig.xml")).isFile()) {
|
||||||
|
confDir = configSetDir;
|
||||||
|
} else {
|
||||||
|
System.err.println("Specified configuration directory "+configSetDir.getAbsolutePath()+
|
||||||
|
" is invalid;\nit should contain either conf sub-directory or solrconfig.xml");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// test to see if that config exists in ZK
|
||||||
System.out.println("Uploading "+confDir.getAbsolutePath()+
|
System.out.println("Uploading "+confDir.getAbsolutePath()+
|
||||||
" for config "+configSetNameInZk+" to ZooKeeper at "+cloudSolrClient.getZkHost());
|
" for config "+confname+" to ZooKeeper at "+cloudSolrClient.getZkHost());
|
||||||
ZkController.uploadConfigDir(cloudSolrClient.getZkStateReader().getZkClient(), confDir, configSetNameInZk);
|
ZkController.uploadConfigDir(cloudSolrClient.getZkStateReader().getZkClient(), confDir, confname);
|
||||||
}
|
}
|
||||||
|
|
||||||
String baseUrl = cloudSolrClient.getZkStateReader().getBaseUrlForNodeName(firstLiveNode);
|
String baseUrl = cloudSolrClient.getZkStateReader().getBaseUrlForNodeName(firstLiveNode);
|
||||||
String collectionName = cli.getOptionValue("name");
|
|
||||||
|
|
||||||
// since creating a collection is a heavy-weight operation, check for existence first
|
// since creating a collection is a heavy-weight operation, check for existence first
|
||||||
String collectionListUrl = baseUrl+"/admin/collections?action=list";
|
String collectionListUrl = baseUrl+"/admin/collections?action=list";
|
||||||
@ -1211,7 +1228,7 @@ public class SolrCLI {
|
|||||||
numShards,
|
numShards,
|
||||||
replicationFactor,
|
replicationFactor,
|
||||||
maxShardsPerNode,
|
maxShardsPerNode,
|
||||||
configSetNameInZk);
|
confname);
|
||||||
|
|
||||||
System.out.println("\nCreating new collection '"+collectionName+"' using command:\n"+createCollectionUrl+"\n");
|
System.out.println("\nCreating new collection '"+collectionName+"' using command:\n"+createCollectionUrl+"\n");
|
||||||
|
|
||||||
@ -1282,8 +1299,8 @@ public class SolrCLI {
|
|||||||
.withArgName("CONFIG")
|
.withArgName("CONFIG")
|
||||||
.hasArg()
|
.hasArg()
|
||||||
.isRequired(false)
|
.isRequired(false)
|
||||||
.withDescription("Name of the configuration for this core; default is "+DEFAULT_CONFIG_SET)
|
.withDescription("Configuration directory to copy when creating the new core; default is "+DEFAULT_CONFIG_SET)
|
||||||
.create("config"),
|
.create("confdir"),
|
||||||
OptionBuilder
|
OptionBuilder
|
||||||
.withArgName("DIR")
|
.withArgName("DIR")
|
||||||
.hasArg()
|
.hasArg()
|
||||||
@ -1304,7 +1321,7 @@ public class SolrCLI {
|
|||||||
if (!configsetsDir.isDirectory())
|
if (!configsetsDir.isDirectory())
|
||||||
throw new FileNotFoundException(configsetsDir.getAbsolutePath() + " not found!");
|
throw new FileNotFoundException(configsetsDir.getAbsolutePath() + " not found!");
|
||||||
|
|
||||||
String configSet = cli.getOptionValue("config", DEFAULT_CONFIG_SET);
|
String configSet = cli.getOptionValue("confdir", DEFAULT_CONFIG_SET);
|
||||||
File configSetDir = new File(configsetsDir, configSet);
|
File configSetDir = new File(configsetsDir, configSet);
|
||||||
if (!configSetDir.isDirectory()) {
|
if (!configSetDir.isDirectory()) {
|
||||||
// we allow them to pass a directory instead of a configset name
|
// we allow them to pass a directory instead of a configset name
|
||||||
@ -1312,7 +1329,7 @@ public class SolrCLI {
|
|||||||
if (possibleConfigDir.isDirectory()) {
|
if (possibleConfigDir.isDirectory()) {
|
||||||
configSetDir = possibleConfigDir;
|
configSetDir = possibleConfigDir;
|
||||||
} else {
|
} else {
|
||||||
throw new FileNotFoundException("Specified config " + configSet +
|
throw new FileNotFoundException("Specified config directory " + configSet +
|
||||||
" not found in " + configsetsDir.getAbsolutePath());
|
" not found in " + configsetsDir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1415,4 +1432,47 @@ public class SolrCLI {
|
|||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
} // end CreateCoreTool class
|
} // end CreateCoreTool class
|
||||||
|
|
||||||
|
public static class CreateTool implements Tool {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "create";
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("static-access")
|
||||||
|
@Override
|
||||||
|
public Option[] getOptions() {
|
||||||
|
return CREATE_COLLECTION_OPTIONS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int runTool(CommandLine cli) throws Exception {
|
||||||
|
|
||||||
|
String solrUrl = cli.getOptionValue("solrUrl", "http://localhost:8983/solr");
|
||||||
|
if (!solrUrl.endsWith("/"))
|
||||||
|
solrUrl += "/";
|
||||||
|
|
||||||
|
String systemInfoUrl = solrUrl+"admin/info/system";
|
||||||
|
CloseableHttpClient httpClient = getHttpClient();
|
||||||
|
|
||||||
|
int result = -1;
|
||||||
|
Tool tool = null;
|
||||||
|
try {
|
||||||
|
Map<String,Object> systemInfo = getJson(httpClient, systemInfoUrl, 2);
|
||||||
|
if ("solrcloud".equals(systemInfo.get("mode"))) {
|
||||||
|
tool = new CreateCollectionTool();
|
||||||
|
} else {
|
||||||
|
tool = new CreateCoreTool();
|
||||||
|
}
|
||||||
|
result = tool.runTool(cli);
|
||||||
|
} finally {
|
||||||
|
closeHttpClient(httpClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end CreateTool class
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user