Redis¶
基础环境,在Debian12,通过apt安装redis-server
基础信息¶
/etc/redis
常用命令¶
# 自启
systemctl enable redis-server
# 运行
systemctl start redis-server
# 状态
systemctl status redis-server
# 重启
systemctl restart redis-server
# 连接
redis-cli
安装最新的社区版本¶
# 1. 更新系統套件
apt update && apt upgrade
# 2. 安裝必要的套件
apt install software-properties-common apt-transport-https curl ca-certificates -y
# 3.導入 Redis.io 倉庫
# 導入 GPG 金鑰以驗證資料來源
curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
# 導入倉庫
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list
# 4. 透過 APT 命令安裝 Redis
apt update && apt install redis redis-server redis-tools
# 5. 驗證 Redis 安裝
apt-cache policy redis
# 6. 驗證 Redis 是否正常執行
systemctl status redis-server