CentOS7 下 yum 安装 Redis

1. 安装 Redis 服务

1> 检查是否有redis yum 源

shell> yum install redis

2> 下载fedora的epel仓库

shell> yum install epel-release

3> 安装redis数据库

shell> yum install redis

2.启动/关闭/重启 Redis 服务

1> 启动 Redis 服务

shell> systemctl start redis.service

2> 关闭 Redis 服务

shell> systemctl stop redis.service

3> 重启 Redis 服务

shell> systemctl restart redis.service

3.设置redis开机启动

shell> systemctl enable redis.service

4.设置redis密码

1> 打开配置文件

shell> vi /etc/redis.conf

2> 找到 “# requirepass foobared”,去掉前面的 “#”,并把 “foobared” 改成你的密码。

3> 保存文件,重启服务

shell> systemctl restart redis.service

5.使用 redis desktop manager 远程连接

1> 下载地址:https://github.com/MicrosoftArchive/redis/releases

2> 如果长时间连接不上,可能有两种可能性

a> bind了127.0.01:只允许在本机连接redis
b> protected-mode设置了yes(使用redis desktop manager工具需要配置,其余不用)

解决方案:

i> 打开redis配置文件
shell> vi /etc/redis.conf
ii> 修改如下内容:

找到 bind 127.0.0.1 将其注释
找到 protected-mode yes 将其改为 protected-mode no

iii > 保存文件,重启服
shell> systemctl restart redis.service

3> 开放 6379 端口 :没有开放该端口无法进行远程链接

shell> firewall-cmd --zone=public --add-port=6379/tcp --permanent
shell> firewall-cmd --reload

参考链接:

https://www.cnblogs.com/rslai/p/8249812.html

https://www.jianshu.com/p/ebda253a8daa

原创文章 9 获赞 19 访问量 3318

猜你喜欢

转载自blog.csdn.net/qq_29335705/article/details/84644278