参考教程:
https://blog.csdn.net/houor/article/details/126672577
https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/install-redis-on-linux/
查看是否安装
redis-cli --version
Ubuntu 上安装
更新:
sudo apt update
sudo apt upgrade
sudo apt install redis-server
查看状态
systemctl status redis.service
$ systemctl status redis.service
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor pres>
Active: activating (start) since Sun 2025-02-23 10:49:45 UTC; 1min 14s ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Process: 211377 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exi>
Tasks: 0 (limit: 154141)
Memory: 484.0K
CGroup: /system.slice/redis-server.service
Feb 23 10:49:45 gitlab-server systemd[1]: Starting Advanced key-value store...
Feb 23 10:49:45 gitlab-server systemd[1]: redis-server.service: Can't open PID file>
macOS 上安装
brew install redis
查看运行状态
brew services info redis
%brew services info redis
redis (homebrew.mxcl.redis)
Running: ✔
Loaded: ✔
Schedulable: ✘
User: pc087
PID: 66794
运行
brew services start redis
停止
brew services stop redis
配置Redis远程设置
sudo nano /etc/redis/redis.conf
修改配置信息 :
# 注释掉绑定地址#bind 127.0.0.1,让Redis可远程访问
# bind 127.0.0.1 ::1
bind 0.0.0.0
#取消注释requirepass 启动密码认证,并设置访问密码
requirepass your-pass-word
# 以守护进程运行Redis
daemonize yes
开放端口:
sudo ufw allow 6379
配置完成后,保存并关闭文件。然后重启Redis:
systemctl restart redis-server
验证输入的是本机密码
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'redis-server.service'.
Authenticating as: xx
Password:
==== AUTHENTICATION COMPLETE ===
Job for redis-server.service failed because a timeout was exceeded.
See "systemctl status redis-server.service" and "journalctl -xe" for details
临时解决方法:重启系统
查看状态:
systemctl status redis-server.service
redis__210">停止 redis 服务
查看状态
sudo systemctl status redis
停止服务
sudo systemctl stop redis
禁用服务(可选)
sudo systemctl disable redis
再次检查端口占用
sudo netstat -tuln | grep 6379