day20-yum精讲

一、yum源概述

㈠ yum源的作用

==软件包管理器==,类似360的软件管家

㈡ yum源的优点

能够==解决软件包之间的依赖关系==,提高运维人员的工作效率。

㈢ yum源的分类

1、本地yum源

yum仓库在==本地==(系统光盘/镜像文件)

2、网络yum源

yum仓库不在本地,在==远程==服务器

二、yum源配置(重点)

㈠ 本地yum源配置

1、本地需要有仓库
① 虚拟光驱装载镜像文件

 ② 将光盘挂载到本地目录

 

/mnt    操作系统默认的挂载点

mount [挂载选项] 需要挂载的设备  挂载点

手动挂载光盘到/mnt
lsblk        查看当前系统所有的设备文件


mount -o ro /dev/sr0 /mnt
注意:手动挂载后,系统重启需要再次手动挂载

# mount -o ro /dev/sr0 /mnt
选项说明:
-o :挂载方式,ro代表以readonly=>只读的方式进行挂载
              rw代表以read/write=>读写的方式进行挂载

 

③ 开机自动挂载

/etc/rc.local,属于系统的开机启动文件。系统启动后,会自动加载并执行这个文件

修改/etc/rc.local文件

/etc/rc.local    操作系统开机最后读取的一个文件

写入一行配置信息到该文件
echo "mount -o ro /dev/sr0 /mnt" >> /etc/rc.local


如下
[root@yuchao-linux01 ~]# echo "mount -o ro /dev/sr0 /mnt" >> /etc/rc.local
[root@yuchao-linux01 ~]# 
[root@yuchao-linux01 ~]# 
[root@yuchao-linux01 ~]# cat /etc/rc.local 
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
mount -o ro /dev/sr0 /mnt
[root@yuchao-linux01 ~]#
2、修改配置文件指向本地仓库
① 备份yum仓库文件
[root@yuchao-linux01 ~]# cd /etc/yum.repos.d/
[root@yuchao-linux01 yum.repos.d]# tar -zcf repo.tgz *.repo
[root@yuchao-linux01 yum.repos.d]# 
[root@yuchao-linux01 yum.repos.d]# ls
CentOS-Base.repo      CentOS-Debuginfo.repo  CentOS-Sources.repo  epel-testing.repo  rpmorphan-1.14-1.noarch.rpm
CentOS-Base.repo.bak  CentOS-fasttrack.repo  CentOS-Vault.repo    local.repo
CentOS-CR.repo        CentOS-Media.repo      epel.repo            repo.tgz
[root@yuchao-linux01 yum.repos.d]# 
[root@yuchao-linux01 yum.repos.d]# rm -rf *.repo
[root@yuchao-linux01 yum.repos.d]# 
[root@yuchao-linux01 yum.repos.d]# 
[root@yuchao-linux01 yum.repos.d]# ls
CentOS-Base.repo.bak  repo.tgz  rpmorphan-1.14-1.noarch.rpm
[root@yuchao-linux01 yum.repos.d]#
① 配置文件存放路径
[root@yuchao-linux01 ~]# 
[root@yuchao-linux01 ~]# ls /etc/yum.repos.d/ -d
/etc/yum.repos.d/
② 修改配置文件

[root@yuchao-linux01 ~]# ls /etc/yum.repos.d/ -d
/etc/yum.repos.d/
[root@yuchao-linux01 ~]# vim /etc/yum.repos.d/local.repo
[root@yuchao-linux01 ~]# 
[root@yuchao-linux01 ~]# 
[root@yuchao-linux01 ~]# cat  /etc/yum.repos.d/local.repo
[local]
name=local yum repo
baseurl=file:///mnt
enabled=1
gpgcheck=0

[root@yuchao-linux01 ~]#

 

 

看看系统给的repo语法是什么

说明:
baseurl=http://nginx.org/packages/centos/7/$basearch/
$basearch表示当前系统cpu架构,如果系统是32位会找32位软件包;如果64位会找64位软件包

 

③验证本地yum源
[root@yuchao-linux01 yum.repos.d]# 
[root@yuchao-linux01 yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Bad id for repo: root@yuchao-linux01 ~, byte = @ 4
Cleaning repos: local
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@yuchao-linux
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

激进的猴哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值