RedHat版的linux安装yum源及redis

一、前言

  最近正在学习redis,但是在安装redis的时候遇到很多坎,在此记录一下。

  硬件环境:我用 VMware Workstation Pro 12 安装 Red Hat Enterprise Linux 7  

  终端工具:SecureCRT 5

  软件版本:redis-3.0.0.tar.gz

二、遇到的问题及解决

  当进入解压(tar -zxvf *)后的 redis-3.0.0,执行 make 编译命令时,提示 gcc 未安装。所以开始着手安装 gcc ,通过搜索网上相关资料,

尝试用 yum install gcc 进行安装,但提示我未找到相关的源。如下

[root@localhost ~]# yum install gcc
已加载插件:product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
没有已启用的源。

  后来通过该资料(地址:http://itgeeker.net/centos-7-epel-china-mirror-repository/)找到了解决办法。

  1、安装源(上海交大源)。如下:

[root@localhost ~]# rpm -Uvh http://ftp.sjtu.edu.cn/fedora/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
获取http://ftp.sjtu.edu.cn/fedora/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
警告:/var/tmp/rpm-tmp.wfieOF: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:epel-release-7-5 ################################# [100%]

  2、配置EPEL源(EPEL 是yum的一个软件源,里面包含了许多基本源里没有的软件。)

#删除自带的文件,再新建
[root@localhost ~]# rm /etc/yum.repos.d/epel.repo
rm:是否删除普通文件 "/etc/yum.repos.d/epel.repo"?y
[root@localhost ~]# vi /etc/yum.repos.d/epel.repo
##在新建的文件中添加以下配置信息
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://ftp.sjtu.edu.cn/fedora/epel/7/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=http://ftp.sjtu.edu.cn/fedora/epel/7/$basearch/debug
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1 [epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=http://ftp.sjtu.edu.cn/fedora/epel/7/SRPMS
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
##清空自带的文件
[root@localhost ~]# true > /etc/yum.repos.d/epel-testing.repo
[root@localhost ~]# vi /etc/yum.repos.d/epel-testing.repo
#在该文件中复制以下内容
[epel-testing]
name=Extra Packages for Enterprise Linux 7 - Testing - $basearch
baseurl=http://ftp.sjtu.edu.cn/fedora/epel/testing/7/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-epel7&arch=$basearch
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-testing-debuginfo]
name=Extra Packages for Enterprise Linux 7 - Testing - $basearch - Debug
baseurl=http://ftp.sjtu.edu.cn/fedora/epel/testing/7/$basearch/debug
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1 [epel-testing-source]
name=Extra Packages for Enterprise Linux 7 - Testing - $basearch - Source
baseurl=http://ftp.sjtu.edu.cn/fedora/epel/testing/7/SRPMS
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

  以上的操作,就已经替换好上海交大源的文件。

  (1)检查源是否已添加

[root@localhost ~]# yum repolist

  (2)运行命令生成缓存(yum makecache就是把服务器的包信息下载到本地电脑缓存起来)

[root@localhost ~]# yum clean all && yum makecache

  3、通过博文(地址: http://blog.chinaunix.net/uid-20729583-id-2972852.html)的启发,配置CentOS

    (1)配置yum更新源    

#创建/etc/yum.repos.d/CentOS-Base.repo文件,定义yum更新源,这里使用的是上海交大的CentOS更新源     
[root@linux-a ~]# vi /etc/yum.repos.d/CentOS-Base.repo
#在新建的文件中添加以下配置信息
[base]
name=CentOS-7-Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever7&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://ftp.sjtu.edu.cn/centos/7/os/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos7
#released updates
[update]
name=CentOS-7-Updates
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/7/updates/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos7
#packages used/produced in the build but not released
[addons]
name=CentOS-7-Addons
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons
#baseurl=http://ftp.sjtu.edu.cn/centos/7/addons/$basearch/
baseurl=http://ftp.sjtu.edu.cn/centos/7/os/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos7
#additional packages that may be useful
[extras]
name=CentOS-7-Extras
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras
baseurl=http://ftp.sjtu.edu.cn/centos/7/extras/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7-Plus
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/7/centosplus/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos7
#contrib - packages by Centos Users
[contrib]
name=CentOS-7-Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/7/contrib/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos7

    (2)导入key配置yum

[root@localhost ~]#  rpm --import http://ftp.sjtu.edu.cn/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7

  注意:

  <1>如果有高版本的linux,比如linux8,只要将CentOS-Base.repo和key中的版本号替换成8即可;

  <2>如果遇到 http://mirrors.sohu.com/centos/7/addons/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found 错误,

可以根据给出的链接 baseurl=http://ftp.sjtu.edu.cn/centos/7/addons/$basearch/ 排查,找到 repomd.xml 正确的路径。经查知,正确路径是:

baseurl=http://ftp.sjtu.edu.cn/centos/7/os/$basearch/

  综上操作,已完成yum的配置安装,然后通过yum进行安装gcc。

  4、安装gcc

[root@localhost ~]# yum install gcc

  5、安装redis

#在 redis-3.0.0目录下执行make命令
[root@localhost redis-3.0.0]# make
#进入src目录
[root@localhost redis-3.0.0]# cd src
[root@localhost src]# make install

  至此,redis才安装成功。

  

上一篇:JAVA类与类之间的全部关系简述+代码详解


下一篇:代码详解:TensorFlow Core带你探索深度神经网络“黑匣子”