CQLSH 客户端 - 模块'对象没有属性'parse_options
CQLSH client - module' object has no attribute 'parse_options
我正在尝试通过 CQLSH 客户端访问我的 Cassandra 服务器以导入一个巨大的 CSV 文件。我遇到 module' object has no attribute 'parse_options
错误。
我运行执行以下命令:
cqlsh XXX.XXX.XX.XX XXXX --cqlversion="3.4.2" --execute="copy evolvdso.teste from '2016-10-26 15:25:10.csv' WITH DELIMITER =',' AND HEADER=TRUE --debug";
这是后面的调试和错误信息:
Starting copy of evolvdso.teste with columns ['ref_equip', 'date', 'load', 'ptd_assoc'].
Traceback (most recent call last):
File "/usr/local/bin/cqlsh", line 1133, in onecmd
self.handle_statement(st, statementtext)
File "/usr/local/bin/cqlsh", line 1170, in handle_statement
return custom_handler(parsed)
File "/usr/local/bin/cqlsh", line 1834, in do_copy
rows = self.perform_csv_import(ks, cf, columns, fname, opts)
File "/usr/local/bin/cqlsh", line 1846, in perform_csv_import
csv_options, dialect_options, unrecognized_options = copyutil.parse_options(self, opts)
AttributeError: 'module' object has no attribute 'parse_options'
当我使用 pip install cqlsh
中的 cqlsh
时出现同样的问题。
尝试使用 cassandra 的工具 cqlsh
sudo docker run -it cassandra /usr/bin/cqlsh
参考jira
我遇到了类似的问题,我的场景的原因是默认的cqlsh路径是/usr/local/bin/cqlsh
。 (用命令$ which cqlsh
检查)
解决方案:使用Cassandra 自带/usr/bin/cqlsh
连接Cassandra 服务器或运行 一些命令。例如,使用命令连接到 Cassandra 服务器:
$ /usr/bin/cqlsh <cassandra_listen_ip>
或 运行 命令与
$ /usr/bin/cqlsh <cassandra_listen_ip> -e "<command>"
看起来 pip 版本有一些问题,你应该通过官方包安装而不是像:
apt install wget apt-transport-https
wget -q -O - https://www.apache.org/dist/cassandra/KEYS | apt-key add -
sh -c 'echo "deb http://www.apache.org/dist/cassandra/debian 311x main" > /etc/apt/sources.list.d/cassandra.list'
apt update
apt install -y cassandra
请注意,这还将包括 cassandra 服务,因此如果您不希望这些服务成为 运行,您可能必须手动禁用它们。
2020年回答:
要使用 cassandra 的 cqlsh,请使用 docker run -it cassandra /opt/cassandra/bin/cqlsh
如果您使用的是 bitnami 的 cassandra 镜像,cqlsh 位于 /opt/bitnami/cassandra/bin/cqlsh
然后COPY keyspace.table TO '/tmp/my_table.csv';
我正在尝试通过 CQLSH 客户端访问我的 Cassandra 服务器以导入一个巨大的 CSV 文件。我遇到 module' object has no attribute 'parse_options
错误。
我运行执行以下命令:
cqlsh XXX.XXX.XX.XX XXXX --cqlversion="3.4.2" --execute="copy evolvdso.teste from '2016-10-26 15:25:10.csv' WITH DELIMITER =',' AND HEADER=TRUE --debug";
这是后面的调试和错误信息:
Starting copy of evolvdso.teste with columns ['ref_equip', 'date', 'load', 'ptd_assoc'].
Traceback (most recent call last):
File "/usr/local/bin/cqlsh", line 1133, in onecmd
self.handle_statement(st, statementtext)
File "/usr/local/bin/cqlsh", line 1170, in handle_statement
return custom_handler(parsed)
File "/usr/local/bin/cqlsh", line 1834, in do_copy
rows = self.perform_csv_import(ks, cf, columns, fname, opts)
File "/usr/local/bin/cqlsh", line 1846, in perform_csv_import
csv_options, dialect_options, unrecognized_options = copyutil.parse_options(self, opts)
AttributeError: 'module' object has no attribute 'parse_options'
当我使用 pip install cqlsh
中的 cqlsh
时出现同样的问题。
尝试使用 cassandra 的工具 cqlsh
sudo docker run -it cassandra /usr/bin/cqlsh
参考jira
我遇到了类似的问题,我的场景的原因是默认的cqlsh路径是/usr/local/bin/cqlsh
。 (用命令$ which cqlsh
检查)
解决方案:使用Cassandra 自带/usr/bin/cqlsh
连接Cassandra 服务器或运行 一些命令。例如,使用命令连接到 Cassandra 服务器:
$ /usr/bin/cqlsh <cassandra_listen_ip>
或 运行 命令与
$ /usr/bin/cqlsh <cassandra_listen_ip> -e "<command>"
看起来 pip 版本有一些问题,你应该通过官方包安装而不是像:
apt install wget apt-transport-https
wget -q -O - https://www.apache.org/dist/cassandra/KEYS | apt-key add -
sh -c 'echo "deb http://www.apache.org/dist/cassandra/debian 311x main" > /etc/apt/sources.list.d/cassandra.list'
apt update
apt install -y cassandra
请注意,这还将包括 cassandra 服务,因此如果您不希望这些服务成为 运行,您可能必须手动禁用它们。
2020年回答:
要使用 cassandra 的 cqlsh,请使用 docker run -it cassandra /opt/cassandra/bin/cqlsh
如果您使用的是 bitnami 的 cassandra 镜像,cqlsh 位于 /opt/bitnami/cassandra/bin/cqlsh
然后COPY keyspace.table TO '/tmp/my_table.csv';