Redis安装&配置&远程连接

1. yum 安装 redis:

直接使用命令,将 redis 安装到 linux 服务器中:

yum -y install redis

2. 启动 redis:

在 xshell 里,可以使用下面命令,以后台方式启动 redis:

[root@VM-8-17-centos /]# redis-server /etc/redis.conf &

3. 操作 redis:

先启动 redis 客户端:

[root@VM-8-17-centos /]# redis-cli

启动后就可以根据实际需求操作了。

3.1 查看内置信息:

使用以下命令:

127.0.0.1:6379> info

注意:在之后如果给 redis 设置了密码,就不能直接使用 info,而是要先进行身份验证:

127.0.0.1:6379> auth "yourpassword"
OK
127.0.0.1:6379> info

4. 远程连接:

以上都是本地操作,远程连接需要更改 redis.conf 配置文件部分信息:

4.1 步骤:

        进入 /etc/ 目录,找到 redis.conf 文件,打开,根据需要进行修改:

        远程连接必须修改的选项:

(1)将 redis.conf 中的 “bind 127.0.0.1”注释掉;

 (2)将 redis.conf 中的“protected-mode yes” 改为“protected-mode no:

        目的是更改受保护模式,否则无法远程连接

 (3)先关闭 redis 服务

redis-cli shutdown

        再启动 redis 服务

redis-server /etc/redis.conf

4.3  释放Redis端口:

配置设置好后,还要保证 redis 端口可用,并且防止云服务器的防火墙拦截:

登录自己的云服务器,添加一个自定义规则:

4.3 最后一步,连接:

        使用 redis 可视化工具 Another Redis Desktop Manager:

 连接成功:

猜你喜欢

转载自blog.csdn.net/m0_65190367/article/details/132237600
今日推荐