Node.js Can';t从aerospike中删除记录
我决定试试aerospike,但我有一些问题。 我在docker中使用aerospike:Node.js Can';t从aerospike中删除记录,node.js,docker,aerospike,Node.js,Docker,Aerospike,我决定试试aerospike,但我有一些问题。 我在docker中使用aerospike: companies-data: image: 'aerospike/aerospike-server:3.10.0-1' ports: - '5310:3000' - '5311:3001' - '5312:3002' - '5313:3003' volumes: - './companies-data
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容器时,数据仍然存在,因此卷设置正确。但是,当我删除一条记录并重新启动docker容器时,该记录仍然存在,不会被删除。在重新启动之前,它工作正常:记录被删除,但在docker容器重新启动之后,它又出现了
我使用的是nodejs aerospike客户端
let key = new Key(this.ns, this.set, id);
client.remove(key, function (err, key) {
if (err) {
return reject(err);
}
resolve(key);
});
这是我的配置文件:
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.
}
}
服务{
用户根
群根
paxos单副本限制1#副本计数自动减少到1的节点数。
pidfile/var/run/aerospike/asd.pid
服务线程4
事务队列4
每个队列4的事务线程
proto fd最大值15000
}
伐木{
#日志文件必须是绝对路径。
文件/var/log/aerospike/aerospike.log{
上下文信息
}
#向标准输出发送日志消息
控制台{
上下文信息
}
}
网络{
服务{
解决任何问题
端口3000
#取消注释以下内容以将“访问地址”参数设置为
#Docker主机的IP地址。这将允许服务器正确运行
#发布群集中的应用程序和其他节点要发布的地址
#在寻址此节点时使用。
#访问地址
}
心跳{
#mesh用于不支持多播的环境
模式网格
端口3002
#使用asinfo-v'tip:host=;port=3002'通知集群
#其他网格节点
间隔150
超时10
}
织物{
端口3001
}
信息{
端口3003
}
}
名称空间mtm{
复制因子2
内存大小1G
默认ttl 5d#5天,使用0永不过期/退出。
#存储引擎存储器
#要使用文件存储备份,请注释掉上面的行并使用
#改为跟着行。
存储引擎设备{
文件/opt/aerospeck/data/mtm.dat
文件大小4G
内存中的数据为真#除文件外,还将数据存储在内存中。
}
}
如何完全删除记录?删除机制删除数据的索引项,从而立即释放索引空间和存储空间。但是,它不会持久地将墓碑标记记录写入存储器,因此可以在集群或网络分区完全冷重启的情况下恢复已删除的记录 这是关于3.10版本的最新Aerospike Aerospike Enterprise Edition中提供的两个功能确实解决了此问题: 1-快速启动(索引保存在共享内存中)。 2-持久删除(见上面提到的博客文章)
您可以在Aerospike论坛上了解更多有关您体验到的行为的信息。因此,除非您为企业版付费,否则显然您无法执行此基本操作。您可以使用ttl管理记录(因为过期的记录不会在coldstart上重新加载-但是您必须不要缩短记录的生命周期,否则会遇到相同的问题)。解决此问题的另一种方法是在将其数据添加回集群之前清理其节点(如果您执行了大量删除)即使在企业版上,冷启动也会恢复已删除的记录,除非它们已经被持久删除(在使用之前有自己的事情要考虑)。