2017-06-07 7 views
8

私はpycassa,cassandra.clusterdse.clusterの両方を接続せずに試してみました。DseAuthenticatorとDseAuthorizerを使ってPythonをcassandraに接続する

私は間違ったホストに接続しているように感じます。私はLinuxサーバーのホスト名を書いていて、cassandraに関する何も指定していません。

大学生は、Linuxマシン上でcqlshのインラインでサーバーに接続することしか知りませんでした。それはちょっと意外と聞こえます。私はpycassaでやっている何をcassandra.yaml

authenticator: com.datastax.bdp.cassandra.auth.DseAuthenticator 
authorizer: com.datastax.bdp.cassandra.auth.DseAuthorizer 

具体的構成:

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

付き

エラーメッセージ:代わりに、カサンドラ1のdse.authのPlainTextAuthProviderを用いて固定

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."',)}) 
+1

はそれかどうかを確認するためにcqlshから同じホストおよび認証情報を使用してカサンドラに接続してみてください作品... 'cqlsh 12345.mycompany.net -u fancycar -p becauseimbatman' –

+0

@undefined_variable 提案をありがとう。 エラー: '[[email protected] SYST:〜]#cqlsh 12345.mycompany.net -u fancycar -p becauseimbatman' '接続エラー:( 'どのサーバーにも接続できません' ('11 .111.11 '、9042)]に接続しようとしました。最終エラー:タイムアウト ")})' 「通常どおり」にログインすると、「 '[[email protected] SYST:〜]#cqlsh -u fancycar -p becauseimbatman' ' 12345_clusterに12345.mycompany.net:9042で接続しました。 [cqlsh 5.0.1 |カサンドラ3.0.11.1485 | DSE 5.0.5 | CQL仕様3.4.0 |ネイティブプロトコルv4] ' – MadsVJ

+1

第2のコマンドは、最初にリモートサーバーに接続しているときにlocalhostに接続します.. 12345.mycompany.netはlocalhostと同じホストに解決しますか? –

答えて

2

..

from dse.cluster import Cluster 
# pip install dse-driver 
from dse.auth import PlainTextAuthProvider 
auth_provider = PlainTextAuthProvider(
     username='fancycar', password='becauseimbatman ') 
cluster = Cluster(contact_points=['12345.mycompany.net'], 
port=9042, auth_provider=auth_provider) 
session = cluster.connect('batcave') 
print "connected" 
print session.execute("SELECT * FROM robinstears")[0] 
関連する問題