Oracle Linux7.8配置本地yum源:报错Loaded plugins: ulninfo

Linux配置本地yum源
一、使用iso镜像作为本地yum源

1、将oracle-linux-ol7.repo配置文件备份

cp /etc/yum.repos.d/oracle-linux-ol7.repo /etc/yum.repos.d/oracle-linux-ol7.repo.bak

#删除原文件:
rm -rf /etc/yum.repos.d/oracle-linux-ol7.repo

2、编辑yum源repo文件仅添加以下内容:

vi /etc/yum.repos.d/oracle-linux-ol7.repo

[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)	#yum源名,叫啥都行
baseurl=file:///mnt/cdrom							#挂载点路径
gpgcheck=0											#0表示关闭gpgkey检查,1是开启
enabled=1											#0表示关闭本地yum源,1是开启

3、创建挂载点:

mkdir /mnt/cdrom

4、挂载光盘镜像:

#服务器或虚拟机已经连接光盘镜像
mount /dev/sr0 /mnt/cdrom

#如果服务器或虚拟机没有连接光盘镜像,将镜像上传到机器,手动指定本地路径挂载镜像
#/u01/software/OracleLinux-R7-U8-Server-x86_64-dvd.iso为我的镜像所在目录
mount -o loop -t iso9660 /u01/software/OracleLinux-R7-U8-Server-x86_64-dvd.iso /mnt/cdrom

5、清除YUM缓存:

yum clean all
#Loaded plugins: ulninfo
#Cleaning repos: ol7_latest

yum makecache

6、更新yum源:

yum update 

7、列出所有可安装的安装包
报错:

yum list
#输出如下:
Loaded plugins: ulninfo
https://yum.oracle.com/repo/OracleLinux/OL7/UEKR5/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: yum.oracle.com; Unknown error"
Trying other mirror.


 One of the configured repositories failed (Latest Unbreakable Enterprise Kernel Release 5 for Oracle Linux 7Server (x86_64)),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=ol7_UEKR5 ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable ol7_UEKR5
        or
            subscription-manager repos --disable=ol7_UEKR5

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=ol7_UEKR5.skip_if_unavailable=true

failure: repodata/repomd.xml from ol7_UEKR5: [Errno 256] No more mirrors to try.
https://yum.oracle.com/repo/OracleLinux/OL7/UEKR5/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: yum.oracle.com; Unknown error"
# 

报错说是因为ol7_UEKR没有配置的问题

#查看/etc/yum.repos.d目录下
ll /etc/yum.repos.d
#输出如下
total 16
-rw-r--r--  1 root root  110 Apr 27 10:26 oracle-linux-ol7.repo
-rw-r--r--. 1 root root 3835 Apr 27 09:37 oracle-linux-ol7.repo.bak
-rw-r--r--. 1 root root 2587 Apr  2  2020 uek-ol7.repo				#uek.repo文件
-rw-r--r--. 1 root root  226 Apr  2  2020 virt-ol7.repo

该Oracle Linux版本在/etc/yum.repos.d目录下有一个uek-ol7.repo文件,这个文件并没有配置,也用不到,就改名做了一个备份

mv uek-ol7.repo uek-ol7.repo.bak

再次执行yum list

yum list
...
#输出如下:
zlib.i686                                                                                                1.2.7-18.el7                                                                               ol7_latest   
zlib-devel.i686                                                                                          1.2.7-18.el7                                                                               ol7_latest   
zlib-devel.x86_64                                                                                        1.2.7-18.el7                                                                               ol7_latest   
zsh.x86_64                                                                                               5.0.2-34.el7                                                                               ol7_latest   
zziplib.i686                                                                                             0.13.62-12.el7                                                                             ol7_latest   
zziplib.x86_64                                                                                           0.13.62-12.el7                                                                             ol7_latest   
#
二、使用createrepo创建本地yum源仓库

1、创建本地yum仓库目录

mkdir -p /mnt/rpm

2、使用createrepo来创建repository仓库

createrepo /mnt/rpm
#createrepo --help查看更多参数
#创建完毕后会在/mnt/rpm目录下生成repodata文件夹

报错-bash createrepo command not found,使用yum安装:yum -y install createrepo

3、编辑yum源repo文件仅添加以下内容:

vi /etc/yum.repos.d/oracle-linux-ol7.repo

[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)	#yum源名,叫啥都行
baseurl=file:///mnt/rpm								#挂载点路径
gpgcheck=0											#0表示关闭gpgkey检查,1是开启
enabled=1											#0表示关闭本地yum源,1是开启

4、清除YUM缓存:

yum clean all
#输出如下:
#Loaded plugins: ulninfo
#Cleaning repos: ol7_latest
执行:
yum makecache

5、向yum仓库中添加rpm包

#使用createrepo 手动执行,更新yum仓库
createrepo --update /mnt/rpm
或
createrepo --update-md-path= /mnt/rpm

6、列出yum源

yum repolist
#查看已配置好的yum源仓库和该yum仓库中存在rpm数量
#若忽略更新yum仓库,查看已配置好的yum源仓库可能显示rpm包为零,或者是添加新的rpm包之前的数量
#若还不显示最新的rpm数量再次执行“4”步骤即可

将需要的安装包使用yum install -y 包名安装即可,卸载使用yum remove -y 包名
有什么问题欢迎留言,谢谢。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值