结合 cbq 和 cbimport 命令的 Couchbase 脚本不起作用

Couchbase script with combination of cbq and cbimport commands is not working

我正在尝试编写一个脚本文件,它将使用 [cbq][1] 命令导出一些数据,然后通过 [cbimport][2] 命令将这些数据导入目标集群。我想以这样的方式增强脚本,使其可以导出大量数据并导入另一个集群。 但是在我的本地机器上,它失败了。实际上脚本在 cbq 命令的 SELECT 命令中变得 stuck

有人可以建议我怎么做吗?下面是我正在使用的测试脚本。

echo "Hello World"
cbq -u Administrator -p Administrator -e "http://localhost:8093";
\REDIRECT temp.txt;
SELECT * FROM `sample.data` where id="106" --output="temp.txt";
\REDIRECT OFF;
cbimport json -c http://{target-cluster}:8091 -u Administrator -p Administrator  -b sample.data -d file://C:\Users\myusername\Desktop\temp.txt -f list -g %docId%;
\EXIT;

以下是上述脚本的响应:

Hello World
 Connected to : http://localhost:8093/. Type Ctrl-D or \QUIT to exit.

 Path to history file for the shell : C:\Users\myuser\.cbq_history

而且卡在这里很长时间。

特别是对于您的这个脚本,您有一个分号在 URL 之后终止 cbq 调用,因此它只是处于交互模式。

您想试试:

echo "Hello World"

cbq -u Administrator -p Administrator -e "http://localhost:8093"  --output="temp.txt" -s "SELECT * FROM `sample.data` where id='106'"
# add processing to convert from redirected output to cbimport format
cbimport json -c http://{target-cluster}:8091 -u Administrator -p Administrator  -b sample.data -d file://C:\Users\myusername\Desktop\temp.txt -f list -g %docId%

作为脚本中的 3 个命令。 (注意语句中没有使用双引号,因为为 shell 选择的引号是双引号。您也可以反转这个选择。)