• Home
  • LLMs
  • Docker
  • Kubernetes
  • Java
  • Maven
  • About
Apache Solr | Install and configure a Solr Cloud (Cluster)
  1. Prerequisites: ZooKeeper Server and ZooKeeper "chroot"
  2. Install and configure a Solr Cluster on 2 different hosts
    1. Download and Install Apache Solr
    2. Configuration files and environment variables
    3. Start Solr
    4. Stop Solr
  3. Install and configure a Solr Cluster on the same host
  4. Install and configure a Solr Cluster on the same host, using the same Solr binary distribution

  1. Prerequisites: ZooKeeper Server and ZooKeeper "chroot"
    To form a Solr Cluster you will need to install and configure ZooKeeper: see Install and configure a ZooKeeper

    By default, Solr configuration will be pushed to ZooKeeper and will be created under the ZooKeeper root znode "/".
    To be able to create the Solr configuration under a custom location (ie: "/solr"), you need to use ZooKeeper "chroot".
    The usage of ZooKeeper "chroot" is not mandatory but it's considered as a best practice.

    If you choose to have Solr configuration created under a custom location, then you have to create manually the "chroot" znode in ZooKeeper.
    You can use ZooKeeper Command Line Utilities file "zkCli.sh" to create your "chroot" znode (ie: "/solr"):
    $ ${ZK_HOME}/bin/zkCli.sh -server localhost:2181 create /solr

  2. Install and configure a Solr Cluster on 2 different host
    We will install Solr on 2 different hosts: "solrhost1", and "solrhost2"

    Assuming we have already installed and configured ZooKeeper. One ZooKeeper instance should be sufficient but we will assume that we have a ZooKeeper Cluster formed of 3 nodes installed on 3 different hosts: "zkhost1", "zkhost2", and "zkhost3"

    On each Solr host, do the following:

    1. Download and Install Apache Solr
      • Download Apache Solr http://lucene.apache.org/solr/

      • Extract the file "solr-9.8.1.zip" in the folder you want to install Solr: /opt/solr-9.8.1
        $ unzip solr-9.8.1.zip -d /opt/

      • Create a symbolic link of the Solr installation folder:
        $ ln -s /opt/solr-9.8.1/ /opt/solr

      • Change the folders permissions (if needed):
        $ chmod -R 755 /opt/solr-9.8.1/
        $ sudo chown -R mtitek:mtitek /opt/solr-9.8.1/
        $ sudo chown -R mtitek:mtitek /opt/solr

        You should replace mtitek:mtitek with your actual user/group names.
    2. Configuration files and environment variables
      ${SOLR_HOME} (or solr.solr.home) represents the path of the Solr home directory: /opt/solr/server/solr

      ${SOLR_ROOT} represents the path of the Solr installation folder: /opt/solr/

      Configuration files:
      ► "${SOLR_HOME}/solr.xml"

      Solr home directory ${SOLR_HOME} must contain a solr.xml file, otherwise Solr will fail to start.
    3. Start Solr
      Start Solr on each Solr host ("solrhost1", "solrhost2")
      $ /opt/solr/bin/solr start -c -z "zkhost1:2181,zkhost2:2181,zkhost3:2181/solr"

      You can omit -z "zkhost1:2181,zkhost2:2181,zkhost3:2181/solr" from the above command if you have defined "ZK_HOST" in "solr.in.sh".

      Typically, you can use one of the following options to start Solr:

      • Specifying a ZooKeeper instance (not recommended to not setting a ZooKeeper chroot ):
        $ /opt/solr/bin/solr start -c -z "zkhost1:2181"

      • Specifying a ZooKeeper instance + setting ZooKeeper chroot to "/solr" (the znode "/solr" has to be created first in ZooKeeper):
        $ /opt/solr/bin/solr start -c -z "zkhost1:2181/solr"

      • Specifying multiple ZooKeeper instances:
        $ /opt/solr/bin/solr start -c -z "zkhost1:2181,zkhost2:2181,zkhost3:2181/solr"

      • Adding additional JVM parameters (start Solr running in SolrCloud mode with 1g max heap size and remote Java debug options enabled):
        $ /opt/solr/bin/solr start -c -m 1g -z "zkhost1:2181,zkhost2:2181,zkhost3:2181/solr" -a "-Xmx1024m -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044"

      Access the Solr Admin UI: http://solrhost1:8983/solr

      Apache Solr/SolrCloud

      Notes:

      • If you are using ZooKeeper "chroot", make sure that the Solr znode is created first in ZooKeeper ("/solr").

        Otherwise you will get this error at startup:
        ERROR (main) [   ] o.a.s.c.SolrCore null:org.apache.solr.common.cloud.ZooKeeperException:
        A chroot was specified in ZkHost but the znode doesn't exist. localhost:2181/solr
          at org.apache.solr.core.ZkContainer.initZooKeeper(ZkContainer.java:112)
          at org.apache.solr.core.CoreContainer.load(CoreContainer.java:623)
          at org.apache.solr.servlet.SolrDispatchFilter.createCoreContainer(SolrDispatchFilter.java:261)
          at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:181)
          at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:136)
          at org.eclipse.jetty.servlet.ServletHandler.lambda$initialize$0(ServletHandler.java:750)

      • At startup, Solr will try to upload the "_default" configuration to ZooKeeper ("${SOLR_HOME}/configsets/_default").

      • Verify that the ZooKeeper instances are up and running, otherwise Solr won't start correctly.

      • If all ZooKeeper instances, specified in the "-z" parameter, go down, Solr will lose connection with ZooKeeper even if the ZooKeeper ensemble contains other instances that are up and running.

      • You can specify memory options: -m 512m (default)

      • On windows, you need to put the ZooKeeper hosts between double quotes: -z "zkhost1:2181,zkhost2:2181,zkhost3:2181/solr"

    4. Stop Solr
      To stop Solr, you need to run the following command on each Solr host ("solrhost1", "solrhost2")
      $ /opt/solr/bin/solr stop

      You can also stop Solr server for which the HTTP listener is bound to the specified port:
      $ /opt/solr/bin/solr stop -p 8983
  3. Install and configure a Solr Cluster on the same host
    To form a Solr Cluster you will need to install and configure ZooKeeper: see Install and configure a ZooKeeper Cluster on the same host
    We will assume that we have a ZooKeeper Cluster formed of 3 nodes installed on the same host where Solr will be installed.

    You have to create manually the znode "/solr" in ZooKeeper.

    Extract the content of "solr-9.8.1.zip" file to 2 locations of your choice:
    ► /opt/solr-i1
    ► /opt/solr-i2

    Running the first Solr instance (port: 8983)
    $ /opt/solr-i1/bin/solr start -c -z "localhost:2181,localhost:2182,localhost:2183/solr" -p 8983

    Running the second Solr instance (port: 8984)
    $ /opt/solr-i2/bin/solr start -c -z "localhost:2181,localhost:2182,localhost:2183/solr" -p 8984

    Access the Solr Admin UI: http://localhost:8983/solr

    Apache Solr/solrcloud: 2 instances on same host

    To stop Solr:
    $ /opt/solr-i1/bin/solr stop -p 8983

    $ /opt/solr-i2/bin/solr stop -p 8984
  4. Install and configure a Solr Cluster on the same host, using the same Solr binary distribution
    To form a Solr Cluster you will need to install and configure ZooKeeper: see Install and configure a ZooKeeper Cluster on the same host
    We will assume that we have a ZooKeeper Cluster formed of 3 nodes installed on the same host where Solr will be installed.

    You have to create manually the znode "/solr" in ZooKeeper.

    Extract the content of "solr-9.8.1.zip" file to a location of your choice:
    ► /opt/solr

    Here are the steps to follow:
    • You need to create a folder that will hold the configuration for each Solr instance (you can choose any path you want): solr1, solr2, ...
      $ mkdir /opt/solr/solr1
      $ mkdir /opt/solr/solr2

    • On each Solr instance home folder (solr1, solr2, ...), you need to copy the "solr.xml" file from "/opt/solr/server/solr".
      $ cp /opt/solr/server/solr/solr.xml /opt/solr/solr1
      $ cp /opt/solr/server/solr/solr.xml /opt/solr/solr2

    • On each Solr instance home folder (solr1, solr2, ...), you need to create a "logs" directory.
      $ mkdir /opt/solr/solr1/logs
      $ mkdir /opt/solr/solr2/logs

    • (Linux) Modify the file /opt/solr/bin/solr:
      if [ -z "$SOLR_LOGS_DIR" ]; then
        #SOLR_LOGS_DIR="$SOLR_SERVER_DIR/logs"
        SOLR_LOGS_DIR="${SOLR_HOME}/logs"
      fi

    • (Windows) Modify the file solr.cmd:
      IF [%SOLR_LOGS_DIR%] == [] (
        @REM set "SOLR_LOGS_DIR=%SOLR_SERVER_DIR%\logs"
        set "SOLR_LOGS_DIR=%SOLR_HOME%\logs"
      )

    Running the first Solr instance (port: 8983)
    $ /opt/solr/bin/solr start -c -z "localhost:2181,localhost:2182,localhost:2183/solr" -p 8983 -s "/opt/solr/solr1"

    Running the second Solr instance (port: 8984)
    $ /opt/solr/bin/solr start -c -z "localhost:2181,localhost:2182,localhost:2183/solr" -p 8984 -s "/opt/solr/solr2"

    To stop Solr:
    $ /opt/solr/bin/solr stop -p 8983

    $ /opt/solr/bin/solr stop -p 8984

    You can also try this command to stop all running Solr servers on a host:
    $ /opt/solr-i1/bin/solr stop -all
© 2025  mtitek