Linux基础学习-RHEL7.4之YUM更换CentOS源

1.配置YUM本地源

1.挂载镜像

[[email protected] ~]# mount /dev/cdrom /mnt

2.查看是否挂载成功

[[email protected] ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        49G  1.3G   48G   3% /
devtmpfs        479M     0  479M   0% /dev
tmpfs           489M     0  489M   0% /dev/shm
tmpfs           489M  6.6M  482M   2% /run
tmpfs           489M     0  489M   0% /sys/fs/cgroup
/dev/sda1       497M  112M  385M  23% /boot
tmpfs            98M     0   98M   0% /run/user/0
/dev/sr0        3.8G  3.8G     0 100% /mnt

3.备份原来的仓库

[[email protected] ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d_bak
[[email protected] ~]# rm -f /etc/yum.repos.d/*

4.创建新的repo配置文件

[[email protected] ~]# vi /etc/yum.repos.d/dvd.repo

[dvd]
name=install dvd
baseurl=file:///mnt
enabled=1
gpgcheck=0

5.刷新repos生成缓存

[[email protected] ~]# yum makecache
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
dvd                                                                            | 4.1 kB  00:00:00
(1/5): dvd/group_gz                                                            | 137 kB  00:00:00
(2/5): dvd/filelists_db                                                        | 3.4 MB  00:00:00
(3/5): dvd/primary_db                                                          | 4.0 MB  00:00:00
(4/5): dvd/other_db                                                            | 1.5 MB  00:00:00
(5/5): dvd/productid                                                           | 1.6 kB  00:00:00
Metadata Cache Created

2.使用CentOS源

1.卸载红帽yum

[[email protected] Packages]# rpm -e $(rpm -qa | grep yum) --nodeps
[[email protected] Packages]# echo $?
0

2.删除yum相关文件

[[email protected] Packages]# rm -rf /etc/yum.conf
[[email protected] Packages]# rm -rf /etc/yum.repos.d/*
[[email protected] Packages]# rm -rf /var/cache/yum

3.下载CentOS相关yum组件

wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-45.el7.noarch.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm
[[email protected] ~]# rpm -ivh *.rpm
warning: python-chardet-2.2.1-1.el7_1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 14%]
   2:yum-plugin-fastestmirror-1.1.31-4################################# [ 29%]
   3:yum-3.4.3-158.el7.centos         ################################# [ 43%]
   4:python-chardet-2.2.1-1.el7_1     ################################# [ 57%]
   5:python-kitchen-1.1.1-5.el7       ################################# [ 71%]
   6:yum-utils-1.1.31-45.el7          ################################# [ 86%]
   7:yum-updateonboot-1.1.31-45.el7   ################################# [100%]
[[email protected] ~]# 

4.创建新的repo文件

[base]
name=CentOS-7 - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-7 - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-7 - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

5.使用yum makecache刷新生成缓存

[[email protected] ~]# yum makecache
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
base                                                                           | 3.6 kB  00:00:00
extras                                                                         | 3.4 kB  00:00:00
updates                                                                        | 3.4 kB  00:00:00
(1/12): base/x86_64/group_gz                                                   | 166 kB  00:00:06
(2/12): base/x86_64/primary_db                                                 | 5.9 MB  00:00:02
(3/12): base/x86_64/filelists_db                                               | 6.9 MB  00:00:08
(4/12): base/x86_64/other_db                                                   | 2.5 MB  00:00:01
(5/12): extras/x86_64/prestodelta                                              |  68 kB  00:00:06
(6/12): extras/x86_64/primary_db                                               | 173 kB  00:00:00
(7/12): extras/x86_64/other_db                                                 | 110 kB  00:00:00
(8/12): extras/x86_64/filelists_db                                             | 588 kB  00:00:06
(9/12): updates/x86_64/prestodelta                                             | 409 kB  00:00:06
(10/12): updates/x86_64/filelists_db                                           | 2.4 MB  00:00:07
(11/12): updates/x86_64/other_db                                               | 381 kB  00:00:00
(12/12): updates/x86_64/primary_db                                             | 4.3 MB  00:00:01
Metadata Cache Created

6.epel扩展源

首先从CentOS Extras这个源(tuna也有镜像)里安装epel-release:

yum install epel-release -y

编辑epel.repo

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/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=https://mirrors.tuna.tsinghua.edu.cn/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=https://mirrors.tuna.tsinghua.edu.cn/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

这些做完以后要删除/etc/pki/rpm-gpg/的文件

把epel中新的文件下载放入其中

[[email protected] ~]# ls /etc/pki/rpm-gpg/
RPM-GPG-KEY-EPEL-7
RPM-GPG-KEY-CentOS-7

原文地址:https://www.cnblogs.com/qdlinux/p/9457942.html

时间: 2024-08-29 20:16:01

Linux基础学习-RHEL7.4之YUM更换CentOS源的相关文章

linux基础学习笔记——操作大全

作者:liaoyi 更新时间:2014-6-2 ****************基本操作***************** 关机 shutdown -h now    root用户               init 0              root用户halt      root+一般用户poweroff 重启shutdown -r now    root用户init6     root用户reboot            root+一般用户 注意:1.shutdown 比较灵活,可

Linux基础学习-crond系统计划任务

系统计划任务 大部分系统管理工作都是通过定期自动执行某个脚本来完成的,那么如何定期执行某个脚本,从而实现运维的自动化,这就要借助Linux的cron功能了. 计划任务分为一次性计划任务和周期性计划任务. 一次性计划任务 每晚11店30分开启网站服务. 周期性计划任务 每周一的凌晨3点30分把/var/www/html目录打包备份为backup.tar.gz 顾名思义,一次性计划任务只执行一次,一般用于满足临时的工作需求,可以使用at命令实现. 如果你的Linux没有此命令可以使用yum inst

c/c++unix/linux基础学习笔记-常用命令和vi的使用

linux 基本命令的使用-命令在ubuntu下面执行,有些命令通用其他linux,有些不通用. 多条命令间用;号隔开,回车后可以一起执行. clear-前屏,pwd显示当前目录,cd跳转目录. sudo [命令]  -ubuntu 下以管理员身份运行命令. 一般情况下,运行当前目录下的程序,要用 ./文件名 执行. 查看当前shell名称:ps 进入另外一个shell,直接输入shell名称:ksh/tcsh/sh/bash,退出一个shell用:exit. 切换shell命令,如:exec

linux基础学习【4】

系统进程 一.什么是进程 进程 : 一个正在运行中的程序 程序被触发后,执行者的权限与属性,程序的程序码与所需数据等都会被载入内存中,操作系统会给予这个内存内的单元一个识别码 (PID). 二.查看进程 1.图形方式查看 命令:`gnome-system-monitor` 2.进程查看命令 命令:`ps` ps -A/-e 显示所有(包括不同终端不同用户)进程(PID,TTY,TIME,CMD) ps -a 当前环境中运行的进程,不包含环境信息(PID,TTY,TIME,CMD) ps -u (

linux基础学习【5】

sshd服务,服务管理及文件传输 一.控制服务 1.什么是服务 2.用什么控制服务 系统初始化进程可以进行相应的控制 3.当前系统初始化进程是什么 systemd 系统初始化进程 pstree 显示系统中的进程树 进程树 4.系统控制命令 ssh(client)客户端---->sshd(server)服务器 命令:`systemctl` systemctl status sshd 查看sshd服务的状态inactive(不可用)/active(可用) systemctl start sshd 开

linux基础学习随笔【根本没有排序哈】

直接整:init 3 5 6 0;init 3代表切换到字符界面,5代表切换到图形界面:6表示重启,等同于reboot:0表示关机=poweroff:改主机名:hostnamectl set-hostname centos7.localdomain;[记不住,TAB键补全]查看操作系统linux版本:cat /etc/centos-release;或者通过安装lsb_release -a ;查看内核版本: uname -rlscpu 查看CPU使用情况:lsblk查看硬盘:free - h查看内

Linux 6.4 设置yum 为centOS源

一. 删除Redhat 自带的yum // root 用户执行 rpm -aq|grep yum|xargs rpm -e --nodeps 二 .下载CentOS 的 yum 安装文件 wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum

一篇文章带你入门Linux——马哥Linux基础学习笔记

1.课程体系: 中级: 初级:系统基础 中级:系统管理.服务安全及服务管理.Shell脚本: 高级: MySQL数据库: cache & storage 集群: Cluster lb: 4layer 7layer ha: 分布式: zookeeper 分布式文件系统 虚拟化技术: xen kvm Openstack:IAAS云: 运维工具: ansible puppet(ruby), saltstack(python) 监控工具: zabbix 大数据处理: hadoop spark, stor

linux基础学习笔记

linux 命令学习linux注意事项:1 linux严格区分大小写,windows不区分大小写,linux下所有命令都是小写的,linux系统下文件名区分大小写,windows下文件名不区分大小写. 2 linux中所有内容都是以文件形式保存,包括硬盘.如果没有写到文件中,写到内存中,那么重启后则失效.操作硬件时都是针对文件名操作. 3 linux不靠扩展名区分文件类型.靠文件权限区分文件.但操作时往往加上一些特定的“扩展名”来帮助管理员更好的识别文件,linux并不要求加上扩展名. 4 li