为Linux主机配置本机可访问的yum软件源

需要按照如下步骤进行。

步骤一:挂载CentOS7光盘设备

1)创建临时挂载点 /mnt/dvd

[root@svr7 ~]# mkdir -p /mnt/dvd/ //建挂载点
2)挂载CentOS7光盘

[root@svr7 ~]# mount /dev/cdrom /mnt/dvd/ //挂载光盘
mount: /dev/sr0 写保护,将以只读方式挂载

步骤二:拷贝CentOS7光盘中的文档资源

1)创建仓库目录 /repo/cos7dvd

[root@svr7 ~]# mkdir -p /repo/cos7dvd
2)将光盘内的所有文档拷贝到 /repo/cos7dvd/ 目录下

[root@svr7 ~]# cp -rf /mnt/dvd/* /repo/cos7dvd/
[root@svr7 ~]#

步骤三:确认本地仓库目录

[root@svr7 ~]# ls /repo/cos7dvd/
CentOS_BuildTag images repodata
EFI isolinux RPM-GPG-KEY-CentOS-7
EULA LiveOS RPM-GPG-KEY-CentOS-Testing-7
GPL Packages TRANS.TBL

步骤四:使用本机目录作为软件源

1):清理旧配置、不可用的配置

清理旧的配置,或者不可用/不使用的配置,避免干扰

[root@svr7 ~]# mkdir /etc/yum.repos.d/oldrepo
[root@svr7 ~]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/oldrepo/

2)添加软件源,指向前一步准备的本地软件仓库
[root@svr7 ~]# yum-config-manager --add-repo file:///repo/cos7dvd/

adding repo from: file:///repo/cos7dvd/
[repo_cos7dvd_]
name=added from: file:///repo/cos7dvd/
baseurl=file:///repo/cos7dvd/
enabled=1

3)确认结果
[root@svr7 ~]# ls /etc/yum.repos.d/ //确认自动添加的配置文件
oldrepo repo_cos7dvd_.repo

4)禁止检查软件签名
[root@svr7 ~]# vim /etc/yum.conf
[main]
cachedir=/var/cache/yum/ b a s e a r c h / basearch/ basearch/releasever
keepcache=0
… …
gpgcheck = 0 //取消软件签名检查
… …

步骤四:列出软件仓库列表,确认结果

[root@svr7 ~]# yum repolist
… …
repo_cos7dvd_ | 3.6 kB 00:00
(1/2): repo_cos7dvd_/group_gz | 155 kB 00:00
(2/2): repo_cos7dvd_/primary_db | 3.0 MB 00:00
Determining fastest mirrors
源标识 源名称 状态
repo_cos7dvd_ added from: file:///repo/cos7dvd/ 3,971
repolist: 3,971

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
redhat 7.2 可用的yum, 亲自测试可以使用 ,使用过程: 1.卸载已经存在的yum: rpm -qa | grep yum | xargs rpm -e --nodeps 2.将yum 文件放到server中 3.执行rpm -ivh yum-* 4.创建repo文件: #CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$7 - Base - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch;=$basearch&repo=os baseurl=http://mirrors.163.com/centos/7/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$7 - Updates - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch;=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/7/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$7 - Extras - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch;=$basearch&repo=extras baseurl=http://mirrors.163.com/centos/7/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$7 - Plus - 163.com baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 5.测试是否安装成功 yum -y install tree
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值