1. 程式人生 > >yum源常見問題及解決方案 ~

yum源常見問題及解決方案 ~

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

在這裡插入圖片描述
@@解決方案:

 ##解除安裝原有的與主機版本不對應的apache
 [[email protected] iso]# yum remove -y httpd-tools-2.4.6-45.el7.x86_64
 ##重新安裝即可
 [[email protected] iso]# yum install httpd -y

在這裡插入圖片描述
排錯2:真機apache未開啟,映象資源無法共享

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

在這裡插入圖片描述
@@解決方案:

 [[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

在這裡插入圖片描述

@@解決方案:

 [[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

在這裡插入圖片描述
@@解決方案:

[[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

在這裡插入圖片描述
@@解決方案:

[[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

在這裡插入圖片描述
@@解決方案:

重新下載一個映象並重新掛載即可
[[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

在這裡插入圖片描述