2

我正在使用容器化的 Vespa.ai DB,我想从主机执行以下命令:

  1. vespa 停止服务
  2. vespa 删除索引
  3. vespa 启动服务

vespa-stop-services && vespa-remove-index && vespa-start-services如果我在附加容器后从我的 shell执行以下操作,它工作正常。但是当我使用 docker exec 时它失败了。

我尝试了以下命令:

docker exec bash -c 'vespa-stop-services && vespa-remove-index && vespa-start-services'

docker exec bash -l 'vespa-stop-services && vespa-remove-index && vespa-start-services'

我成功执行这些命令的唯一方法是按顺序执行它们,我想避免这种情况:

docker exec bash -l 'vespa-stop-services'

docker exec bash -l 'vespa-remove-index'

docker exec bash -l 'vespa-start-services'

我究竟做错了什么?提前致谢!

4

1 回答 1

1

从父主机系统运行时,您需要指定这些命令的位置

以下工作/应该工作:

docker exec vespa bash -c "/opt/vespa/bin/vespa-stop-services && /opt/vespa/bin/vespa-remove-index -force && /opt/vespa/bin/vespa-start-services"

注意 -force,它不会在删除数据之前要求确认,还要注意索引不是唯一的持久数据,配置状态仍然保留。

名为“vespa”的 docker 容器的示例运行:

docker exec vespa bash -c "/opt/vespa/bin/vespa-stop-services && /opt/vespa/bin/vespa-remove-index -force && /opt/vespa/bin/vespa-start-services"
Executing /opt/vespa/libexec/vespa/stop-vespa-base.sh
config-sentinel was running with pid 7788, sending SIGTERM
Waiting for exit (up to 15 minutes)
.. DONE
configproxy was running with pid 7666, sending SIGTERM
Waiting for exit (up to 15 minutes)
. DONE
[info] You have 23088 kilobytes of data for cluster msmarco
[info] For cluster msmarco distribution key 0 you have:
[info] 23084 kilobytes of data in var/db/vespa/search/cluster.msmarco/n0
[info] removing data:  rm -rf var/db/vespa/search/cluster.msmarco/n0
[info] removed.

Running /opt/vespa/libexec/vespa/start-vespa-base.sh
Starting config proxy using tcp/localhost:19070 as config source(s)
runserver(configproxy) running with pid: 10553
Waiting for config proxy to start
config proxy started after 1s (runserver pid 10553)
runserver(config-sentinel) running with pid: 10679
于 2021-05-30T19:47:36.427 回答