配置yum源

1---创建挂载目录并挂载

[root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
devtmpfs                 908M     0  908M    0% /dev
tmpfs                    919M     0  919M    0% /dev/shm
tmpfs                    919M  8.6M  911M    1% /run
tmpfs                    919M     0  919M    0% /sys/fs/cgroup
/dev/mapper/centos-root   50G  1.6G   49G    4% /
/dev/sda1               1014M  150M  865M   15% /boot
/dev/mapper/centos-home  2.0T   33M  2.0T    1% /home
tmpfs                    184M     0  184M    0% /run/user/0
/dev/sr0                 4.5G  4.5G     0  100% /mnt/cdrom

2---永久挂载,开机挂载依旧存在

[root@localhost ~]# vim /etc/fstab
/dev/cdrom             /mnt/cdrom               iso9660 defaults        0 0

3---配置本地yun源

[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# ll
总用量 36
-rw-r--r--. 1 root root 1664 4月   8 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 4月   8 2020 CentOS-CR.repo
-rw-r--r--. 1 root root  649 4月   8 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 4月   8 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 4月   8 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 4月   8 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 7577 4月   8 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root  616 4月   8 2020 CentOS-x86_64-kernel.repo
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv *.repo bak/
[root@localhost yum.repos.d]# ll
总用量 0
drwxr-xr-x. 2 root root 220 12月 30 09:31 bak
[root@localhost yum.repos.d]# vi local.repo
[local]
name=local
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=0
[root@localhost yum.repos.d]# ll
总用量 4
drwxr-xr-x. 2 root root 220 12月 30 09:33 bak
-rw-r--r--. 1 root root  66 12月 30 09:33 local.repo
[root@localhost yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: local
[root@localhost yum.repos.d]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
local                                                                                                                                                                    | 3.6 kB  00:00:00     
(1/4): local/group_gz                                                                                                                                                    | 153 kB  00:00:00     
(2/4): local/filelists_db                                                                                                                                                | 3.3 MB  00:00:00     
(3/4): local/other_db                                                                                                                                                    | 1.3 MB  00:00:00     
(4/4): local/primary_db                                                                                                                                                  | 3.3 MB  00:00:00     
元数据缓存已建立
[root@localhost yum.repos.d]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
源标识                                                                                        源名称                                                                                       状态
local                                                                                         local                                                                                        4,071
repolist: 4,071

4---安装wget(可以直接yum安装 )

[root@localhost ~]# cd /mnt/cdrom/
[root@localhost cdrom]# ll
[root@localhost cdrom]# cd Packages/
[root@localhost Packages]# ls | grep wget
wget-1.14-18.el7_6.1.x86_64.rpm
[root@localhost Packages]# rpm -ivh wget-1.14-18.el7_6.1.x86_64.rpm
警告:wget-1.14-18.el7_6.1.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:wget-1.14-18.el7_6.1             ################################# [100%]

5---下载阿里yum源和阿里epel源(便于某些依赖包直接下载)

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@localhost ~]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base epel extras local updates
Cleaning up list of fastest mirrors
[root@localhost ~]# yum makecache
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
总用量 12
drwxr-xr-x. 2 root root  220 12月 30 09:33 bak
-rw-r--r--. 1 root root 2523 12月 26 2020 CentOS-Base.repo
-rw-r--r--. 1 root root  664 12月 26 2020 epel.repo
-rw-r--r--. 1 root root   66 12月 30 09:33 local.repo
[root@localhost ~]# yum repolist
源标识                                                                     源名称                                                                                                    状态
base/7/x86_64                                                              CentOS-7 - Base - mirrors.aliyun.com                                                                      4,734+5,338
epel/x86_64                                                                Extra Packages for Enterprise Linux 7 - x86_64                                                              13,691+12
extras/7/x86_64                                                            CentOS-7 - Extras - mirrors.aliyun.com                                                                         483+17
local                                                                      local                                                                                                           4,071
updates/7/x86_64                                                           CentOS-7 - Updates - mirrors.aliyun.com                                                                   1,155+2,087
repolist: 24,134

6---配置优先级

//有epel源的情况下安装插件
[root@localhost ~]# yum -y install yum-plugin-priorities.noarch
//编辑本地源,设置优先级
[root@localhost ~]# vi /etc/yum.repos.d/local.repo 
[local]
name=local
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=0
priority=1              (级别1-99,1是最高,优先本地源下载,其他源自动寻找下载)
//清除缓存并建立缓存
[root@localhost ~]# yum clean all
已加载插件:fastestmirror, priorities
正在清理软件源: base epel extras local updates
Cleaning up list of fastest mirrors
[root@localhost ~]# yum makecache
//验证源下载
[root@localhost ~]# yum -y install elinks
 elinks                            x86_64                                  
 0.12-0.37.pre6.el7.0.1            local (从local源下载)
[root@localhost ~]# yum -y install sl
 sl                                x86_64                                        
 5.02-1.el7                        epel (local源没有会自动从epel源下载)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值