一、安装 Redis

安装:

apt install -y redis-server

查看状态:

systemctl status redis-server

开机自启:

systemctl enable redis-server

二、Redis 安全+持久化配置

备份配置文件

mv /etc/redis/redis.conf mv /etc/redis/redis.conf.bak

编辑:

nano /etc/redis/redis.conf

配置:

# redis 密码
requirepass 你的密码
# 只能本地链接 可配置ssh公网连接
bind 127.0.0.1 -::1
protected-mode yes
# 公网放开
# bind 0.0.0.0

# 配置持久化文件存储路径
dir /var/lib/redis
# 配置rdb
# 15分钟内有至少1个key被更改则进行快照
save 900 1
# 5分钟内有至少10个key被更改则进行快照
save 300 10
# 1分钟内有至少10000个key被更改则进行快照
save 60 10000
# 开启压缩
rdbcompression yes
# rdb文件名 用默认的即可
dbfilename dump.rdb

# 开启aof
appendonly yes
# 文件名
appendfilename "appendonly.aof"
# 持久化策略,no:不同步,everysec:每秒一次,always:总是同步,速度比较慢
# appendfsync always
appendfsync everysec
# appendfsync no
maxmemory 128mb
maxmemory-policy allkeys-lru

重启:

systemctl restart redis-server

查看:

systemctl status redis-server

查看监听:

ss -ntl | grep 6379

应为:

127.0.0.1:6379

三、 Another Redis Desktop Manager SSH Tunnel连接更安全

Another Redis Desktop Manager - New Connection:

Host: 127.0.0.1
Port: 6379
Password: redis密码

Another Redis Desktop Manager -SSH Tunnel:

SSH隧道: 勾选
Host: 服务器IP
Port: 22
Username: root
Password: 云服务器root密码

更多推荐