Create Solr collection with shared Zookeeper Ensemble - solr

I set up a SOLR cluster with two nodes and external Zookeper ensemble. This ZK ensemble has 3 nodes. I start my solr instances with parameter:
-z zookeeper1:2181,zookeeper2:2181,zookeeper3:2181/solr5
That means, I want the SOLR configuration to be under /solr5 instead of / as it is done by default.
The folder /solr5 is created in ZK with:
create /solr5 []
I also can upload the SOLR configuration into /solr5 without problem.
My question is when creating a collection, how do I get the generated files to be under /solr5?
The command I use to create the collection is:
bin/solr create -c collection1 -n configset -s 2 -rf 2
I looked at the documentation on this page but i don't see where to specify the zk path. The files and folder generated are:
security.json
clusterstate.json
aliases.json
live_nodes
overseer
overseer_elect
collections
How do I get these generated under /solr5 instead of /?

The solution is to specify the the zookeeper path in solr.xml:
<solrcloud>
<str name="zkHost">zookeeper1:2181,zookeeper2:2181,zookeeper3:2181/solr5</str>
</solrcloud>

Related

How do we edit config files uploaded to zookeeper ensemble

I have uploaded solr config files to zookeeper and created collection indexed few documents into collection. Now I want to update schema file. Is it possible to edit the schema config file uploaded to zookeeper. ? If yes how do we do it. some source say upload updated schema config file to zookeeper which overwrites old one.
uploading updated config file is not tedious task But want to know if there is a way to edit the existing config file in zookeeper.
Thanks in advance,
vinod
To update schema download latest configset associated with schema
Latest configset can be downloaded using following command:
solr zk -downconfig -d directory to download -n configset name -z ip:port of zookeeper
for example : solr zk -downconfig -d C:\solr\workingConfig -n configsetName -z localhost:2181
make required changes
Then Upload latest configset to zookeeper using following command.
solr zk -upconfig -d directory to upload -n configset name -z ip:port of zookeeper
For example: solr zk -upconfig -d C:\solr\workingConfig -n configsetName -z localhost:2181
Then you need to Reload schema so that changes can take effect immediately.
Schema can be reloaded using following command:
http://ip:port/solr/admin/collections?action=RELOAD&name=

Solr : Path for the config files in embedded zookeeper

I am using solr-6.0.0
Using the cloud example,
I started solr in cloud mode using the following commands
bin/solr start -cloud -p 8983 -s "example/cloud/node1/solr"
bin/solr start -cloud -p 7574 -s "example/cloud/node2/solr" -z localhost:9983
I would like to index data from my database. Had it been stand-alone mode I would have edited the managed-schema and solrconfig.xml files accordingly. But for cloud-mode I cannot find those files.
According to the docs :
Note that the SolrCloud example does not include a conf directory for
each Solr Core (so there is no solrconfig.xml or Schema file). This is
because the configuration files usually found in the conf directory
are stored in ZooKeeper so they can be propagated across the cluster.
So where can I edit those files or do I need to upload a new set of config files and override the already uploaded ones?
Found this in the docs:
See the section : Uploading configs using zkcli or SolrJ
at Uploading configs using zkcli
You can do something like this to push a file :
zkcli.sh -zkhost localhost:2181 -cmd putfile /solr.xml /path/to/solr.xml
and something like this to upload the config files:
./server/scripts/cloud-scripts/zkcli.sh -zkhost localhost:9983 -cmd upconfig -confname <conf-name> -confdir <path-of-the-local-conf-dir>

In Solr5.5, easiest command-line way to create core in localhost using existing conf

