Install Redis from Source
debian 12(bookworm) Install Redis from Source
编译安装
wget https://github.com/redis/redis/archive/refs/tags/7.2.5.tar.gz -O redis-7.2.5.tar.gz
tar xzf redis-7.2.5.tar.gz && cd redis-7.2.5
# make -j8 BUILD_TLS=yes
sudo make -j8 install
参考配置
mkdir /var/log/redis
/usr/local/etc/redis.conf
daemonize yes
pidfile /var/run/redis/redis7.pid
port 6379
bind 0.0.0.0
# unixsocket /var/run/redis/redis.sock
# unixsocketperm 700
tcp-backlog 511
# protected-mode yes
requirepass debian
timeout 0
tcp-keepalive 0
# log-level:debug, verbose, notice, warn
loglevel notice
logfile /var/log/redis/redis7.log
# syslog-enabled no
# syslog-ident redis
# syslog-facility local0
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename redis-6379.rdb
dir /vms/databases/redis/
服务启动
/lib/systemd/system/redis7.service
[Unit]
Description=Advanced key-value store
After=network.target
Documentation=http://redis.io/documentation, man:redis-server(1)
[Service]
Type=notify
PIDFile=/run/redis/redis7.pid
RuntimeDirectory=redis
RuntimeDirectoryMode=2755
ExecStart=/usr/local/bin/redis-server /usr/local/etc/redis.conf --supervised systemd --daemonize no
TimeoutStopSec=0
Restart=always
User=nick
Group=users
[Install]
WantedBy=multi-user.target
常用命令
redis-cli -h 10.20.0.26 -a password
redis-server # Redis服务器的daemon启动程序
redis-cli # Redis命令行操作工具。也可以用telnet根据其纯文本协议来操作
redis-benchmark # Redis性能测试工具,测试Redis在当前系统下的读写性能
redis-check-aof # 数据修复
redis-check-rdb # rdb修复命令
redis-check-dump # 检查导出工具