我正在尝试在docker中设置太阳能云。 我正在使用docker-compose
来启动云。 我创建了一个云,包含 3 个动物园管理员和 4 个 solrs(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
对于分片2,我有 我在容器中有一个包含两个内核的目录,例如对于 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
我找到了解决方案。需要在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'