我已经设置了一个包含3个节点的cassandra集群。
我正在尝试使用copy命令执行一个简单的导出/导入操作,但失败了,错误如下:
cqlsh:walmart> select * from test;
store | date | isholiday | dept
-------+------------+-----------+------
1 | 22/04/1993 | False | 1
cqlsh> use walmart;
cqlsh:walmart> copy test to 'test.csv';
'NoneType' object has no attribute 'datacenter'我研究了这个错误,每个相关链接似乎都指出了python的问题。
我还安装了python驱动pip cassandra-driver。手动插入数据有效,但不能通过导出/导入。
cassandra@cassandra-srv01:~$ python -c 'import cassandra; print cassandra.__version__'
3.6.0Ubuntu 16.04 64位。
如何修复此错误?
$CASSANDRA_HOME/logs中的日志没有任何关于该错误的条目。
回溯:
Traceback (most recent call last):
File "/usr/local/Cellar/cassandra/3.7/libexec/bin/cqlsh.py", line 1152, in onecmd
self.handle_statement(st, statementtext)
File "/usr/local/Cellar/cassandra/3.7/libexec/bin/cqlsh.py", line 1189, in handle_statement
return custom_handler(parsed)
File "/usr/local/Cellar/cassandra/3.7/libexec/bin/cqlsh.py", line 1907, in do_copy
task = ImportTask(self, ks, table, columns, fname, opts, DEFAULT_PROTOCOL_VERSION, CONFIG_FILE)
File "/usr/local/Cellar/cassandra/3.7/libexec/bin/../pylib/cqlshlib/copyutil.py", line 1061, in __init__
CopyTask.__init__(self, shell, ks, table, columns, fname, opts, protocol_version, config_file, 'from')
File "/usr/local/Cellar/cassandra/3.7/libexec/bin/../pylib/cqlshlib/copyutil.py", line 207, in __init__
self.local_dc = shell.conn.metadata.get_host(shell.hostname).datacenter
AttributeError: 'NoneType' object has no attribute 'datacenter发布于 2016-09-08 08:58:51
这不是很好,但我会努力为这个问题做出贡献。我是cassandra的新手,在尝试通过复制功能将数据导入到cassandra表中时遇到了完全相同的问题。我通过安装在虚拟机上的cqlsh连接到安装了cassandra的服务器。因此,我必须在运行cqlsh命令时指定服务器的ip地址和端口:# cqlsh ip_address port我像这样连接到服务器名称:# cqlsh cqlsh myserver.example.com 9040,我已连接,但复制功能不起作用。
但与服务器的数字ip地址连接(例如:
cqlsh 127.0.0.1 9040)。
这纯属偶然,我只是简单地测试了一下,它对我来说是有效的。
如果这里有人能解释这个事实,那就太好了!
发布于 2016-09-07 05:30:06
问题出在您正在使用的cqlsh版本,因为版本copyutil没有使用正确的主机进行连接。在新的版本中它已经被fixed了。只需克隆repo并运行bin/cqlsh,然后尝试相同的命令。
https://stackoverflow.com/questions/39308666
复制相似问题