源码安装
下载、解压
# 使用 curl 下载 和 解压
VALKEY_VERSION=9.0.1
curl -L -o valkey-$VALKEY_VERSION.tar.gz https://github.com/valkey-io/valkey/archive/refs/tags/$VALKEY_VERSION.tar.gz
ls -lh valkey-$VALKEY_VERSION.tar.gz
tar -zxvf valkey-$VALKEY_VERSION.tar.gz
ls -lh
# 使用 wget 下载 和 解压
VALKEY_VERSION=9.0.1
wget --no-check-certificate --content-disposition https://github.com/valkey-io/valkey/archive/refs/tags/$VALKEY_VERSION.tar.gz
ls -lh valkey-$VALKEY_VERSION.tar.gz
tar -zxvf valkey-$VALKEY_VERSION.tar.gz
ls -lh
编译、安装
valkey 8+ 编译时 gcc 版本必须 >= 4.9,否则将出现下列异常[root@anolis-7-9 valkey-9.0.1]# make MALLOC=libc
cd src && make all
which: no python3 in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
make[1]: Entering directory `/root/valkey-9.0.1/src'
CC Makefile.dep
make[1]: Leaving directory `/root/valkey-9.0.1/src'
which: no python3 in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
make[1]: Entering directory `/root/valkey-9.0.1/src'
CC threads_mngr.o
In file included from server.h:34:0,
from threads_mngr.c:35:
config.h:378:161: error: missing binary operator before token "("
#if defined(__x86_64__) && ((defined(__GNUC__) && __GNUC__ >= 5) || (defined(__clang__) && __clang_major__ >= 4)) && defined(__has_attribute) && __has_attribute(target)
^
In file included from threads_mngr.c:35:0:
server.h:43:23: fatal error: stdatomic.h: No such file or directory
#include <stdatomic.h>
^
compilation terminated.
make[1]: *** [threads_mngr.o] Error 1
make[1]: Leaving directory `/root/valkey-9.0.1/src'
make: *** [all] Error 2
[root@anolis-7-9 valkey-9.0.1]#
gcc 版本列表参见:gcc
# CentOS
# 使用英文输出
# export LANG=en_US.UTF-8
VALKEY_VERSION=9.0.1
cd valkey-$VALKEY_VERSION
yum -y install gcc make
# 或 make
make MALLOC=libc
make install
# Debian
VALKEY_VERSION=9.0.1
cd valkey-$VALKEY_VERSION
make
make install
# 安装结果
INSTALL valkey-server
INSTALL valkey-benchmark
INSTALL valkey-cli
INSTALL SYMLINK redis-server -> valkey-server
INSTALL SYMLINK redis-cli -> valkey-cli
INSTALL SYMLINK redis-benchmark -> valkey-benchmark
INSTALL SYMLINK redis-check-rdb -> valkey-check-rdb
INSTALL SYMLINK redis-check-aof -> valkey-check-aof
INSTALL SYMLINK redis-sentinel -> valkey-sentinel
安装结果
| 文件目录 |
说明 |
/usr/local/bin/redis-server |
Redis 服务端,软连接到 /usr/local/bin/valkey-server |
/usr/local/bin/redis-cli |
Redis 客户端,软连接 /usr/local/bin/valkey-cli |
/usr/local/bin/redis-sentinel |
Redis 哨兵,软连接 /usr/local/bin/valkey-sentinel |
/usr/local/bin/valkey-server |
valkey 服务端 |
/usr/local/bin/valkey-cli |
valkey 客户端 |
/usr/local/bin/valkey-sentinel |
valkey 哨兵 |
测试版本
# valkey
valkey-server --version
# redis
redis-server --version
测试启动
- 源码解压目录中可找到
valkey.conf 文件
- 默认情况下,只能本地连接,无法进行远程连接
- 如果启动时出现异常
Failed to configure LOCALE for invalid locale name.,需要配置 export LC_ALL=C.UTF-8 切换语言
# 直接启动
[root@k8s-1 ~]# valkey-server
79088:M 10 Dec 2025 09:51:23.149 * oO0OoO0OoO0Oo Valkey is starting oO0OoO0OoO0Oo
79088:M 10 Dec 2025 09:51:23.149 * Valkey version=9.0.1, bits=64, commit=00000000, modified=0, pid=79088, just started
79088:M 10 Dec 2025 09:51:23.149 # Warning: no config file specified, using the default config. In order to specify a config file use valkey-server /path/to/valkey.conf
79088:M 10 Dec 2025 09:51:23.149 * Increased maximum number of open files to 10032 (it was originally set to 1024).
79088:M 10 Dec 2025 09:51:23.149 * monotonic clock: POSIX clock_gettime
.+^+.
.+#########+.
.+########+########+. Valkey 9.0.1 (00000000/0) 64 bit
.+########+' '+########+.
.########+' .+. '+########. Running in standalone mode
|####+' .+#######+. '+####| Port: 6379
|###| .+###############+. |###| PID: 79088
|###| |#####*'' ''*#####| |###|
|###| |####' .-. '####| |###|
|###| |###( (@@@) )###| |###| https://valkey.io
|###| |####. '-' .####| |###|
|###| |#####*. .*#####| |###|
|###| '+#####| |#####+' |###|
|####+. +##| |#+' .+####|
'#######+ |##| .+########'
'+###| |##| .+########+'
'| |####+########+'
+#########+'
'+v+'
79088:M 10 Dec 2025 09:51:23.150 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
79088:M 10 Dec 2025 09:51:23.151 * Server initialized
79088:M 10 Dec 2025 09:51:23.151 * Cleaning slot migration log in anticipation of a load operation.
79088:M 10 Dec 2025 09:51:23.151 * Loading RDB produced by Valkey version 9.0.1
79088:M 10 Dec 2025 09:51:23.151 * RDB age 85 seconds
79088:M 10 Dec 2025 09:51:23.151 * RDB memory usage when created 0.91 Mb
79088:M 10 Dec 2025 09:51:23.151 * Done loading RDB, keys loaded: 0, keys expired: 0.
79088:M 10 Dec 2025 09:51:23.151 * DB loaded from disk: 0.000 seconds
79088:M 10 Dec 2025 09:51:23.151 * Ready to accept connections tcp
# 使用配置文件启动
[root@k8s-1 ~]# valkey-server valkey.conf
82380:M 10 Dec 2025 09:53:09.244 * oO0OoO0OoO0Oo Valkey is starting oO0OoO0OoO0Oo
82380:M 10 Dec 2025 09:53:09.244 * Valkey version=9.0.1, bits=64, commit=00000000, modified=0, pid=82380, just started
82380:M 10 Dec 2025 09:53:09.244 * Configuration loaded
82380:M 10 Dec 2025 09:53:09.244 * Increased maximum number of open files to 10032 (it was originally set to 1024).
82380:M 10 Dec 2025 09:53:09.245 * monotonic clock: POSIX clock_gettime
.+^+.
.+#########+.
.+########+########+. Valkey 9.0.1 (00000000/0) 64 bit
.+########+' '+########+.
.########+' .+. '+########. Running in standalone mode
|####+' .+#######+. '+####| Port: 6379
|###| .+###############+. |###| PID: 82380
|###| |#####*'' ''*#####| |###|
|###| |####' .-. '####| |###|
|###| |###( (@@@) )###| |###| https://valkey.io
|###| |####. '-' .####| |###|
|###| |#####*. .*#####| |###|
|###| '+#####| |#####+' |###|
|####+. +##| |#+' .+####|
'#######+ |##| .+########'
'+###| |##| .+########+'
'| |####+########+'
+#########+'
'+v+'
82380:M 10 Dec 2025 09:53:09.246 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
82380:M 10 Dec 2025 09:53:09.246 * Server initialized
82380:M 10 Dec 2025 09:53:09.246 * Cleaning slot migration log in anticipation of a load operation.
82380:M 10 Dec 2025 09:53:09.246 * Loading RDB produced by Valkey version 9.0.1
82380:M 10 Dec 2025 09:53:09.246 * RDB age 14 seconds
82380:M 10 Dec 2025 09:53:09.246 * RDB memory usage when created 0.91 Mb
82380:M 10 Dec 2025 09:53:09.246 * Done loading RDB, keys loaded: 0, keys expired: 0.
82380:M 10 Dec 2025 09:53:09.246 * DB loaded from disk: 0.000 seconds
82380:M 10 Dec 2025 09:53:09.246 * Ready to accept connections tcp
本地连接
[root@k8s-1 ~]# valkey-cli
127.0.0.1:6379> set name xuxiaowei
OK
127.0.0.1:6379> get name
"xuxiaowei"
127.0.0.1:6379>
其他配置