挂载镜像 我本人镜像位置为 /media/iso 所以挂载命令为:
你们镜像位置可以随意定义
mkdir /media/iso 自己定义镜像存放位置
mkdir /media/dvd 镜像挂载的位置
mount -o loop /media/iso/CentOS-7-x86_64-DVD-1511.iso /media/dvd/ #挂载iso文件
大部分人会出现包受保护,无法进行挂载
可以尝试通过chmod 777 给予镜像赋权限,如果行不通,自行百度解决方案
很多时候忽略版本问题,先查询自身Centos携带的rpm包
[root@zf-test-web01-4 ~]# rpm -qa|grep yum 命令查找所有的rpm
yum-plugin-fastestmirror-1.1.31-34.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-3.4.3-132.el7.centos.0.1.noarch
**rpm -e 命令 卸载当前系统中的rpm包**
通过rpm -e 删除时报错误,依赖关联,无法单个删除
执行命令 rpm -e yum-* --nodeps 将其yum包全部删除 如果没有删除
选择执行命令rpm -aq|grep yum|xargs rpm -e --nodeps
cat /etc/redhat-release 查看当前系统中的Centos的版本
下载版本对应的系统中需要的rpm包
下载地址为:http://vault.centos.org/7.3.1611/os/x86_64/package
我自身的iso镜像为7.3版本,按需下载
安装当前下载rpm包,关于安装rpm包时,出现rpm包互相关联或者缺失
执行命令 rpm -ivh yum-*
当前第四步执行 yum clean all
yum makecache
当执行yum makecache 出现以下错误。!!!!!
One of the configured repositories failed (Unknown),
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. Disable the repository, 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
4. 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=.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
我一开始百度很多答案 更改 DNS 或者修改配置文件 其实都不是
需要将其原Cenos中的这几个文件删除,要不然上面错误会一直提示 一直提示
切记这个文件夹下只剩下自己创建的local.repo
新建local.repo这个文件
进入 /etc/yum.repos.d文件夹下, touch local.repo
内容如下代码块
[local_server]
name=This is a local repo
baseurl=file:///mnt/cdrom 这个url地址就是镜像挂载的位置
enabled=1 视情况而定 不是0就是1
gpgcheck=1 无需更改
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7** 无需更改
**
yum clean all
yum makecache 执行通过
千万别 yum update 要不然又是无休止的百度,还解决不了 ,因为版本升级导致冲突,使用自身上传的版本即可