1

我正在尝试在 docker 中设置太阳能云。我正在使用docker-compose将云启动。我创建了一个云,其中包含 3 个动物园管理员和 4 个 solr(solr1、solr2、solr3、solr4)容器。创建 4 个分片和 2 个副本的分布式集合很酷。问题是当它在已安装的卷中创建集合以在 docker 外部的机器上进行备份时。我可以为每个容器将目录卷从机器挂载到 solr 云,但我无法在那里创建集合。当我创建分布式集合时

docker exec -it solr1 /opt/solr/bin/solr create_collection -c publications -s 4 -rf 2 -p 8983

我在容器中有两个核心的目录,例如对于 solr1 有

/opt/solr/server/solr/publications_shard2_replica_n6

/opt/solr/server/solr/publications_shard4_replica_n14

对于 shard2,我有一个容器中有两个核心的目录,例如对于 solr1 有

/opt/solr/server/solr/publications_shard1_replica_n1

/opt/solr/server/solr/publications_shard3_replica_n8

等等。核心的名称是动态的。

如何在我的卷目录中创建它们

/root/solr/cores

docker-compose.yml的如下

version: "3.1"
services:
  solr1:
    image: solr:latest
    environment:
      - JVM_OPTS=-Xmx12g -Xms12g -XX:MaxPermSize=1024m
    ports:
      - "8983:8983"
    restart: always
    container_name: solr1
    volumes:
     - /root/solr/mycores:/opt/solr/server/solr/mycores
    deploy:
      mode: replicated
      replicas: 2
      resources:
    limits:
      memory: 1g
      restart_policy:
    condition: on-failure
    links:
      - zookeeper1
      - zookeeper2
      - zookeeper3
    command: bash -c '/opt/solr/bin/solr start -f -z zookeeper1:2181,zookeeper2:2182,zookeeper2:2183 -m 1g'
  solr2:
    image: solr:latest
    ports:
      - "8984:8984"
    restart: always
    container_name: solr2
    volumes:
     - /root/solr/cores:/opt/solr/server/solr/mycores
    deploy:
      replicas: 2
      resources:
    limits:
      memory: 1g
      restart_policy:
    condition: on-failure
    links:
      - zookeeper1
      - zookeeper2
      - zookeeper3
      - solr1
    command: bash -c '/opt/solr/bin/solr start -f -z zookeeper1:2181,zookeeper2:2182,zookeeper3:2183 -m 1g'
  solr3:
    image: solr:latest
    ports:
      - "8985:8985"
    restart: always
    container_name: solr3
    volumes:
     - /root/solr/cores:/opt/solr/server/solr/mycores
    deploy:
      replicas: 2
      resources:
    limits:
      memory: 1g
      restart_policy:
    condition: on-failure
    links:
      - zookeeper1
      - zookeeper2
      - zookeeper3
      - solr1
      - solr2
    command: bash -c '/opt/solr/bin/solr start -f -z zookeeper1:2181,zookeeper2:2182,zookeeper3:2183 -m 1g'
  solr4:
    image: solr:latest
    ports:
      - "8986:8986"
    restart: always
    container_name: solr4
    volumes:
     - /root/solr/cores:/opt/solr/server/solr/mycores
    deploy:
      replicas: 2
      resources:
    limits:
      memory: 1g
      restart_policy:
    condition: on-failure
    links:
      - zookeeper1
      - zookeeper2
      - zookeeper3
      - solr1
      - solr2
      - solr3
    command: bash -c '/opt/solr/bin/solr start -f -z zookeeper1:2181,zookeeper2:2182,zookeeper3:2183 -m 1g'
  zookeeper1:
    image: jplock/zookeeper:latest
    container_name: zookeeper1
    ports:
      - "2181:2181"
      - "2888:2888"
      - "3888:3888"
    restart: always
  zookeeper2:
    image: jplock/zookeeper:latest
    container_name: zookeeper2
    ports:
      - "2182:2182"
      - "2889:2889"
      - "3889:3889"
    restart: always
  zookeeper3:
    image: jplock/zookeeper:latest
    container_name: zookeeper3
    ports:
      - "2183:2183"
      - "2890:2890"
      - "3890:3890"
    restart: always
4

1 回答 1

2

我找到了解决方案。需要在 docker-compose.yml 文件中添加-t参数并提供数据目录/opt/solr/server/solr/mycores。下面的编辑行

command: bash -c '/opt/solr/bin/solr start -f -z zookeeper1:2181,zookeeper2:2182,zookeeper2:2183 -m 1g -t /opt/solr/server/solr/mycores'
于 2018-05-21T08:09:47.433 回答