2017-11-22 1 views
0

저는이 작은 대학 프로젝트를 가지고 있으며 Bokeh 프론트 엔드와 Cassandra 백엔드가있는 간단한 파이썬 응용 프로그램을 개발했습니다. 프로토 타입을 작성하고 단일 카산드라 노드로 개발 한 다음 기본 노드 하나, 가상 노드 두 개까지 세 노드까지 확장했습니다.DataStax Python Cassandra 드라이버가 로컬 호스트의 Cassandra를 잘못 찾습니다.

  • 192.168.56.1 노예 마스터
  • 192.168.56.101/102을 위해 : 따라서 개발은 내가 IP 주소를 vboxnet0라는 이름의 호스트 전용 네트워크를 사용하여 마이그레이션, 로컬 호스트에 있었다.

    :

카산드라 버전 3.11.1이
보케 서버 버전 나는 그에 따라 코드를 변경


(토네이도 4.4.3에서 실행) 0.12.10 그래서 내 응용 프로그램 코드로 시작이다

[email protected]:~> cqlsh 
Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")}) 
,536,913,632 :
from cassandra.cluster import Cluster 
from cassandra.auth import PlainTextAuthProvider 
from cassandra.query import dict_factory` 

def pandas_factory(colnames, rows): 
    return pd.DataFrame(rows, columns=colnames) 
auth_provider = PlainTextAuthProvider(username='', password='') 
cluster = Cluster(contact_points=['192.168.56.1'], port=9042, auth_provider=auth_provider) 
session = cluster.connect() 
session.row_factory = pandas_factory 
session.default_fetch_size = None 

카산드라는 로컬 호스트에서 실행 하지입니다 10

그리고 아직 파이썬 드라이버는 어떻게 든 127.0.0.1에 카산드라 호스트를 발견 생각과 연결을 시도 :

[email protected]:~/Folder/subfolder> bokeh serve Appname > ~/bokeh.output 
2017-11-22 19:24:49,230 Starting Bokeh server version 0.12.10 (running on Tornado 4.4.3) 
2017-11-22 19:24:49,233 Bokeh app running at: http://localhost:5006/Appname 
2017-11-22 19:24:49,233 Starting Bokeh server with process id: 5819 
2017-11-22 19:25:03,281 Using datacenter 'datacenter1' for DCAwareRoundRobinPolicy (via host '192.168.56.1'); if incorrect, please specify a local_dc to the constructor, or limit contact points to local cluster nodes 
2017-11-22 19:25:03,281 New Cassandra host <Host: 127.0.0.1 datacenter1> discovered 
2017-11-22 19:25:03,282 Found multiple hosts with the same rpc_address (127.0.0.1). Excluding peer 192.168.56.101 
2017-11-22 19:25:03,368 Failed to create connection pool for new host 127.0.0.1: 
Traceback (most recent call last): 
    File "cassandra/cluster.py", line 2343, in cassandra.cluster.Session.add_or_renew_pool.run_add_or_renew_pool (cassandra/cluster.c:44919) 
    File "cassandra/pool.py", line 332, in cassandra.pool.HostConnection.__init__ (cassandra/pool.c:6757) 
    File "cassandra/cluster.py", line 1119, in cassandra.cluster.Cluster.connection_factory (cassandra/cluster.c:16094) 
    File "cassandra/connection.py", line 330, in cassandra.connection.Connection.factory (cassandra/connection.c:5963) 
    File "/usr/lib64/python3.6/site-packages/cassandra/io/asyncorereactor.py", line 307, in __init__ 
    self._connect_socket() 
    File "cassandra/connection.py", line 369, in cassandra.connection.Connection._connect_socket (cassandra/connection.c:7477) 
ConnectionRefusedError: [Errno 111] Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused 
2017-11-22 19:25:03,403 Host 127.0.0.1 has been marked down 
2017-11-22 19:25:04,406 Error attempting to reconnect to 127.0.0.1, scheduling retry in 2.0 seconds: [Errno 111] Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused 
2017-11-22 19:25:06,414 Error attempting to reconnect to 127.0.0.1, scheduling retry in 4.0 seconds: [Errno 111] Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused 
2017-11-22 19:28:14,994 Error attempting to reconnect to 127.0.0.1, scheduling retry in 8.0 seconds: [Errno 111] Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused 
2017-11-22 19:28:16,489 Host 127.0.0.1 may be up; will prepare queries and open connection pool 
2017-11-22 19:28:16,808 Failed to create connection pool for new host 127.0.0.1: 



을 그리고 그것은 계속적으로 간다. 앞면에서는 정상적으로 보입니다. 앱이 작동하고 192.168.56.1이 올바르게 쿼리되지만, 이는 옳지 않은 것이 짜증나며 버그인지 내 자신의 잘못인지는 알 수 없습니다.

답변

1

우선 Cassandra는 마스터/슬레이브 관계를 사용하지 않습니다. 노드가 코디네이터 역할을 할 수 있다는 점에서 모든 노드가 동일합니다. 코디네이터는 요청에 따라 선택되며 클라이언트는 사용할 최상의 코디네이터를 선택합니다. 그러면 코디네이터는 읽고 쓰는 데이터를 담당하는 다른 노드와 조정하고 클라이언트에 응답합니다. 클라이언트에서 지정하는 접점은 접점이라고합니다. 이것은 카산드라 클러스터에 초기 연결을하기 위해서만 사용됩니다. 이 작업이 완료되면 클라이언트는 Cassandra 클러스터의 각 노드에 대한 연결을 유지합니다 (모든 노드가 요청에 대한 잠재적 조정자이기 때문에).

질문에 답변하십시오. cassandra.yaml 파일이 잘못되었습니다.

2017-11-22 19:25:03,282 Found multiple hosts with the same rpc_address (127.0.0.1). Excluding peer 192.168.56.101 

기계의 주소로 rpc_address를 설정해야합니다. 클러스터의 각 노드에서이 작업을 수행해야합니다. 다음 단계에 따라 구성을 누락하지 않았는지 확인하십시오. http://cassandra.apache.org/doc/latest/getting_started/configuring.html#main-runtime-properties

또한 모든 노드에 대해 동일한 IP/ips로 시드를 설정해야합니다. 씨앗은 노드가 시작될 때 연결할 클러스터의 하나 또는 여러 노드의 IP입니다. DC 당 2 개의 시드를 사용하는 것이 좋으며 모든 노드에서 동일해야합니다.

관련 문제