Amazon Linux 2023(内核 6.1) 安装 Redis8

摘要

Yum 安装

最省事,国内环境也可以顺利完成安装。
Amazon Linux 2023(内核 6.1)Rocky Linux release 9.4 (Blue Onyx) 均成功安装。

  • 1.添加仓库

1
2
3
4
5
6
7
sudo tee /etc/yum.repos.d/redis.repo > /dev/null <<EOF
[Redis]
name=Redis
baseurl=http://packages.redis.io/rpm/rockylinux9
enabled=1
gpgcheck=1
EOF
  • 2.安装 Redis

1
2
3
curl -fsSL https://packages.redis.io/gpg > /tmp/redis.key
sudo rpm --import /tmp/redis.key
sudo yum install redis -y
  • 3.查看redis安装信息

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
# 查看已安装的redis版本
$ rpm -qa | grep redis
redis-8.4.0-1.x86_64

# 查看redis安装信息
$ rpm -qi redis-8.4.0-1.x86_64
Name : redis
Version : 8.4.0
Release : 1
Architecture: x86_64
Install Date: Wed 24 Dec 2025 06:05:22 AM UTC
Group : Applications/Databases
Size : 83034075
License :
Signature : RSA/SHA512, Mon 01 Dec 2025 12:05:10 PM UTC, Key ID 5f4349d6bf53aa0c
Source RPM : redis-8.4.0-1.src.rpm
Build Date : Tue 18 Nov 2025 04:41:58 PM UTC
Build Host : 331d5099e900
Packager : Redis Labs <redis@redis.io>
URL : https://redis.io/
Summary : Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps.
Description :
Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps.

# 查看redis安装的文件
$ rpm -ql redis-8.4.0-1.x86_64
/etc/redis
/etc/redis/redis.conf
/etc/redis/sentinel
/etc/redis/sentinel/sentinel.conf
/run/redis
/run/redis/redis-server.pid
/usr/bin/redis-benchmark
/usr/bin/redis-check-aof
/usr/bin/redis-check-rdb
/usr/bin/redis-cli
/usr/bin/redis-sentinel
/usr/bin/redis-server
/usr/lib/redis
/usr/lib/redis/modules
/usr/lib/redis/modules/redisbloom.so
/usr/lib/redis/modules/redisearch.so
/usr/lib/redis/modules/redistimeseries.so
/usr/lib/redis/modules/rejson.so
/usr/lib/redis/redisbloom.so
/usr/lib/redis/redisearch.so
/usr/lib/redis/redistimeseries.so
/usr/lib/redis/rejson.so
/usr/lib/systemd/system/redis-sentinel.service
/usr/lib/systemd/system/redis.service
/usr/share/selinux/packages/redis-ce.fc
/usr/share/selinux/packages/redis-ce.te
/var/lib/redis
/var/log/redis
/var/log/redis/redis-sentinel.log
/var/log/redis/redis-server.log
  • 4.启动redis

1
2
3
sudo systemctl enable redis
sudo systemctl start redis
sudo systemctl status redis
  • 5.登录redis

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
$ redis-cli
127.0.0.1:6379> MODULE LIST
1) 1) "name"
2) "bf"
3) "ver"
4) (integer) 80400
5) "path"
6) "/usr/lib/redis/modules/redisbloom.so"
7) "args"
8) (empty array)
2) 1) "name"
2) "timeseries"
3) "ver"
4) (integer) 80400
5) "path"
6) "/usr/lib/redis/modules/redistimeseries.so"
7) "args"
8) (empty array)
3) 1) "name"
2) "ReJSON"
3) "ver"
4) (integer) 80400
5) "path"
6) "/usr/lib/redis/modules/rejson.so"
7) "args"
8) (empty array)
4) 1) "name"
2) "vectorset"
3) "ver"
4) (integer) 1
5) "path"
6) ""
7) "args"
8) (empty array)
5) 1) "name"
2) "search"
3) "ver"
4) (integer) 80402
5) "path"
6) "/usr/lib/redis/modules/redisearch.so"
7) "args"
8) (empty array)

源码安装

  • 1.更新环境(非必须)

1
sudo dnf update -y
  • 2.安装依赖包

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
sudo dnf install -y --nobest --skip-broken \
pkg-config \
xz \
wget \
which \
git \
make \
openssl \
openssl-devel \
python3 \
python3-pip \
python3-devel \
unzip \
rsync \
clang \
llvm \
curl \
libtool \
automake \
autoconf \
jq \
systemd-devel
  • 3.下载并提取Redis源代码

1
2
3
cd /usr/src
sudo wget -O redis-8.4.0.tar.gz https://github.com/redis/redis/archive/refs/tags/8.4.0.tar.gz
sudo tar -xzf redis-8.4.0.tar.gz
  • 4.编译Redis

这里要注意,不会自动安装模块,需要手动安装。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 启用GCC工具集
cd /usr/src/redis-8.4.0
# 构建TLS
export BUILD_TLS=yes
# 构建Redis模块,配不配都不会自动安装模块
export BUILD_WITH_MODULES=yes
# 安装Rust工具链
export INSTALL_RUST_TOOLCHAIN=yes
# 关闭警告
export DISABLE_WERRORS=yes
# 开始编译
sudo make -j "$(nproc)" all

# 验证
./src/redis-server --version
./src/redis-cli --version

  • 5.启动Redis

1
sudo ./src/redis-server redis.conf
  • 6.登录Redis

1
2
3
4
5
6
7
8
9
10
$ ./src/redis-cli
127.0.0.1:6379> MODULE LIST
1) 1) "name"
2) "vectorset"
3) "ver"
4) (integer) 1
5) "path"
6) ""
7) "args"
8) (empty array)