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

Linux的yum配置

        yum的全稱為Yellow dog Updater,Modified,是一個基於RPM的shell前端包管理器,能夠從指定伺服器上(一個或者多個)自動下載並安裝或更新軟體、刪除軟體。其最大的好處就是能解決依賴關係

一、本地yum源配置

1.虛擬機器搭建所需環境

[[email protected] Desktop]# mkdir /ios
[[email protected] Desktop]# mount /dev/cdrom /ios/
mount: /dev/sr0 is write-protected, mounting read-only
[
[email protected]
Desktop]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/rhel-root 9754624 2972192 6782432 31% / devtmpfs 926516 0 926516 0% /dev tmpfs 942060 420 941640 1% /dev/shm tmpfs 942060 8996 933064 1% /run tmpfs 942060 0 942060 0% /sys/fs/cgroup /dev/sda1 201388 145464 55924 73% /boot tmpfs 188412 4 188408 1% /run/user/42 tmpfs 188412 8 188404 1% /run/user/0 /dev/sr0 3947824 3947824 0 100% /ios

注意:之所以新建掛載目錄是因為yum指令無法識別空格符,因為掛在的映象名字有空格符。

2.配置yum檔案

[[email protected] Desktop]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# ls
redhat.repo
[[email protected] yum.repos.d]# vim rhel.repo
[[email protected] yum.repos.d]# 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]
yum.repos.d]# 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 rhel7.2 4,620 repolist: 4,620

注意:以上的yum源頭配置都為臨時間配置

3.永久配置yum源

[[email protected] Desktop]# vim /etc/rc.d/rc.local 
[[email protected] Desktop]# reboot 

 

真機中配置yum源直接將映象掛載到掛載目錄,重複以上即可。

二、網路yum源的搭建

1.搭建實驗所需要環境(真機中搭建)

安裝Apache

2.重新搭建本機的yum 源配置

[[email protected] ~]# mkdir /var/www/html/rhel7.2
[[email protected] ~]# mount /ios/rhel-server-7.2-x86_64-dvd.iso /var/www/html/rhel7.2
mount: /dev/loop0 is write-protected, mounting read-only
[[email protected] ~]# vim /etc/yum.repos.d/junzi.repo 
[[email protected] ~]# vim /etc/yum.repos.d/rhel7.2.repo 
[[email protected] ~]# vim /etc/rc.d/rc.local 
[[email protected] ~]# systemctl restart httpd

3.製作火牆策略

[[email protected] ~]# firewall-cmd --permanent --add-service=http
success
[[email protected] ~]# firewall-cmd --permanent --add-masquerade 
success

 

4.客戶端作測試

搭建成功 更改客戶端yum源配置檔案