- YUM 添加epel 源
yum install epel-release
- 安装 redis
yum install redis
- 配置 redis
vim /etc/redis.conf
找到redis.conf 并修改 daemonize no(第128行) 为 daemonize yes
- 开启客户端要确保服务端启动
redis-server /etc/redis.conf
使用这种方式启动时,需使用kill -9 结束进程
- 查看版本
redis-server -v
- 查看日志
tail -f /var/log/redis/redis.log
- 测试启动
redis-cli ping
返回PONG,说明启动成功
- 设置为开机启动
systemctl enable redis.service
- 关闭开启启动
systemctl disable redis.service
- 设置访问密码
vim /etc/redis.conf
找到 requirepass 所在行,复制并设置密码
- 允许远程访问
vim /etc/redis.conf
1、protected-mode yes 修改为 protected-mode no
2、bind 127.0.0.1 注释掉
3、关闭防火墙或开放 6379 端口
- 第二种启停命令
systemctl start redis.service
systemctl restart redis.service
systemctl stop redis.service