百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术教程 > 正文

Centos7 Redis 安装

mhr18 2024-11-26 12:05 38 浏览 0 评论


今天在一台干净的服务器上,安装redis, 一般大家都知道 yum install redis 这种方式。

但是这样直接通过yum 安装,会提示无依赖包

[root@localhost test]# yum install redis
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
base                                                                                                                                      | 3.6 kB  00:00:00     
extras                                                                                                                                    | 2.9 kB  00:00:00     
nginx                                                                                                                                     | 2.9 kB  00:00:00     
updates                                                                                                                                   | 2.9 kB  00:00:00     
没有可用软件包 redis。
错误:无须任何处理


首先检查已有的镜像,并备份已有的镜像

[root@localhost wyz]# ll /etc/yum.repos.d/
总用量 36
-rw-r--r--. 1 root root 1664 11月 23 2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 11月 23 2018 CentOS-CR.repo
-rw-r--r--. 1 root root  649 11月 23 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 11月 23 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 11月 23 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 11月 23 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 11月 23 2018 CentOS-Vault.repo
-rw-r--r--. 1 root root  113 7月  15 2014 nginx.repo

备份已有的镜像,并切换阿里云,然后重新下载,接着安装redis,结果还是没有

-rw-r--r--. 1 root root  113 7月  15 2014 nginx.repo
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2021-09-30 10:21:35--  http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 61.162.46.208, 27.221.122.241, 27.221.122.239, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|61.162.46.208|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

100%[=======================================================================================================================>] 2,523       --.-K/s 用时 0s      

2021-09-30 10:21:35 (77.8 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])

