Aerospike测试容器:2个名称空间



我使用官方的Aerospike Docker镜像来使用Testcontainers运行它。我可以指定一个默认名称空间作为环境变量。不幸的是,我无法在容器启动时创建2个名称空间。

有什么方法可以做到这一点吗?

不能用环境变量声明多个命名空间。但是您可以传递自定义Aerospike配置文件。看看下面的例子:

static final GenericContainer<?> aerospike =
new GenericContainer<>(DockerImageName.parse("aerospike/aerospike-server:5.6.0.4"))
.withClasspathResourceMapping("aerospike.conf", "/opt/aerospike/etc/aerospike.conf", READ_ONLY)
.withExposedPorts(3000, 3001, 3002)
.withCommand("--config-file /opt/aerospike/etc/aerospike.conf")
.waitingFor(Wait.forLogMessage(".*migrations: complete.*", 2));

withClasspathResourceMapping方法将aerospike.conf文件复制到容器中。该文件位于src/test/resources目录中。下面是一个带有两个名称空间的Aerospike配置示例。

# This stanza must come first.
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
proto-fd-max 15000
}
logging {
# Log file must be an absolute path.
file /dev/null {
context any info
}
# Send log messages to stdout
console {
context any info
}
}
network {
service {
address any
port 3000
}
heartbeat {
address any
mode mesh
port 3002
interval 150
timeout 10
}
fabric {
address any
port 3001
}
}
namespace product-namespace {
replication-factor 1
memory-size 1G
default-ttl 30d
nsup-period 120
storage-engine device {
file /opt/aerospike/data/product_namespace.dat
filesize 4G
data-in-memory true # Store data in memory in addition to file.
}
}
namespace client-namespace {
replication-factor 1
memory-size 1G
default-ttl 30d
nsup-period 120
storage-engine device {
file /opt/aerospike/data/client_namespace.dat
filesize 4G
data-in-memory true # Store data in memory in addition to file.
}
}

在这种情况下,将创建product-namespaceclient-namespace

最新更新