2016-11-01 96 views
1

我決定嘗試aerospike,但是我遇到了一些問題。 我使用的碼頭工人,塞:無法從aerospike中刪除記錄

companies-data: 
    image: 'aerospike/aerospike-server:3.10.0-1' 
    ports: 
     - '5310:3000' 
     - '5311:3001' 
     - '5312:3002' 
     - '5313:3003' 
    volumes: 
     - './companies-data/data:/opt/aerospike/data' 
     - './companies-data/config:/opt/aerospike/etc' 
    command: '/usr/bin/asd --foreground --config-file /opt/aerospike/etc/aerospike.conf' 

當我創建了一個記錄,然後重新啓動泊塢窗容器中的數據仍然存在,所以卷的設置是否正確。但是,當我刪除記錄並重新啓動泊塢窗容器時,記錄仍然存在,它不會被刪除。在重新啓動之前它工作正常:記錄被刪除,但是在docker-container重新啓動後,它再次出現。

我正在使用nodejs aerospike客戶端。

let key = new Key(this.ns, this.set, id); 
client.remove(key, function (err, key) { 
    if (err) { 
     return reject(err); 
    } 
    resolve(key); 
}); 

這裏是我的conf:

service { 
    user root 
    group root 
    paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1. 
    pidfile /var/run/aerospike/asd.pid 
    service-threads 4 
    transaction-queues 4 
    transaction-threads-per-queue 4 
    proto-fd-max 15000 
} 

logging { 

    # Log file must be an absolute path. 
    file /var/log/aerospike/aerospike.log { 
     context any info 
    } 

    # Send log messages to stdout 
    console { 
     context any info 
    } 
} 

network { 
    service { 
     address any 
     port 3000 

     # Uncomment the following to set the `access-address` parameter to the 
     # IP address of the Docker host. This will the allow the server to correctly 
     # publish the address which applications and other nodes in the cluster to 
     # use when addressing this node. 
     # access-address <IPADDR> 
    } 

    heartbeat { 

     # mesh is used for environments that do not support multicast 
     mode mesh 
     port 3002 

     # use asinfo -v 'tip:host=<ADDR>;port=3002' to inform cluster of 
     # other mesh nodes 

     interval 150 
     timeout 10 
    } 

    fabric { 
     port 3001 
    } 

    info { 
     port 3003 
    } 
} 

namespace mtm { 
    replication-factor 2 
    memory-size 1G 
    default-ttl 5d # 5 days, use 0 to never expire/evict. 

    # storage-engine memory 

    # To use file storage backing, comment out the line above and use the 
    # following lines instead. 
    storage-engine device { 
     file /opt/aerospike/data/mtm.dat 
     filesize 4G 
     data-in-memory true # Store data in memory in addition to file. 
    } 
} 

如何完全刪除記錄?

回答

2

刪除機制刪除數據的索引條目,從而立即釋放索引空間和存儲空間。但是,它不會持久地向存儲寫入墓碑標記記錄,因此可以在完全冷重新啓動集羣或網絡分區的情況下恢復已刪除的記錄。

這是關於3.10版本的最新Aerospike Blog Post

在塞式企業版中提供

2的功能做解決這個問題:

1-快速啓動(指數在共享內存中保存)。 2-持久刪除(請參閱上面提到的博客文章)。

您可以在Aerospike論壇上閱讀更多關於您在this thread上遇到的行爲。

+1

顯然,除非您爲企業版支付費用,否則您無法執行此基本操作。 –

+1

您可以使用ttl來管理記錄的生命週期(因爲過期的記錄不會在冷啓動時加載 - 但是您必須不縮短記錄的壽命,否則會遇到同樣的問題)。解決這個問題的另一種方法是在將數據添加回羣集之前清理其數據的節點(如果執行了大量刪除操作)。即使在企業版中,冷啓動也會帶回已刪除的記錄,除非它們已被持久刪除(在使用之前它有自己的一套事情要考慮......) – Meher