介绍
Redis Labs 修改 Redis 的开源协议确实是因为它们认为一些大型云服务提供商在没有对项目做出贡献的情况下利用 Redis 赚取利润。Redis Labs 从 Redis 7.4 版本开始,将原先的 BSD 源码使用协议修改为 RSALv2 和 SSPLv1 协议,这一变化意味着 Redis 在 OSI(开放源代码促进会)定义下不再被视为「开源」项目。
Redis Labs 首席执行官 Ofer Bengal 曾表示,云计算公司利用其垄断力量采用开源项目而不贡献。同时 Redis Labs 首席营销官 Manish Gupta 指出,新的许可证 RSAL 旨在保护 Redis Labs 开发的模块,如 RedisSearch、RedisGraph 等,这些模块将不再是开源软件,而是源码可用(source available)级别的软件。
Linux 基金会宣布创建 Valkey 7.2.5 的版本,这可能是对 Redis Labs 修改开源协议行为的回应。Valkey 7.2.5 是基于 Redis 7.2.4 版本 fork 出来的,旨在提供一个不受 Redis Labs 新许可证影响的 Redis 实现。
开源社区对于许可证的修改可能会有不同的反应,一些开发者和公司可能会支持这种改变,认为这有助于保护开源项目的可持续发展,而另一些人可能会对此持批评态度,认为这限制了开源精神的自由和开放性。无论如何,Redis Labs 的这一决策显然在开源社区引起了广泛的讨论和关注。
使用
下载与解压
wget https://github.com/valkey-io/valkey/archive/refs/tags/7.2.5.tar.gz
tar -zxvf 7.2.5.tar.gz
编译
cd valkey-7.2.5
make
安装
这通常需要几分钟才能完成。测试完成后,输入以下命令将二进制文件安装到系统上:
sudo make install
输出以下提示表示安装成功啦!
Hint: It's a good idea to run 'make test' ;)
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/valkey-server /etc/valkey/valkey.conf
发现本地端口
6379
被原有Redis占用,这里使用其他端口
6378
。再次启动就正常啦
服务
为了更好地控制Valkey的管理方式,您可以创建一个systemd单元文件,使其可以作为systemd服务。这样做的好处是可以服务器启动时启动Valkey。
创建并打开
/etc/systemd/system/valkey.service
文件:
[Unit]
Description=Valkey a new project to resume development on the formerly open-source Redis project
After=network.target
[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/valkey-server /etc/valkey/valkey.conf
ExecStop=/usr/local/bin/valkey-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.target
输入以下命令启动systemd服务
sudo systemctl start valkey.service
运行以下命令检查服务有没有错误
sudo systemctl status valkey.service
输出以下内容表示服务启动成功
● valkey.service - Valkey a new project to resume development on the formerly open-source Redis project
Loaded: loaded (/etc/systemd/system/valkey.service; disabled; vendor preset: enabled)
Active: active (running) since Tue 2024-04-2323:21:29 CST; 13min ago
Main PID: 26924 (valkey-server)
Tasks: 5 (limit: 4915)
CGroup: /system.slice/valkey.service
└─26924 /usr/local/bin/valkey-server 127.0.0.1:6378
Apr 2323:21:29 wt-test-develop valkey-server[26924]: 26924:C 23 Apr 202423:21:29.735 * Valkey version=7.2.5, bits=64, commit=000
Apr 2323:21:29 wt-test-develop valkey-server[26924]: 26924:C 23 Apr 202423:21:29.735 * Configuration loaded
Apr 2323:21:29 wt-test-develop valkey-server[26924]: 26924:M 23 Apr 202423:21:29.736 # You requested maxclients of 10000 requiri
Apr 2323:21:29 wt-test-develop valkey-server[26924]: 26924:M 23 Apr 202423:21:29.736 # Server can't set maximum open files to 10
Apr 23 23:21:29 wt-test-develop valkey-server[26924]: 26924:M 23 Apr 2024 23:21:29.737 # Current maximum open files is 4096. maxcl
Apr 23 23:21:29 wt-test-develop valkey-server[26924]: 26924:M 23 Apr 2024 23:21:29.737 * monotonic clock: POSIX clock_gettime
Apr 23 23:21:29 wt-test-develop valkey-server[26924]: 26924:M 23 Apr 2024 23:21:29.737 # Failed to write PID file: Permission deni
Apr 23 23:21:29 wt-test-develop valkey-server[26924]: 26924:M 23 Apr 2024 23:21:29.738 * Running mode=standalone, port=6378.
Apr 23 23:21:29 wt-test-develop valkey-server[26924]: 26924:M 23 Apr 2024 23:21:29.741 * Server initialized
Apr 23 23:21:29 wt-test-develop valkey-server[26924]: 26924:M 23 Apr 2024 23:21:29.742 * Ready to accept connections tcp
客户端
要测试您的服务是否正常运行,请使用命令行客户端连接到
Valkey
服务器。
$ valkey-cli -p 6378
127.0.0.1:6378> set name "Tinywan"
OK
127.0.0.1:6378> get name
"Tinywan"
127.0.0.1:6378>
由于客户端跟Redis完全一样,端口和提示信息也一样,所以可以直接使用Redis客户端连接
$ redis-cli -p 6378
127.0.0.1:6378> keys *
1) "name"
127.0.0.1:6378> get name
"Tinywan"
127.0.0.1:6378>
性能测试
在 Redis 安装完毕后会自动安装一个
redis-benchmark
测试工具,其是一个压力测试工具,用于测试 Redis 的性能。同理在安装完成
Valkey
后也会生成一个
valkey-benchmark
测试工具。
valkey-benchmark
valkey-benchmark -h 127.0.0.1 -p 6378 -n 10000 -c 20 -q
PING_INLINE: 45248.87 requests per second, p50=0.143 msec
PING_MBULK: 31545.74 requests per second, p50=0.359 msec
SET: 28409.09 requests per second, p50=0.607 msec
GET: 31645.57 requests per second, p50=0.343 msec
INCR: 29940.12 requests per second, p50=0.375 msec
LPUSH: 30487.80 requests per second, p50=0.439 msec
RPUSH: 30864.20 requests per second, p50=0.407 msec
LPOP: 33670.04 requests per second, p50=0.167 msec
RPOP: 24154.59 requests per second, p50=0.479 msec
SADD: 31250.00 requests per second, p50=0.351 msec
HSET: 47169.81 requests per second, p50=0.143 msec
SPOP: 42918.46 requests per second, p50=0.151 msec
ZADD: 30959.75 requests per second, p50=0.287 msec
ZPOPMIN: 48076.92 requests per second, p50=0.143 msec
LPUSH (needed to benchmark LRANGE): 49019.61 requests per second, p50=0.143 msec
LRANGE_100 (first 100 elements): 15600.62 requests per second, p50=0.551 msec
LRANGE_300 (first 300 elements): 6968.64 requests per second, p50=1.351 msec
LRANGE_500 (first 500 elements): 4466.28 requests per second, p50=2.031 msec
LRANGE_600 (first 600 elements): 3821.17 requests per second, p50=2.439 msec
MSET (10 keys): 32467.53 requests per second, p50=0.487 msec
XADD: 31446.54 requests per second, p50=0.479 msec
redis-benchmark
redis-benchmark -h 127.0.0.1 -p 6378 -n 10000 -c 20 -q
PING_INLINE: 42735.04 requests per second, p50=0.159 msec
PING_MBULK: 46511.63 requests per second, p50=0.143 msec
SET: 34843.21 requests per second, p50=0.151 msec
GET: 49019.61 requests per second, p50=0.143 msec
INCR: 46511.63 requests per second, p50=0.143 msec
LPUSH: 44052.86 requests per second, p50=0.143 msec
RPUSH: 33222.59 requests per second, p50=0.287 msec
LPOP: 23419.21 requests per second, p50=0.655 msec
RPOP: 43668.12 requests per second, p50=0.143 msec
SADD: 35087.72 requests per second, p50=0.159 msec
HSET: 32786.88 requests per second, p50=0.351 msec
SPOP: 26954.18 requests per second, p50=0.623 msec
ZADD: 23752.97 requests per second, p50=0.615 msec
ZPOPMIN: 23696.68 requests per second, p50=0.615 msec
LPUSH (needed to benchmark LRANGE): 31347.96 requests per second, p50=0.391 msec
LRANGE_100 (first 100 elements): 16051.36 requests per second, p50=0.959 msec
LRANGE_300 (first 300 elements): 7082.15 requests per second, p50=1.375 msec
LRANGE_500 (first 500 elements): 4679.46 requests per second, p50=1.991 msec
LRANGE_600 (first 600 elements): 4004.81 requests per second, p50=2.295 msec
MSET (10 keys): 27247.96 requests per second, p50=0.519 msec
XADD: 24449.88 requests per second, p50=0.455 msec
简单比较
数据库 | PING | SET | GET | SPOP | ZPOPMIN | XADD |
---|---|---|---|---|---|---|
Redis | 42735.04 | 34843.21 | 49019.61 | 26954.18 | 23696.68 | 24449.88 |
Valkey | 45248.87 | 28409.09 | 31645.57 | 42918.46 | 48076.92 | 23752.97 |