KeyDB 安装配置:号称吊打 Redis 的发行版
KeyDB 是 Redis 的一个多线程分支,主打「同一份数据、多核并行处理」,在单机上用多线程 I/O 与多线程命令执行来提升吞吐。下面是它的 RPM 安装、配置文件要点和集群搭建步骤。
版本说明
本文写于 2022-03,基于当时活跃开发的 KeyDB。
现状说明:KeyDB 项目自 Snap Inc. 收购后开发已基本停滞,官方 GitHub 长期无实质性更新,不建议在新项目中选型;本文的多线程/FLASH 存储等设计思路仍有参考价值,但生产环境请优先评估 Redis 官方多线程 I/O(6.0+)或 Valkey(Redis 社区分支)等更活跃的替代方案。
wget https://download.keydb.dev/pkg/open_source/rpm/centos7/x86_64/keydb-latest-1.el7.x86_64.rpm
yum localintall keydb-latest-1.el7.x86_64.rpm
1
2
3
2
3
cat /data/keydb7001/keydb7001.conf
bind 192.0.2.11
protected-mode yes
port 7001
tcp-backlog 511
timeout 0
tcp-keepalive 0
daemonize yes
supervised no
pidfile "/data/keydb7001/keydb7001.pid"
loglevel notice
logfile "/data/keydb7001/keydb7001.log"
databases 16
always-show-logo yes
requirepass Cv88xO3SuVv0FSGI
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename "dump.rdb"
dir "/data/keydb7001/"
masterauth Cv88xO3SuVv0FSGI
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
maxclients 100000
maxmemory-policy allkeys-lfu
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly yes
appendfilename "appendonly.aof"
appendfsync no
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
#client-output-buffer-limit slave 2048mb 1500mb 60
client-output-buffer-limit slave 0 0 0
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
repl-backlog-size 2500000kb
repl-timeout 5000
# Generated by CONFIG REWRITE
save 900 1
save 300 10
save 60 10000
#add by mc@20201213 for memallc
activedefrag yes
active-defrag-ignore-bytes 500mb
active-defrag-threshold-lower 10
active-defrag-cycle-min 25
active-defrag-cycle-max 75
# rename-command CONFIG "ADMIN_CONFIG"
rename-command FLUSHALL "ADMIN_FLUSHALL"
rename-command FLUSHDB "ADMIN_FLUSHDB"
rename-command KEYS "ADMIN_KEYS"
maxmemory 10240mb
cluster-enabled yes
cluster-config-file "cluster-7001.conf"
cluster-node-timeout 5000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
cat /usr/lib/systemd/system/keydb7001.service
[Unit]
Description=Advanced key-value store
After=network.target
Documentation=https://docs.keydb.dev, man:keydb-server(1)
[Service]
Type=forking
ExecStart=/usr/bin/keydb-server /data/keydb7001/keydb7001.conf
ExecStop=/bin/kill -s TERM $MAINPID
PIDFile=/data/keydb7001/keydb-server.pid
TimeoutStopSec=0
Restart=always
User=keydb
Group=keydb
RuntimeDirectory=keydb
RuntimeDirectoryMode=2755
UMask=007
PrivateTmp=yes
LimitNOFILE=65535
PrivateDevices=yes
ProtectHome=yes
ReadOnlyDirectories=/
ReadWriteDirectories=-/data/keydb7001
ReadWriteDirectories=-/data/keydb7001
ReadWriteDirectories=-/data/keydb7001
NoNewPrivileges=true
CapabilityBoundingSet=CAP_SETGID CAP_SETUID CAP_SYS_RESOURCE
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
ProtectSystem=true
ReadWriteDirectories=-/etc/keydb
[Install]
WantedBy=multi-user.target
Alias=keydb.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
上次更新: 8/27/2026