4

Please help me with docker-compose file. Right now, i'm using Solr in docker file, but i need to change it to SolrCloud. I need 2 Solr instances, an internal Zookeeper and docker (local). This is an example of docker-compose file I did:

version: "3"

services:
  mongo:
    image: mongo:latest
    container_name: mongo
    hostname: mongo
    networks:
      - gsec
    ports:
      - 27018:27017    

  sqlserver:
    image: microsoft/mssql-server-linux:latest
    hostname: sqlserver
    container_name: sqlserver
    environment:
      SA_PASSWORD: "#Password123!"
      ACCEPT_EULA: "Y"
    networks:
      - gsec
    ports:
      - 1403:1433
  solr:
    image: solr
    container_name: solr    
    ports:
     - "8983:8983"
    networks:
      - gsec 
    volumes:
      - data:/opt/solr/server/solr/mycores
    entrypoint:
      - docker-entrypoint.sh
      - solr-precreate
      - mycore
volumes:
  data:

networks:
      gsec:
        driver: bridge

Thank you in advanced.

freedev
  • 25,946
  • 8
  • 108
  • 125
Ronny Lee
  • 47
  • 1
  • 1
  • 5
  • Do you have some errors? Please post them (re-edit your question). – Nicola Ben Jun 25 '18 at 10:21
  • this configuration is working, but i need Solrcloud + zookeeper. I have tried to change this code: version: '3.3' services: solr1: container_name: solr1 image: solr ports: - "8981:8983" volumes: - ./data:/opt/solr/server/solr/mycores entrypoint: - docker-entrypoint.sh - solr - start - -f - -c - -z - zoo1:2181,zoo2:2181,zoo3:2181 - -a - "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044" networks: - solr – Ronny Lee Jun 25 '18 at 13:12
  • if you need, i can send dockercompose file. – Ronny Lee Jun 25 '18 at 13:21

3 Answers3

10

Solr docker instance has a zookeeper server embedded into. You have just to start Solr with the right parameters and add the zookeeper ports 9983:9983 in the docker-compose file:

  solr:
    image: solr
    container_name: solr    
    ports:
     - "9983:9983"
     - "8983:8983"
    networks:
      - gsec 
    volumes:
      - data:/opt/solr/server/solr/mycores
    entrypoint:
      - docker-entrypoint.sh
      - solr
      - start
      - -c
      - -f

SolrCloud basically is a Solr cluster where Zookeeper is used to coordinate and configure the cluster.

Usually you use SolrCloud with Docker because you're are learning how it works or because you're preparing your application (locally?) to deploy in a bigger environment.

On the other hand it doesn't make much sense run SolrCloud if you don't have a distributed configuration, i.e. having Solr and Zookeeper running on different nodes.

SolrCloud is the kind of cluster you need when you have hundred or even thousands searches per second with collection of millions or even billions of documents.

Your cluster have to scale horizontally.

freedev
  • 25,946
  • 8
  • 108
  • 125
  • 1
    Thank you, Freedev, for your time and help. It works perfect. – Ronny Lee Jun 26 '18 at 09:58
  • Hi guys, sorry to bother you... I'm struggling with a solr Docker, could you help me? I've posted a question here: https://stackoverflow.com/questions/67062098/build-a-docker-with-flask-application-and-solr Thanks – Simo Apr 14 '21 at 16:58
3

Version to use with external zookeper.

'-t' to change data dir in container.

To see other options run: solr start -help

version: '3'

services:
  solr1:
    image: solr
    ports:
      - "8984:8984"
    entrypoint:
      - solr
    command:
      - start
      - -f
      - -c
      - -h
      - "10.1.0.157"
      - -p
      - "8984"
      - -z
      - "10.1.0.157:2181,10.1.0.157:2182,10.1.0.157:2183"
      - -m
      - 1g
      - -t
      - "/opt/solr/server/solr/mycores"
    volumes:
      - "./data1/mycores:/opt/solr/server/solr/mycores"
jeckep
  • 2,972
  • 1
  • 14
  • 10
3

I use this setup locally to test three instances of solr and three instances of zookeeper, based on the official example.

version: '3.7'
services:
  solr-1:
    image: solr:8.7
    container_name: solr-1
    ports:
      - "8981:8983"
    environment:
      - ZK_HOST=zoo-1:2181,zoo-2:2181,zoo-3:2181
    networks:
      - solr
    depends_on:
      - zoo-1
      - zoo-2
      - zoo-3
  #    command:
  #      - solr-precreate
  #      - gettingstarted

  solr-2:
    image: solr:8.7
    container_name: solr-2
    ports:
      - "8982:8983"
    environment:
      - ZK_HOST=zoo-1:2181,zoo-2:2181,zoo-3:2181
    networks:
      - solr
    depends_on:
      - zoo-1
      - zoo-2
      - zoo-3

  solr-3:
    image: solr:8.7
    container_name: solr-3
    ports:
      - "8983:8983"
    environment:
      - ZK_HOST=zoo-1:2181,zoo-2:2181,zoo-3:2181
    networks:
      - solr
    depends_on:
      - zoo-1
      - zoo-2
      - zoo-3

  zoo-1:
    image: zookeeper:3.6
    container_name: zoo-1
    restart: always
    hostname: zoo-1
    volumes:
      - zoo1data:/data
    ports:
      - 2181:2181
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=0.0.0.0:2888:3888;2181 server.2=zoo-2:2888:3888;2181 server.3=zoo-3:2888:3888;2181
    networks:
      - solr

  zoo-2:
    image: zookeeper:3.6
    container_name: zoo-2
    restart: always
    hostname: zoo-2
    volumes:
      - zoo2data:/data
    ports:
      - 2182:2181
    environment:
      ZOO_MY_ID: 2
      ZOO_SERVERS: server.1=zoo-1:2888:3888;2181 server.2=0.0.0.0:2888:3888;2181 server.3=zoo-3:2888:3888;2181
    networks:
      - solr

  zoo-3:
    image: zookeeper:3.6
    container_name: zoo-3
    restart: always
    hostname: zoo-3
    volumes:
      - zoo3data:/data
    ports:
      - 2183:2181
    environment:
      ZOO_MY_ID: 3
      ZOO_SERVERS: server.1=zoo-1:2888:3888;2181 server.2=zoo-2:2888:3888;2181 server.3=0.0.0.0:2888:3888;2181
    networks:
      - solr

networks:
  solr:

# persist the zookeeper data in volumes    
volumes:
  zoo1data:
    driver: local
  zoo2data:
    driver: local
  zoo3data:
    driver: local
mikebridge
  • 4,209
  • 2
  • 40
  • 50