[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# ll
总用量 40
-rw-r--r--. 1 root root 2523 12月 26 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1664 11月 23 2018 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 11月 23 2018 CentOS-CR.repo
-rw-r--r--. 1 root root  649 11月 23 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 11月 23 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 11月 23 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 11月 23 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 11月 23 2018 CentOS-Vault.repo
-rw-r--r--. 1 root root  113 7月  15 2014 nginx.repo
[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# yum install redis
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
没有可用软件包 redis。
错误:无须任何处理


既然镜像中没有这些安装包,那我们需要从fedora的epel仓库。

yum install epel-relase
[root@localhost yum.repos.d]# yum install redis
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
没有可用软件包 redis。
错误:无须任何处理
[root@localhost yum.repos.d]# yum install epel-release
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-11 将被 安装
--> 解决依赖关系完成

依赖关系解决

=================================================================================================================================================================
 Package                                    架构                                 版本                                 源                                    大小
=================================================================================================================================================================
正在安装:
 epel-release                               noarch                               7-11                                 extras                                15 k

事务概要
=================================================================================================================================================================
安装  1 软件包

总下载量:15 k
安装大小:24 k
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
epel-release-7-11.noarch.rpm 的公钥尚未安装
epel-release-7-11.noarch.rpm                                                                                                              |  15 kB  00:00:00     
从 http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
 用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 来自       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : epel-release-7-11.noarch                                                                                                                     1/1 
  验证中      : epel-release-7-11.noarch                                                                                                                     1/1 

已安装:
  epel-release.noarch 0:7-11                                                                                                                                     

完毕!
[root@localhost yum.repos.d]# 

查看已有的

[root@localhost yum.repos.d]# yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                                                      | 5.8 kB  00:00:00     
 * base: mirrors.aliyun.com
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
epel                                                                                                                                      | 4.7 kB  00:00:00     
(1/3): epel/x86_64/group_gz                                                                                                               |  96 kB  00:00:00     
(2/3): epel/x86_64/updateinfo                                                                                                             | 1.0 MB  00:00:00     
(3/3): epel/x86_64/primary_db                                                                                                             | 7.0 MB  00:00:00     
源标识                                                        源名称                                                                                       状态
base/7/x86_64                                                 CentOS-7 - Base - mirrors.aliyun.com                                                         10,072
*epel/x86_64                                                  Extra Packages for Enterprise Linux 7 - x86_64                                               13,674
extras/7/x86_64                                               CentOS-7 - Extras - mirrors.aliyun.com                                                          500
nginx/x86_64                                                  nginx repo                                                                                      242
updates/7/x86_64                                              CentOS-7 - Updates - mirrors.aliyun.com                                                       2,751
repolist: 27,239
[root@localhost yum.repos.d]# 


装redis, 开始造

[root@localhost yum.repos.d]# yum install redis
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 redis.x86_64.0.3.2.12-2.el7 将被 安装
--> 正在处理依赖关系 libjemalloc.so.1()(64bit),它被软件包 redis-3.2.12-2.el7.x86_64 需要
--> 正在检查事务
---> 软件包 jemalloc.x86_64.0.3.6.0-1.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=================================================================================================================================================================
 Package                                架构                                 版本                                       源                                  大小
=================================================================================================================================================================
正在安装:
 redis                                  x86_64                               3.2.12-2.el7                               epel                               544 k
为依赖而安装:
 jemalloc                               x86_64                               3.6.0-1.el7                                epel                               105 k

事务概要
=================================================================================================================================================================
安装  1 软件包 (+1 依赖软件包)

总下载量:648 k
安装大小:1.7 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/epel/packages/jemalloc-3.6.0-1.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
jemalloc-3.6.0-1.el7.x86_64.rpm 的公钥尚未安装
(1/2): jemalloc-3.6.0-1.el7.x86_64.rpm                                                                                                    | 105 kB  00:00:00     
(2/2): redis-3.2.12-2.el7.x86_64.rpm                                                                                                      | 544 kB  00:00:00     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                             1.4 MB/s | 648 kB  00:00:00     
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 检索密钥
导入 GPG key 0x352C64E5:
 用户ID     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 指纹       : 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 软件包     : epel-release-7-11.noarch (@extras)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : jemalloc-3.6.0-1.el7.x86_64                                                                                                                  1/2 
  正在安装    : redis-3.2.12-2.el7.x86_64                                                                                                                    2/2 
  验证中      : redis-3.2.12-2.el7.x86_64                                                                                                                    1/2 
  验证中      : jemalloc-3.6.0-1.el7.x86_64                                                                                                                  2/2 

已安装:
  redis.x86_64 0:3.2.12-2.el7                                                                                                                                    

作为依赖被安装:
  jemalloc.x86_64 0:3.6.0-1.el7                                                                                                                                  

完毕!


启动Redis

[root@localhost yum.repos.d]# service redis start
Redirecting to /bin/systemctl start redis.service

或者
# 启动redis
systemctl start redis

# 开机自动启动Redis
systemctl enable redis

#停止redis
systemctl stop redis

#查看Redis运行状态
systemctl status redis


修改端口等信息

通过在/etc/redis.conf编辑, 比如修改port, 密码,可链接的ip的信息

port : 修改端口
requier: 设置密码
bind: 设置链接redis的IP
protec

修改完之后,如果继续使用 service start redis,redis并没有使用最新的配置文件,也就是说,你改动的,没有生效。所以需要指定配置文件启动

/usr/bin/redis-server  /etc/redis.conf &

客户端登录 redis-cli

默认情况下,

redis-cli 是无密码连接的6379端口,并登录,如果修改过配置信息

redis-cli -h 127.0.0.1 -p 7379  -a yourpasswd
或者
# redis-cli -p 7895  登录
# auth yourpasswd
登录

# keys *
  

退出

shutdown/quit

相关推荐

Java后端学习路线是什么?(java后端学到什么程度)

关于Java后端(SpringBoot为主)学习路线:一、Java基础阶段编程语言基础掌握基本数据类型(如int、double、char等)、变量、常量的定义和使用。理解运算符(算术、关...

Oracle与Nextcloud合作,推出主权云上的安全协作平台

据thefastmode网6月18日报道,Oracle与Nextcloud达成合作,将NextcloudHub引入Oracle云基础设施(OCI),为政府和企业客户提供安全协作平台。Nextclou...

主打的是回顾与展望?解读美国陆军250周年庆丨武装

2025年6月14日,美国陆军250周年庆(Armycelebrates250thbirthday)及阅兵活动在美国弗吉尼亚州阿灵顿县和华盛顿特区隆重举行,以纪念美国陆军成立(1775年6月14...

微服务不如单体架构?那是你不会用!

一、我为什么选择微服务架构?众所周知,单体应用程序,由于其种种不足,几乎不支持敏捷方法。如果你想为一个大型或复杂的业务创建一个软件项目,最好从微服务架构开始。微服务架构是一种灵活的架构,可以显著性地提...

从杯垫到塔罗牌,这些“非主流品类”才是真风口!

说到卖小玩意,想到的不是薄利多销就是卷价格战,毕竟这种模式在国内已经根深蒂固,但跨境电商给了每一位想要做小品类赚大钱的卖家一个机会,从杯垫到塔罗牌,越来越多人,开始靠一些你日常根本不会注意到的小玩意,...

Raid磁盘阵列更换磁盘时另一块盘离线恢复案例

Raid磁盘阵列更换磁盘时另一块盘离线恢复案例(v7000存储数据恢复)【故障描述】客户设备型号为IBMV7000存储,架构为AIX+oracle+V7000存储阵列柜,需要恢复的数据主要存放在阵列...

sql还有类型,大牛黑客必学,你也必须了解

上节课讲到sql注入的基础,上节课讲到的注入方法是联合查询,也称之为”显错注入”,当然,sql注入的方式不单单只是显错注入,还有不同的类型。根据数据库类型;一种是整形注入,一种是字符型注入。其实sql...

Java 性能优化(一)(java性能优化权威指南pdf)

优化目的可供程序利用的资源(内存、CPU时间、网络带宽等)是有限的,优化的目的就是让程序用尽可能少的资源完成预定的任务。优化通常包含两方面的内容:减小代码的体积;提高代码的运行效率。本文讨论的主要是如...

八种基本服务器类型,看这篇完全够了!

号主:老杨丨11年资深网络工程师,更多网工提升干货,请关注公众号:网络工程师俱乐部上午好,我的网工朋友。服务器作为网络基础设施的核心组件,其重要性不言而喻。无论是个人空间还是大型企业的数据中心,服务器...

Oracle 赢得云大单:一年 2100 亿元

2025年7月1日,Oracle透露,它赢得了一份年收入超过300亿美元(2149亿元人民币)的云合同。受此消息影响,Oracle股价一度上涨近9%,最终以上涨4%收盘。据向监...

聊聊 Java8 以后各个版本的新特性

某天在网上闲逛,突然看到有篇介绍Java11新特性的文章,顿时心里一惊,毕竟我对于Java的版本认识还停留在Java8上,而日常使用的语法和API还停留在Java7上。于是抽...

bug现场谜之进程为什么消失了?(程序出现bug是什么原因)

1.bug现场情况2021年11月,客户现场某业务系统挂掉,运维发现系统的进程没了,看日志也没有任何报错信息。运维重启服务,系统运行正常,第二天或者隔几天又挂掉...值得注意的现象:周五重启的服务,...

.NET周刊【6月第5期 2025-06-29】

字数5471,阅读大约需28分钟国内文章为什么说方法的参数最好不要超过4个?https://www.cnblogs.com/lmy5215006/p/18919081本文探讨了调用协定的概念,...

聊聊Java8之后的JDK升级内容(jdk8版本)

Java都已经更新到SE12了..公司用的还是Java8,觉得是应该了解下SE8之后的更新内容了,从网上搜集整理了一下核心的功能更新文章概览JDKJDK全称JavaDevelopmentKit...

Spring Boot 分布式事务实现简单得超乎想象

环境:SpringBoot2.7.18+Atomikos4.x+MySQL5.71.简介关于什么是分布式事务,本文不做介绍。有需要了解的自行查找相关的资料。本篇文章将基于SpringBoot...

取消回复欢迎 发表评论: