yum源常见问题及解决方案 ~

时间:2024-03-28 21:06:11

yum源常搭建常见问题及解决方案

如果虚拟机无法下载软件 可能的原因有:

1.真机yum源没有配置好
2.真机共享yum源的挂载错误
3.真机apache没有开启
4.真机火墙没有关闭(或者是真机火墙开着的但未添加http服务到火墙策略中)
5.虚拟机的yum源指向错误
6.所挂载的镜像本身就有问题

排错1:
我这里的真机曾经用过7.3版本的镜像资源安装过apache,而此时挂载的是7.2版本的镜像资源,若要想重新安装新版本的apache,就必须先卸载原先与系统版本不匹配的apahe,然后再重新安装新版本的apache

[[email protected] yum.repos.d]# yum clean all
Loaded plugins: aliases, changelog, kabi, langpacks, ovl, product-id, search-
              : disabled-repos, subscription-manager, tmprepo, verify,
              : versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading support for Red Hat kernel ABI
Cleaning repos: source7.2
Cleaning up everything
[[email protected] yum.repos.d]# yum repolist
Loaded plugins: aliases, changelog, kabi, langpacks, ovl, product-id, search-
              : disabled-repos, subscription-manager, tmprepo, verify,
              : versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading support for Red Hat kernel ABI
source7.2                                                | 4.1 kB     00:00     
(1/2): source7.2/primary_db                                | 3.6 MB   00:00     
(2/2): source7.2/group_gz                                  | 136 kB   00:00     
repo id                              repo name                            status
source7.2                            source7.2                            4,620
repolist: 4,620
##报错
[[email protected] iso]# yum install httpd -y

yum源常见问题及解决方案 ~

 @@解决方案:
 ##卸载原有的与主机版本不对应的apache
 [[email protected] iso]# yum remove -y httpd-tools-2.4.6-45.el7.x86_64
 ##重新安装即可
 [[email protected] iso]# yum install httpd -y

yum源常见问题及解决方案 ~
排错2:真机apache未开启,镜像资源无法共享

[[email protected] ~]# yum clean all
Loaded plugins: langpacks
Cleaning repos: rhel7.0
Cleaning up everything
[[email protected] ~]# yum repolist

yum源常见问题及解决方案 ~

 @@解决方案: 
 [[email protected] ~]# systemctl status httpd
 ##开启apache
 [[email protected] ~]# systemctl start httpd
[[email protected] yum.repos.d]# yum clean all
Loaded plugins: langpacks
Cleaning repos: rhel7.0
Cleaning up everything
[[email protected] yum.repos.d]# yum repolist
Loaded plugins: langpacks
rhel7.0                                                   | 4.1 kB  00:00:00     
(1/2): rhel7.0/group_gz                                   | 134 kB  00:00:00     
(2/2): rhel7.0/primary_db                                 | 3.4 MB  00:00:00     
repo id                              repo name                             status
rhel7.0                              rhel7.0                               4,305
repolist: 4,305

排错3:真机防火墙未开启,当真机用http方式共享镜像资源时被拒绝

[[email protected] Desktop]# yum clean all
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: rhel7.2
Cleaning up everything
[[email protected] Desktop]# yum repolist

yum源常见问题及解决方案 ~

 @@解决方案:
 [[email protected] ~]# systemctl stop firewalld
 [[email protected] ~]# systemctl status firewalld
[[email protected] Desktop]# yum clean all
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: rhel7.2
Cleaning up everything

[[email protected] Desktop]# yum repolist
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.    rhel7.2                                                  | 4.1 kB     00:00     
(1/2): rhel7.2/group_gz                                    | 136 kB   00:00     
(2/2): rhel7.2/primary_db                                  | 3.6 MB   00:00     
repo id                           repo name                               status
rhel7.2                           &&&&&&&&&&&&&                           4,620
repolist: 4,620

排错4:虚拟机ip设定错误,真机与虚拟机网络不可达,都无法通信(网络位相同的主机才能通信),更谈不上共享镜像资源了

[[email protected] Desktop]# yum clean all
[[email protected] Desktop]# yum repolist

yum源常见问题及解决方案 ~

@@解决方案:
[[email protected] Desktop]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 52:54:00:52:62:54  txqueuelen 1000  (Ethernet)
        RX packets 11  bytes 774 (774.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
##添加ip
[[email protected] Desktop]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 
#########################
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.234
PREFIX=24

[[email protected] Desktop]# systemctl restart network
[[email protected] Desktop]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.25.254.234  netmask 255.255.255.0  broadcast 172.25.254.255
        inet6 fe80::5054:ff:fe52:6254  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:52:62:54  txqueuelen 1000  (Ethernet)
        RX packets 11  bytes 774 (774.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 24  bytes 3029 (2.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[[email protected] Desktop]# yum repolist
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel7.2                                                  | 4.1 kB     00:00     
(1/2): rhel7.2/group_gz                                    | 136 kB   00:00     
(2/2): rhel7.2/primary_db                                  | 3.6 MB   00:00     
repo id                           repo name                               status
rhel7.2                           &&&&&&&&&&&&&                           4,620
repolist: 4,620

排错5:虚拟机yum源指向错误

[[email protected] yum.repos.d]# yum clean all
Loaded plugins: langpacks
Cleaning repos: rhel7.0
Cleaning up everything
##说明yum源指向有问题
[[email protected] yum.repos.d]# yum repolist

yum源常见问题及解决方案 ~

@@解决方案:
[[email protected] yum.repos.d]# cat rhel7.0.repo 
[rhel7.0]
name=rhel7.0
baseurl=http://source7.0  ##发现yum源指向确实有问题
gpgcheck=0

##更正yum源指向
[[email protected] yum.repos.d]# vim rhel7.0.repo 
########################
[rhel7.0]
name=rhel7.0
baseurl=http://172.25.254.66/source7.0
gpgcheck=0

[[email protected] yum.repos.d]# yum clean all
Loaded plugins: langpacks
Cleaning repos: rhel7.0
Cleaning up everything
[[email protected] yum.repos.d]# yum repolist
Loaded plugins: langpacks
rhel7.0                                                   | 4.1 kB  00:00:00     
(1/2): rhel7.0/group_gz                                   | 134 kB  00:00:00     
(2/2): rhel7.0/primary_db                                 | 3.4 MB  00:00:00     
repo id                              repo name                             status
rhel7.0                              rhel7.0                               4,305
repolist: 4,305

排错6:真机所共享的镜像本身有问题

[[email protected] ~]# yum clean all
Loaded plugins: langpacks
Cleaning repos: rhel_dvd
Cleaning up everything
[[email protected] ~]# yum repolist
Loaded plugins: langpacks
rhel_dvd                                                 | 4.1 kB     00:00     
(1/2): rhel_dvd/group_gz                                   | 134 kB   00:00     
(2/2): rhel_dvd/primary_db                                 | 3.4 MB   00:00     
repo id                    repo name                                      status
rhel_dvd                   Remote classroom copy of dvd                   4,305
repolist: 4,305
[[email protected] ~]# yum install -y httpd

yum源常见问题及解决方案 ~

@@解决方案:
重新下载一个镜像并重新挂载即可
[[email protected] Desktop]# mv rhel-server-7.0-x86_64-dvd.iso /iso
mv: overwrite ‘/iso/rhel-server-7.0-x86_64-dvd.iso’? y

[[email protected] Desktop]# df
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/sda13     122268336 79564520  42703816  66% /
devtmpfs         1822536        0   1822536   0% /dev
tmpfs            1837252      520   1836732   1% /dev/shm
tmpfs            1837252     9480   1827772   1% /run
tmpfs            1837252        0   1837252   0% /sys/fs/cgroup
/dev/sda11        505580   150720    354860  30% /boot
/dev/sda1         262144    37528    224616  15% /boot/efi
/dev/loop0       3947824  3947824         0 100% /source7.2
/dev/loop1       3762278  3762278         0 100% /var/www/html/source6.5
/dev/loop2       3704296  3704296         0 100% /var/www/html/source7.3
/dev/loop3       3947824  3947824         0 100% /var/www/html/source7.2
tmpfs             367452       44    367408   1% /run/user/1000
tmpfs             367452        0    367452   0% /run/user/0
/dev/loop4       3654720  3654720         0 100% /var/www/html/source7.0
##卸载
[[email protected] Desktop]# umount /var/www/html/source7.0
##重新挂载
[[email protected] Desktop]# mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/source7.0
mount: /dev/loop4 is write-protected, mounting read-only
[[email protected] ~]# yum install -y httpd

yum源常见问题及解决方案 ~