Zookeeper 如何使用docker-compose运行SolrCloud

yebdmbv4  于 2022-12-09  发布在  Apache
关注(0)|答案(3)|浏览(203)

请帮助我与docker-compose文件。现在,我正在使用Solr在docker文件,但我需要改变它到SolrCloud。我需要2 Solr示例,一个内部Zookeeper和docker(本地)。这是一个docker-compose文件的例子,我做了:

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

先谢谢你了。

ymdaylpp

ymdaylpp1#

Solr docker示例中嵌入了一个zookeeper服务器。您只需使用正确的参数启动Solr,并在docker-compose文件中添加zookeeper端口9983:9983

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基本上是一个Solr集群,其中Zookeeper用于协调和配置集群。
通常,您使用SolrCloud和Docker是因为您正在学习它的工作原理,或者因为您正在准备您的应用程序(本地?)以在更大的环境中部署。
另一方面,如果您没有分布式配置,即Solr和Zookeeper运行在不同的节点上,则运行SolrCloud没有多大意义。
SolrCloud是一种集群,当您每秒进行数百甚至数千次搜索,收集数百万甚至数十亿个文档时,您需要这种集群。
您的集群必须水平扩展。

gijlo24d

gijlo24d2#

与外部zookeper一起使用的版本。
'-t'更改容器中的数据目录。
要查看其他选项运行:solr启动-帮助

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"
ubbxdtey

ubbxdtey3#

我在本地使用此设置来测试基于official example的solr的三个示例和zookeeper的三个示例。

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

相关问题