liunx配置本地yum源和更新aliyun yum源

时间:2023-03-09 07:53:08
liunx配置本地yum源和更新aliyun yum源

1、挂载DVD光盘到/mnt   因为配置时候路径名里面不能有空格,否则不能识别

[root@ mnt]# mount   /dev/cdrom   /mnt

[root@ mnt]# umount   /mnt

2、在目录/etc/yum.repos.d/创建文件文件名.repo

3、配置本地yum源

cd /etc/yum.repos.d/   #进入yum配置目录

touch  rhel7.repo   #建立yum配置文件

vim  rhel7.repo   #编辑配置文件,添加以下内容

[rhel-yum]

name=rhel7   #自定义名称

baseurl=file:///mnt#本地光盘挂载路径

enabled=1   #启用yum源,0为不启用,1为启用

gpgcheck=0  #检查GPG-KEY,0为不检查,1为检查

1.找到yum源模版位置,复制一份yum模版,改成自己的名字

cp rhel-debuginfo.repo rhel-xininfo.repo

liunx配置本地yum源和更新aliyun yum源

2.yum模版内容:

liunx配置本地yum源和更新aliyun yum源

3.配置配置自己的yum源:/mnt 光盘挂在位置,/mnt/Server,安装包位置

liunx配置本地yum源和更新aliyun yum源

4.清理yum缓存:yum clean  all

liunx配置本地yum源和更新aliyun yum源

5.验证yum是否配置成功:yum makecache

liunx配置本地yum源和更新aliyun yum源

到此,就可以用本地yum安装软件

更新阿里yum源:

先用本地yum源安装wget

rpm -ivh wget-1.14-15.el7.x86_64.rpm

cd /etc/yum.repos.d

[root@localhost yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo

--2018-09-06 23:24:18--  http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... failed: Name or service not known.
wget: unable to resolve host address ?.irrors.aliyun.com?

如果报上面的错误,按照下面修改

[root@localhost Packages]# vi /etc/resolv.conf
# Generated by NetworkManager
search localdomain
#nameserver 192.168.3.2
nameserver 8.8.8.8

利用Google的DNS进行解析,就可以顺利更新了