2022 年超详细步骤讲解 CentOS 7 安装Redis 。解决Redis Desktop Manager 图形化工具连接失败解决 ;connection failed处理。开机自启Redis

本文涉及的产品
云原生内存数据库 Tair,内存型 2GB
云数据库 Redis 版,标准版 2GB
推荐场景:
搭建游戏排行榜
简介: 这篇文章提供了在CentOS 7上安装Redis的详细步骤,包括上传Redis安装包、解压安装、编译、安装、备份配置文件、修改配置以支持后台运行和设置密码、启动Redis服务、使用客户端连接Redis、关闭Redis服务、解决Redis Desktop Manager图形化工具连接失败的问题、设置Redis开机自启动,以及Redis服务的启动和停止命令。

1、将redis安装包上传到虚拟机对应位置

在这里插入图片描述

创建redis目录、直接就安装在这里

在这里插入图片描述

2、解压安装包

tar -zxvf redis-6.2.6.tar.gz

在这里插入图片描述

3、删除安装包

rm -f redis-6.2.6.tar.gz

在这里插入图片描述

4、在redis 目录下执行make命令(编译好)

在这里插入图片描述

5、执行make install

make install

在这里插入图片描述

6、备份redis.config

复制备份的时候、确保在对应的文件目录下。

cp redis.conf /usr/local/beifen/

在这里插入图片描述

7、修改redis.conf配置文件

后台启动设置daemonize no改成yes
在这里插入图片描述

8、设置redis密码

在这里插入图片描述

9、redis启动

在放置redis.conf的文件夹下启动

redis-server redis.conf

查看启动是否成功

ps -ef | grep redis

在这里插入图片描述

10、客户端访问、输入密码(如果设置了)

redis-cli
AUTH 密码

在这里插入图片描述

11、简单使用

在这里插入图片描述

12、关闭Redis

单实例关闭:redis-cli shutdown
或者进入终端:shutdown

在这里插入图片描述

在这里插入图片描述

13、可视化工具连接

在这里插入图片描述

13.1 连接失败

  • 1 、将bind 127.0.0.1 注释掉
  • 2、将protedted-mode 改为no

在这里插入图片描述

在这里插入图片描述

13.2 连接成功

在这里插入图片描述

14 如何设置开机自启

14.1 在/etc目录下新建redis目录

cd /etc/
mkdir redis

在这里插入图片描述

14.2 复制配置文件

将redis.conf文件复制到/etc/redis目录下,并重命名为6379.conf

cp redis.conf /etc/redis/6379.conf

在这里插入图片描述

14.3 复制启动脚本

cp redis_init_script /etc/init.d/redis
vim /etc/init.d/redis

在这里插入图片描述
通过查看启动脚本,确定各个路径是否正确
在这里插入图片描述

14.4 执行自启命令

cd /etc/init.d/
chkconfig redis on

在这里插入图片描述

14.5 启动Redis

# 打开redis命令:
service redis start

# 关闭redis命令:
service redis stop

15 重启虚拟机

成功启动redis
在这里插入图片描述

在这里插入图片描述

16 redis启动的多种方式

16.1 设置开机自启后

service redis start

在这里插入图片描述

16.2 在安装目录下下启动

必须在安装的redis目录下执行才可以

redis-server redis.conf

在这里插入图片描述

17 后语

前一段时间最怕在虚拟机上操作的我、已经可以熟练的穿梭往来

开机自启参考:开机自启动

相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
相关文章
|
17天前
|
缓存 NoSQL Redis
【Azure Redis 缓存】Redission客户端连接Azure:客户端出现 Unable to send PING command over channel
【Azure Redis 缓存】Redission客户端连接Azure:客户端出现 Unable to send PING command over channel
|
18天前
|
缓存 NoSQL Redis
【Azure Redis 缓存】Redis 连接失败
【Azure Redis 缓存】Redis 连接失败
|
17天前
|
缓存 NoSQL 网络协议
【Azure Redis 缓存】Lettuce 连接到Azure Redis服务,出现15分钟Timeout问题
【Azure Redis 缓存】Lettuce 连接到Azure Redis服务,出现15分钟Timeout问题
【Azure Redis 缓存】Lettuce 连接到Azure Redis服务,出现15分钟Timeout问题
|
17天前
|
NoSQL Unix 网络安全
【Azure Cache for Redis】Python Django-Redis连接Azure Redis服务遇上(104, 'Connection reset by peer')
【Azure Cache for Redis】Python Django-Redis连接Azure Redis服务遇上(104, 'Connection reset by peer')
【Azure Cache for Redis】Python Django-Redis连接Azure Redis服务遇上(104, 'Connection reset by peer')
|
17天前
|
缓存 NoSQL Java
【Azure Redis 缓存】示例使用 redisson-spring-boot-starter 连接/使用 Azure Redis 服务
【Azure Redis 缓存】示例使用 redisson-spring-boot-starter 连接/使用 Azure Redis 服务
|
17天前
|
NoSQL 网络协议 Redis
【Azure Redis】AKS中使用Lettuce连接Redis Cache出现 timed out 问题的解决思路
【Azure Redis】AKS中使用Lettuce连接Redis Cache出现 timed out 问题的解决思路
【Azure Redis】AKS中使用Lettuce连接Redis Cache出现 timed out 问题的解决思路
|
8天前
|
NoSQL Linux Redis
Linux Redis 服务设置开机自启动
【9月更文挑战第2天】在 Linux 系统中,可使用两种方法设置 Redis 开机自启动:一是通过创建 `redis.service` 文件并利用 systemd 进行管理,包括定义服务参数和启动脚本;二是编辑 `/etc/rc.local` 文件,在其中添加启动命令。推荐使用 systemd 方法,因为它更符合现代 Linux 系统的设计理念。设置完成后,可通过 `sudo systemctl status redis.service` 检查服务状态。
|
15天前
|
NoSQL 算法 Java
诡异!Redis Proxy RT上升后连接倾斜
本文细致地描述了关于Redis Proxy RT上升后连接倾斜问题的排查过程和根本原因,最后给出了优化方案。
|
18天前
|
缓存 NoSQL 网络协议
【Azure Redis 缓存】Redisson 连接 Azure Redis出现间歇性 java.net.UnknownHostException 异常
【Azure Redis 缓存】Redisson 连接 Azure Redis出现间歇性 java.net.UnknownHostException 异常
|
17天前
|
Kubernetes NoSQL Redis
【Azure Redis】部署在AKS中的应用连接Redis时候出现Unable to connect to Redis server
【Azure Redis】部署在AKS中的应用连接Redis时候出现Unable to connect to Redis server
【Azure Redis】部署在AKS中的应用连接Redis时候出现Unable to connect to Redis server