1. 程式人生 > >Linux yum源配置

Linux yum源配置

sta user df -h pac ans write 編寫 odata product

Linux yum源配置

  本文介紹Red Hat下yum源配置方法,Redhat使用yum網絡源需要購買服務,但是本地yum源不會收費。

  CentOS用戶自帶yum源,並且yum不收費。

準備工具:

  1、安裝機器時的鏡像

  2、VMware機器設置裏CD/DVD選項勾選,已連接和開機自動連接

步驟:

  1、首先編寫yum源的repo文件,存放路徑 /etc/yum.repos.d/,以repo結尾,名字任意命名

    格式如下:    

      [rhel7.4]      是用於區別各個不同的倉庫,名字不能和其他的倉庫名字重復
      name=       對倉庫的描述,

      baseurl=      路徑  
      enable=       是否啟用,1啟用 0關閉           
      gpgcheck=     是否驗證,1啟用,0關閉

按照這個格式配置,就可以使用yum倉庫了,其他更深入的功能見後邊更新講解

       

[root@localhost ~]#  vim /etc/yum.repos.d/rhel.repo 

[rhel7.4] 
name=RedHat_Enterprise_linux_7.4 
baseurl=file:///iso 
enable=1 
gpgcheck=0

  

  2、掛載鏡像

    首先創建一個掛載點,因為上邊配置文件裏寫的是根目錄下的iso目錄,所以在根下邊創建一個/iso

      mkdir /iso

掛載
[root@localhost ~]# mount /dev/cdrom /iso/
mount: /dev/sr0 is write-protected, mounting read-only

可以看到已經掛載成功
[root@localhost ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   10G  7.7G  2.4G  77% /
devtmpfs               1.9G     0  1.9G   0% /dev
tmpfs                  1.9G  8.9M  1.9G   1% /dev/shm
tmpfs                  1.9G  9.2M  1.9G   1% /run
tmpfs                  1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/rhel-usr    35G   24G   12G  68% /usr
/dev/sda1             1014M  145M  870M  15% /boot
/dev/mapper/rhel-tmp   4.0G   60M  4.0G   2% /tmp
/dev/mapper/rhel-opt   4.0G  559M  3.5G  14% /opt
/dev/mapper/rhel-var   8.0G  5.0G  3.1G  63% /var
tmpfs                  378M     0  378M   0% /run/user/0
/dev/sr0               3.8G  3.8G     0 100% /iso

當/iso出現以下內容,表明掛載成功
[root@localhost ~]# ls /iso/
addons            GPL       media.repo               RPM-GPG-KEY-redhat-release
EFI               images    Packages                 TRANS.TBL
EULA              isolinux  repodata
extra_files.json  LiveOS    RPM-GPG-KEY-redhat-beta

  查看倉庫

[root@localhost ~]# yum repolist
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
repo id                        repo name                                           status
rhel7.4                        RedHat_Enterprise_linux_7.4                         4,986
repolist: 4,986

  安裝服務測試一下

[root@localhost ~]# yum install vsftpd
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-22.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================
 Package           Arch              Version                    Repository          Size
=========================================================================================
Installing:
 vsftpd            x86_64            3.0.2-22.el7               rhel7.4            169 k

Transaction Summary
=========================================================================================
Install  1 Package

Total download size: 169 k
Installed size: 348 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : vsftpd-3.0.2-22.el7.x86_64                                            1/1 
  Verifying  : vsftpd-3.0.2-22.el7.x86_64                                            1/1 

Installed:
  vsftpd.x86_64 0:3.0.2-22.el7                                                           

Complete!

  至此,yum配置安裝完成

Linux yum源配置