I have a git repository containing a solr/conf folder with solrconfig.xml and schema.xml. I've managed to create a local solr core and copy these files into it, but I expect there is an easier way than what I did, which was basically:
solr create -c mycorename
cp solr/conf/schema.xml /usr/local/Cellar/solr/5.5.0/server/solr/mycorename/conf
cp solr/conf/solrconfig.xml /usr/local/Cellar/solr/5.5.0/server/solr/mycorename/conf
...and restart the core to have the changes take effect.
My solution is not that complicated, but it requires a lot of specific knowledge of folders etc. and I'd like something simpler. Ideally, I would prefer that the core is created in-place in my existing folder.
If that is not possible I would like to have a simpler way that does not require knowledge of the specific solr folders on a developer's workstation. Maybe a couple of curl commands.
Your question is about best practice for creating a core from command line.
You already use
bin\solr create -c mycorename`
but at time you need a restart, because you change the config after creation.
Solr can copy your config files and creating the core in one step:
bin\solr create_core -c mycore -d c:/tmp/myconfig
If you are using SolrCloud you could work even more folder independent:
Add configuration folder to zookeeper
Create collection with this configuration
see also How to create new core in Solr 5?
To create Solr core, use solr script ran with solr user privileges, e.g.
sudo -u solr ./bin/solr create -c mycorename

Do I need to create schema.xml when creating a new core in Solr?

I am running Solr 5.3.0 and I have created a new core using the command bin/solr create -c collection1.
However, I noticed there is no schema.xml file anywhere for that core in the collection1/conf folder.
Do I need to create the schema.xml from scratch each time I create a new core?
What is the best way to do this? Copy the one from {SOLR_INSTALLATION}/server/solr/configsets\basic_configs\conf and modify the schema.xml to suit my needs?
Thanks
Solr 5.3 by default will create a managed schema without a schema.xml; you will then need to create everything you need in it via REST calls to Solr. You can read more about it here.
If you wanted to have the actual schema file you will need to create your collection like so:
bin/solr create -c collection1 -d {SOLR_INSTALLATION}/server/solr/configsets/basic_configs
You can learn more about the options to create a collection by doing:
bin/solr create_collection help
Solr 5 creates schema automatically for you and it is known as managed schema
In case you need to specify your own schema then you can use the below curl command
curl -X POST -H 'Content-type:application/json' --data-binary '{"add-field": {"name":"order_count", "type":"int", "multiValued":false, "stored":true}}'
name : the name of your column or field
type : data type of field
Similarly you can run curl commands for all the fields
You can run this command after creating your solr collection using solr create -c command

How does solr loads configsets in examples provided by solr?

I have started learning solr.I have downloaded the latest zip(5.1.0) provided by solr and run the server using bin/solr start -e cloud -noprompt.
I check that this internally calls
bin/solr start -cloud -s example/cloud/node1/solr -p 8983
bin/solr start -cloud -s example/cloud/node2/solr -p 7574 -z localhost:9983
I check that these is no config(conf/solrconfig.xml) defined in example/cloud/node1/solr so how does solr load config from the SOLR_HOME/configsets directory?
I read the documentation on several places but i am still unable to figure out the use of cloud like in 'bin/solr start -cloud -s ... ' and use of zookeeper.
Please help.
when you are working on solr cloud with zookeeper, you have to upload your solr config on zookeeper.
./bin/solr zk -upconfig -z localhost:2181,localhost:2182,localhost:2182 -n my-config -d server/solr/files/conf/
using upconfig you can upload your solr config, only have to provide path of your config directory.
You can use config name(my-config) for create core using api.
http://XXX.XXX.XXX.XXX:8983/solr/admin/collections?action=CREATE&name=irTest&numShards=3&replicationFactor=2&maxShardsPerNode=3&collection.configName=my-config
So it will create core using your config only.
Download the latest version of the Apache solr reference guide.
https://www.apache.org/dyn/closer.cgi/lucene/solr/ref-guide/apache-solr-ref-guide-5.1.pdf
check this section in the PDF.
Configuration Directories and SolrCloud
Since you are not specifying a specific configset, the default is loaded.
First, if you don't provide the -d or -n options, then the default
configuration ($SOLR_HOME/server/solr/con
figsets/data_driven_schema_configs/conf) is uploaded to ZooKeeper
using the same name as the collection

Resources