Centos7 Redis 安装


今天在一台干净的服务器上,安装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) "
 指纹       : 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) "
 指纹       : 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
展开阅读全文

页面更新:2024-04-14

标签:下载量   密钥   软件包   概要   用量   指纹   端口   插件   加载   大小   错误   密码   事务   关系   科技   信息

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top