Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-9891

Add mkroot command to bin/solr and bin/solr.cmd

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.4, 7.0
    • Component/s: None
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:
      None

      Description

      This came to my attention just now. To use a different root in Solr, we say this in the ref guide:

      IMPORTANT: If your ZooKeeper connection string uses a chroot, such as localhost:2181/solr, then you need to bootstrap the /solr znode before launching SolrCloud using the bin/solr script. To do this, you need to use the zkcli.sh script shipped with Solr, such as:
      server/scripts/cloud-scripts/zkcli.sh -zkhost localhost:2181/solr -cmd bootstrap -solrhome server/solr

      I think all this really does is create an empty /solr ZNode. We're trying to move the common usages of the zkcli scripts to bin/solr so I tried making this work.

      It's clumsy. If I try to copy up an empty directory to /solr nothing happens. I got it to work by copying file:README.txt to zk:/solr/nonsense then delete zk:/solr/nonsense. Ugly.

      I don't want to get into reproducing the whole Unix shell file manipulation commands with mkdir, touch, etc.

      I guess we already have special 'upconfig' and 'downconfig' commands, so maybe a specific command for this like 'mkroot' would be OK. Do people have opinions about this as opposed to 'mkdir'? I'm tending to mkdir.

      Or have the cp command handle empty directories, but mkroot/mkdir seems more intuitive if not as generic.

      1. SOLR-9891.patch
        9 kB
        Erick Erickson
      2. SOLR-9891.patch
        9 kB
        Erick Erickson

        Activity

        Hide
        erickerickson Erick Erickson added a comment -

        Not tested on Windows. I've copy/pasted/edited what I think are the necessary bits into bin/solr.cmd, but it needs someone to try it out before I can check it in.

        If some kind person with a windows setup could give this patch a spin on Windows I would be grateful.

        NOTE: I've used 'mkroot' as the command. I'm not particularly wedded to that name. What opinions do people have? Two possibilities that spring to mind are 'mkpath' and 'mkdir'...

        I slightly prefer 'mkroot' even though it's really a generic 'mkpath' command. The intent is to create something for chroot, but it's really more general than that. Not sure that generality needs to be advertised though...

        Show
        erickerickson Erick Erickson added a comment - Not tested on Windows. I've copy/pasted/edited what I think are the necessary bits into bin/solr.cmd, but it needs someone to try it out before I can check it in. If some kind person with a windows setup could give this patch a spin on Windows I would be grateful. NOTE: I've used 'mkroot' as the command. I'm not particularly wedded to that name. What opinions do people have? Two possibilities that spring to mind are 'mkpath' and 'mkdir'... I slightly prefer 'mkroot' even though it's really a generic 'mkpath' command. The intent is to create something for chroot, but it's really more general than that. Not sure that generality needs to be advertised though...
        Hide
        erickerickson Erick Erickson added a comment -

        I implemented this with 'mkroot'. Works on my machine, but still needs someone to take a few minutes and try it on Windows before I can commit it.

        Show
        erickerickson Erick Erickson added a comment - I implemented this with 'mkroot'. Works on my machine, but still needs someone to take a few minutes and try it on Windows before I can commit it.
        Hide
        steve_rowe Steve Rowe added a comment -

        Works for me on Windows 10:

        First, check ZK contents:

        ...\git\lucene-solr\solr>bin\solr zk ls -r / -z localhost:2181
        
        Connecting to ZooKeeper at localhost:2181 ...
        Getting listing for Zookeeper node / from ZooKeeper at localhost:2181 recurse: true
        /
        

        Then, zk mkroot solr:

        ...\git\lucene-solr\solr>bin\solr zk mkroot solr -z localhost:2181
        
        Connecting to ZooKeeper at localhost:2181 ...
        Creating Zookeeper path solr on ZooKeeper at localhost:2181
        

        And then check contents again:

        ...\git\lucene-solr\solr>bin\solr zk ls -r / -z localhost:2181
        
        Connecting to ZooKeeper at localhost:2181 ...
        Getting listing for Zookeeper node / from ZooKeeper at localhost:2181 recurse: true
        /
        /solr
        

        I also tried zk mkroot solr2/subfolder, zk mkroot /solr3 (note the leading slash), and these worked too.

        Show
        steve_rowe Steve Rowe added a comment - Works for me on Windows 10: First, check ZK contents: ...\git\lucene-solr\solr>bin\solr zk ls -r / -z localhost:2181 Connecting to ZooKeeper at localhost:2181 ... Getting listing for Zookeeper node / from ZooKeeper at localhost:2181 recurse: true / Then, zk mkroot solr : ...\git\lucene-solr\solr>bin\solr zk mkroot solr -z localhost:2181 Connecting to ZooKeeper at localhost:2181 ... Creating Zookeeper path solr on ZooKeeper at localhost:2181 And then check contents again: ...\git\lucene-solr\solr>bin\solr zk ls -r / -z localhost:2181 Connecting to ZooKeeper at localhost:2181 ... Getting listing for Zookeeper node / from ZooKeeper at localhost:2181 recurse: true / /solr I also tried zk mkroot solr2/subfolder , zk mkroot /solr3 (note the leading slash), and these worked too.
        Hide
        erickerickson Erick Erickson added a comment -

        Final patch with CHANGES.txt

        Show
        erickerickson Erick Erickson added a comment - Final patch with CHANGES.txt
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit cb266d5fc775bd9d26ed7f0e68e9d0d12793f9b5 in lucene-solr's branch refs/heads/master from Erick Erickson
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=cb266d5 ]

        SOLR-9891: Add mkroot command to bin/solr and bin/solr.cmd

        Show
        jira-bot ASF subversion and git services added a comment - Commit cb266d5fc775bd9d26ed7f0e68e9d0d12793f9b5 in lucene-solr's branch refs/heads/master from Erick Erickson [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=cb266d5 ] SOLR-9891 : Add mkroot command to bin/solr and bin/solr.cmd
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit ed55658620e66b7a06a820219daf6435dfb070d6 in lucene-solr's branch refs/heads/branch_6x from Erick Erickson
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=ed55658 ]

        SOLR-9891: Add mkroot command to bin/solr and bin/solr.cmd
        (cherry picked from commit cb266d5)

        Show
        jira-bot ASF subversion and git services added a comment - Commit ed55658620e66b7a06a820219daf6435dfb070d6 in lucene-solr's branch refs/heads/branch_6x from Erick Erickson [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=ed55658 ] SOLR-9891 : Add mkroot command to bin/solr and bin/solr.cmd (cherry picked from commit cb266d5)
        Hide
        erickerickson Erick Erickson added a comment -

        Thanks Steve!

        Show
        erickerickson Erick Erickson added a comment - Thanks Steve!
        Hide
        erickerickson Erick Erickson added a comment -

        Also changed many of the references to zkcli in the ref guide to use bin/solr.

        Show
        erickerickson Erick Erickson added a comment - Also changed many of the references to zkcli in the ref guide to use bin/solr.
        Hide
        kiranch kiran added a comment -

        It would be useful if this command worked when the connect string has the chroot path like

        bin/solr zk mkroot -z {}/chroot

        That would achieve similar functionality with how bootstrap command worked

        Show
        kiranch kiran added a comment - It would be useful if this command worked when the connect string has the chroot path like bin/solr zk mkroot -z {}/chroot That would achieve similar functionality with how bootstrap command worked
        Hide
        erickerickson Erick Erickson added a comment -

        Please open new JIRAs rather than comment on closed ones, that makes the bookkeeping easier .

        Show
        erickerickson Erick Erickson added a comment - Please open new JIRAs rather than comment on closed ones, that makes the bookkeeping easier .

          People

          • Assignee:
            erickerickson Erick Erickson
            Reporter:
            erickerickson Erick Erickson
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development