我已经尝试过使用
错误信息:
错误信息:
pycassa
、cassandra.cluster
和 dse.cluster
,但都无法建立连接。
我感觉我正在连接到错误的主机,因为我只写了Linux服务器的主机名,没有指定任何关于Cassandra的信息。
同事告诉我他们只知道在Linux机器上通过 cqlsh
进行内联连接。这听起来很不方便。
cassandra.yaml
中有具体的配置。
authenticator: com.datastax.bdp.cassandra.auth.DseAuthenticator
authorizer: com.datastax.bdp.cassandra.auth.DseAuthorizer
我在Pycassa中所做的事情:
import pycassa
URIPORTLIST = ['12345.mycompany.net:9420']
pool = pycassa.ConnectionPool('my_keyspace', server_list=URIPORTLIST,credentials={'USERNAME':'fancycar','PASSWORD':'becauseimbatman'}, prefill=False)
cf = pycassa.ColumnFamily(pool, 'my_table')
错误信息:
AllServersUnavailable: An attempt was made to connect to each of the servers twice, but none of the attempts succeeded. The last failure was TTransportException: Could not connect to 12345.mycompany.net:9420
使用dse.cluster
from dse.cluster import Cluster
auth_provider = PlainTextAuthProvider(
username='fancycar', password='becauseimbatman')
cluster = Cluster(
['12345.mycompany.net'],
port=9042,auth_provider=auth_provider)
session = cluster.connect('my_keyspace')
错误信息:
NoHostAvailable: ('Unable to connect to any servers', {'11.111.11.1': AuthenticationFailed('Failed to authenticate to 11.111.11.2: Error from server: code=0100 [Bad credentials] message="Failed to login. Please re-try."',)})
cqlsh 12345.mycompany.net -u fancycar -p becauseimbatman
- undefined_variable[root@12345.mycompany.net SYST:~]# cqlsh 12345.mycompany.net -u fancycar -p becauseimbatman
连接错误:('无法连接到任何服务器',{'11.111.11.11': error(None, "Tried connecting to [('11.111.11.11', 9042)]. Last error: timed out")}
而以“通常”的方式登录是可以的:[root@12345.mycompany.net SYST:~]# cqlsh -u fancycar -p becauseimbatman
已连接到12345_cluster,位于12345.mycompany.net:9042。 [cqlsh 5.0.1 | Cassandra 3.0.11.1485 | DSE 5.0.5 | CQL spec 3.4.0 | Native protocol v4]
- MadsVJtelnet cassandra-host 9042
)... 2)在cassandra.yaml中,rpc_address
不应该是localhost。 - undefined_variable