2013-08-19 4 views
2

단일 노드를 포함하고 각 데이터 센터가 네트워크의 개별 물리적 서버에있는 각 데이터 센터에 단일 복제가있는 cassandra 2 데이터 센터 쌍이 있습니다. 하나의 데이터 센터가 망가질 경우, 다른 하나는 읽기 및 쓰기를 위해 계속 사용할 수 있습니다. 제 3의 서버에서 Java 응용 프로그램을 시작했고, 실행중인 모든 것은 ok입니다. 카산드라에게 읽고 쓰고 있어요.카산드라 복제본 예외 HUnavailableException

다음으로 네트워크에서 두 번째 데이터 센터 서버 인 네트워크 케이블을 연결 해제했습니다. 첫 번째 데이터 센터에 대한 예외없이 응용 프로그램이 계속 실행되기를 기대했지만 그렇지 않았습니다.

다음 예외

응용 프로그램에서 발생하기 시작 :

me.prettyprint.hector.api.exceptions.HUnavailableException: : May not be enough replicas present to handle consistency level. 
     at me.prettyprint.cassandra.service.ExceptionsTranslatorImpl.translate(ExceptionsTranslatorImpl.java:60) 
     at me.prettyprint.cassandra.service.KeyspaceServiceImpl$9.execute(KeyspaceServiceImpl.java:354) 
     at me.prettyprint.cassandra.service.KeyspaceServiceImpl$9.execute(KeyspaceServiceImpl.java:343) 
     at me.prettyprint.cassandra.service.Operation.executeAndSetResult(Operation.java:101) 
     at me.prettyprint.cassandra.connection.HConnectionManager.operateWithFailover(HConnectionManager.java:232) 
     at me.prettyprint.cassandra.service.KeyspaceServiceImpl.operateWithFailover(KeyspaceServiceImpl.java:131) 
     at me.prettyprint.cassandra.service.KeyspaceServiceImpl.getSuperColumn(KeyspaceServiceImpl.java:360) 
     at me.prettyprint.cassandra.model.thrift.ThriftSuperColumnQuery$1.doInKeyspace(ThriftSuperColumnQuery.java:51) 
     at me.prettyprint.cassandra.model.thrift.ThriftSuperColumnQuery$1.doInKeyspace(ThriftSuperColumnQuery.java:45) 
     at me.prettyprint.cassandra.model.KeyspaceOperationCallback.doInKeyspaceAndMeasure(KeyspaceOperationCallback.java:20) 
     at me.prettyprint.cassandra.model.ExecutingKeyspace.doExecute(ExecutingKeyspace.java:85) 
     at me.prettyprint.cassandra.model.thrift.ThriftSuperColumnQuery.execute(ThriftSuperColumnQuery.java:44) 

내가 2 서버에 네트워크 케이블을 다시 연결되면, 오류가 중지되었습니다.

여기 여기)

1 카산드라 1.0.10에 대한 자세한 내용은을의의는 I 각 인스턴스에 대해 노드 도구 반지를 실행

Keyspace: AdvancedAds: 
Replication Strategy: org.apache.cassandra.locator.NetworkTopologyStrategy 
Durable Writes: true 
Options: [DC2:1, DC1:1] 

2) 두 데이터 센터에 카산드라에서 설명하는 다음

./nodetool -h 111.111.111.111 -p 11000 ring 
Address DC Rack Status State Load Owns Token 
1 
111.111.111.111 DC1 RAC1 # <-- usUp Normal 1.07 GB 100.00% 0 
111.111.111.222 DC2 RAC1 Up Normal 1.1 GB 0.00% 1 

./nodetool -h 111.111.111.222 ring -port 11000 
Address DC Rack Status State Load Owns Token 
1 
111.111.111.111 DC1 RAC1 Up Normal 1.07 GB 100.00% 0 
111.111.111.222 DC2 RAC1 # <-- usUp Normal 1.1 GB 0.00% 1 

3) cassandra.yaml을 확인했습니다.

the seeds are 111.111.111.111, 111.111.111.222 
,

4) 나는이 cassandra-topology.properties

111.111.111.111 

    # Cassandra Node IP=Data Center:Rack 

    # datacenter 1 
    111.111.111.111=DC1:RAC1 # <-- us 

    # datacenter 2 
    111.111.111.222=DC2:RAC1 

    default=DC1:r1 

111.111.111.222 

    # Cassandra Node IP=Data Center:Rack 

    # datacenter 1 
    111.111.111.111=DC1:RAC1 

    # datacenter 2 
    111.111.111.222=DC2:RAC1 # <-- us 

    default=DC1:r1 

5) 우리는 다음과 같이 consistencyLevel 우리의 자바 응용 프로그램에서 LOCAL_QUORUM 설정 확인 :

나는이 구성이 작동 할 말을 들었다
public Keyspace getKeyspace(final String keyspaceName, final String serverAddresses) 
{   
    Keyspace ks = null; 
    Cluster c = clusterMap.get(serverAddresses); 
    if (c != null) 
    {    
     ConfigurableConsistencyLevel policy = new ConfigurableConsistencyLevel(); 
     policy.setDefaultReadConsistencyLevel(consistencyLevel); 
     policy.setDefaultWriteConsistencyLevel(consistencyLevel); 

     // Create Keyspace 
     ks = HFactory.createKeyspace(keyspaceName, c, policy); 
    }   
    return ks; 
} 

, 어쩌면 내가 뭔가를 놓치고있어. 당신이 두 개의 노드 만 있고 데이터가 실제로 아래로, 일관성이 필요한 경우, 당신은 전체 쓰기 가용성을 달성하지 못할 수있는 노드에 배치 될 경우 어떤 통찰력

답변

0

에 대한

감사합니다. 카산드라는 Hinted Handoff으로이를 달성 할 것이지만 QUORUM 일관성 레벨의 경우 UnavailableException이 던져 질 것입니다.

다운 노드에 속한 데이터를 요청할 때도 마찬가지입니다.

그러나 클러스터의 균형이 잘 맞지 않는 것처럼 보입니다. 노드 111.111.111.111이 100 % 소유하고 111.111.111.222이 0 %를 소유하고있는 것처럼 보입니다. 토큰을 보면 그 이유가있는 것처럼 보입니다. 여기에 초기 토큰을 설정하는 방법

체크 아웃 : http://www.datastax.com/docs/0.8/install/cluster_init#token-gen-cassandra

은 또한 당신이 Another Question을 확인 할 수 있습니다,이 같은 상황이 발생할 수 있습니다 때 더 많은 이유와 답을 포함하고 있습니다.

0

이 같은 NetworkTopologyStrategy를 구성하는 경우 LOCAL_QUORUM가 작동하지 않습니다

Options: [DC2:1, DC1:1] # this will make LOCAL_QUORUM and QUORUM fail always 

LOCAL_QUORUM과 (내 경험) QUORUM은 적어도이 데이터 센터를 필요로 2 복제물. 데이터 센터에 걸쳐 쿼럼을 원할 경우 일관성 수준을 데이터 센터에 영향을 미치지 않는 TWO으로 설정해야합니다.

더 많은 예제 :

Options: [DC2:3, DC1:1] # LOCAL_QUORUM for clients in DC2 works, QUORUM fails 

Options: [DC2:2, DC1:1] # LOCAL_QUORUM in DC2 works, but down after 1 node failure 
         # QUORUM fails, TWO works.