2012-08-07 82 views
7

運行Cassandra守護進程時,我遇到以下異常。我從1.2主幹運行。在啓動Cassandra時讀取已保存的緩存和系統表時出錯

WARN 14:47:51,038 error reading saved cache /home/manuzhang/cassandra/saved_caches/system-local-KeyCache-b.db 
java.lang.NullPointerException 
    at org.apache.cassandra.cache.AutoSavingCache.loadSaved(AutoSavingCache.java:141) 
    at org.apache.cassandra.db.ColumnFamilyStore.<init>(ColumnFamilyStore.java:237) 
    at org.apache.cassandra.db.ColumnFamilyStore.createColumnFamilyStore(ColumnFamilyStore.java:340) 
    at org.apache.cassandra.db.ColumnFamilyStore.createColumnFamilyStore(ColumnFamilyStore.java:312) 
    at org.apache.cassandra.db.Table.initCf(Table.java:332) 
    at org.apache.cassandra.db.Table.<init>(Table.java:265) 
    at org.apache.cassandra.db.Table.open(Table.java:110) 
    at org.apache.cassandra.db.Table.open(Table.java:88) 
    at org.apache.cassandra.db.SystemTable.checkHealth(SystemTable.java:284) 
    at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:168) 
    at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:318) 
    at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:361) 

這裏的地方緩存保存:

[email protected]:~/cassandra/saved_caches$ ls -l 
total 12 
-rw-rw-r-- 1 manuzhang manuzhang 156 Aug 7 13:09 system-local-KeyCache-b.db 
-rw-rw-r-- 1 manuzhang manuzhang 60 Aug 7 13:09 system-schema_columnfamilies-KeyCache-b.db 
-rw-rw-r-- 1 manuzhang manuzhang 60 Aug 7 13:09 system-schema_columns-KeyCache-b.db 

此外,無法加載系統表文件。

ERROR 17:03:16,637 Fatal exception during initialization 
org.apache.cassandra.config.ConfigurationException: Found system table files, but they couldn't be loaded! 
at org.apache.cassandra.db.SystemTable.checkHealth(SystemTable.java:303) 
at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:201) 
at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:349) 
at org.apache.cassandra.service.CassandraDaemon.main(CassandraDaemon.java:392) 

現在我能夠重現裝載系統故障表爲每個卡桑德拉的運行(我事後清理所有文件)。這裏拋出異常:

/** 
* One of three things will happen if you try to read the system table: 
* 1. files are present and you can read them: great 
* 2. no files are there: great (new node is assumed) 
* 3. files are present but you can't read them: bad 
* @throws ConfigurationException 
*/ 
public static void checkHealth() throws ConfigurationException 
{ 
    Table table; 
    try 
    { 
     table = Table.open(Table.SYSTEM_TABLE); 
    } 
    catch (AssertionError err) 
    { 
     // this happens when a user switches from OPP to RP. 
     ConfigurationException ex = new ConfigurationException("Could not read system table!"); 
     ex.initCause(err); 
     throw ex; 
    } 
    ColumnFamilyStore cfs = table.getColumnFamilyStore(LOCAL_CF); 

    String req = "SELECT cluster_name FROM system.%s WHERE key='%s'"; 
    UntypedResultSet result = processInternal(String.format(req, LOCAL_CF, LOCAL_KEY)); 

    if (result.isEmpty() || !result.one().has("cluster_name")) 
    { 
     // this is a brand new node 
     if (!cfs.getSSTables().isEmpty()) 
      throw new ConfigurationException("Found system table files, but they couldn't be loaded!"); 

     // no system files. this is a new node. 
     req = "INSERT INTO system.%s (key, cluster_name) VALUES ('%s', '%s')"; 
     processInternal(String.format(req, LOCAL_CF, LOCAL_KEY, DatabaseDescriptor.getClusterName())); 
     return; 
    } 

    String savedClusterName = result.one().getString("cluster_name"); 
    if (!DatabaseDescriptor.getClusterName().equals(savedClusterName)) 
     throw new ConfigurationException("Saved cluster name " + savedClusterName + " != configured name " + DatabaseDescriptor.getClusterName()); 
} 

這三次運行完全符合註釋中的三個條件。

「沒有文件存在」在第一次運行,因爲它是一個全新的節點。

在第二次運行「文件在那裏,你可以看到他們。」

在第三次運行中,「文件存在但您無法讀取它們」,並且我檢查了result.isEmpty()result.one.has("cluster_name")都返回false

其實,我很困惑與異常「無法加載」。這是什麼意思?我不認爲這是文件系統權限問題,因爲r/w權限授予當前用戶。

上述問題消失後,我刪除所有相關文件,但我不希望運行卡桑德拉每次都做到這一點。

這一直困擾着我很長一段時間。

一個不相關的問題是,我不認爲卡桑德拉@計算器已經得到足夠的重視從社會。你同意嗎?

任何意見或建議,將不勝感激。

謝謝。

+1

你爲什麼運行cassandra主幹,而不是發佈的版本? – sbridges 2012-09-03 13:14:40

+0

@sbridges如果您按照Cassandra wiki下載代碼庫,那就是您得到的;並且我還可以閱讀有關虛擬節點的新內容 – manuzhang 2012-09-03 23:29:03

+0

您是否可以通過官方發佈重現您的問題:http://cassandra.apache.org/download/ – sbridges 2012-09-04 02:26:35

回答

1

我在2個場景中遇到了這個問題。

  1. 我試圖改變分區而不刪除集羣的數據(不能這樣做)也查看mailing list的解釋。
  2. 我第一次啓動時,以超級用戶的身份運行了cassandra進程sudo ./cassandra,它創建了僅具有超級用戶權限的必需數據/日誌/高速緩存目錄,然後重新啓動cassandra並以普通用戶身份運行進程沒有權限使用超級用戶運行的進程創建的目錄中的文件)。

我知道你解決了這個問題,但是這可能對其他開發人員非常有用。