這篇文章主要介紹了rhel6.3中yum源如何配置,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
10年的靈川網站建設經驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。營銷型網站的優(yōu)勢是能夠根據用戶設備顯示端的尺寸不同,自動調整靈川建站的顯示方式,使網站能夠適用不同顯示終端,在瀏覽器中調整網站的寬度,無論在任何一種瀏覽器上瀏覽網站,都能展現優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)公司從事“靈川網站設計”,“靈川網站推廣”以來,每個客戶項目都認真落實執(zhí)行。
環(huán)境:RHEL6.3
創(chuàng)建本地yum源步驟如下:
1、首先檢查是否有YUM命令,如果沒有請安裝
#rpm -ivh yum-3.2.29-30.el6.noarch.rpm
再次檢查是否有createrepo,如果沒有請安裝createrepo包,裝這個包之前先裝以下兩個包;
[root@localhost Packages]# rpm -ivh deltarpm-3.5-0.5.20090913git.el6.i686.rpm
warning: deltarpm-3.5-0.5.20090913git.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:deltarpm ########################################### [100%]
[root@localhost Packages]# rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm
warning: python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:python-deltarpm ########################################### [100%]
[root@localhost Packages]#rpm -ivh createrepo-0.9.8-5.el6.noarch.rpm
2、新建本地源目錄
#mkdir /Packages #存放本地YUM所需的文件
將光盤上的Packages下的所有安裝包都放置到這個目錄中,還有把光盤上的RPM-GPG-KEY-redhat-release也拷貝到這個目錄中
3. 在/Packages 目錄下,執(zhí)行createrepo /Packages
2842/2842 - xorg-x11-fonts-misc-7.2-9.1.el6.noarch.rpm
Saving Primary metadata
Saving file lists metadata
Saving other metadata
會生成 repodata目錄,并有四個關鍵文件,現在查看一下
[root@localhost Packages]# ls -d */
HighAvailability/ images/ isolinux/ LoadBalancer/ repodata/
[root@localhost Packages]# cd repodata
[root@localhost repodata]# ls
filelists.xml.gz other.xml.gz primary.xml.gz repomd.xml
注:repodata作為軟件的倉庫,其目錄下有四個必要文件:filelists.xml.gz other.xml.gz primary.xml.gz repomd.xml(md意思是metadata),其中最主要的是repomd.xml文件。一般出現的找不到repodata目錄或文件的錯誤的原因通常有三個:一是路徑問題;二是沒有生成repodata目錄;三是*.repo配置文件沖突(這個需要特別注意,需要將/etc/yum.repos.d下的其他repo文件的enabled=0設置或者刪除其他的repo文件)。以上四個文件要建立yum庫后才會出現,在下面的示例中,路徑為:/Packages /repodata/
4. 在/etc/yum.repos.d下新建一個yum.repo。內容如下:
[RHEL]
name=rhel6.3
baseurl=file:///Packages
gpgcheck=1
gpgkey=file:///Packages/RPM-GPG-KEY-redhat-release
enabled=1
解釋:
[....] 代表這個庫的名字,必須是唯一的,不可以重復。
name= 是這個庫的說明,沒有太大的實際意義,只是一個字段說明。
baseurl= 說明采取什么方式傳輸,具體路徑在哪里,可以使用的方式有,file://,ftp://,http://等
enabled=1 說明啟用這個更新庫,0表示不啟用。
gpgcheck=0 表示不使用gpg文件來檢查軟件包的簽名 1表示使用簽名
gpgkey= 表示gpg文件所存放的位置,此處也可以有http方式的位置。
到此就可以測試yum庫創(chuàng)建是否成功了。
5、測試一下
[root@localhost /]# yum -y install telnet*
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package telnet.i686 1:0.17-47.el6 will be installed
---> Package telnet-server.i686 1:0.17-47.el6 will be installed
--> Processing Dependency: xinetd for package: 1:telnet-server-0.17-47.el6.i686
--> Running transaction check
---> Package xinetd.i686 2:2.3.14-34.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Installing:
telnet i686 1:0.17-47.el6 RHEL 57 k
telnet-server i686 1:0.17-47.el6 RHEL 36 k
Installing for dependencies:
xinetd i686 2:2.3.14-34.el6 RHEL 121 k
Transaction Summary
===============================================================================================
Install 3 Package(s)
Total download size: 214 k
Installed size: 409 k
Downloading Packages:
Error Downloading Packages:
1:telnet-0.17-47.el6.i686: failure: Packages/telnet-0.17-47.el6.i686.rpm from RHEL: [Errno 256] No more mirrors to try.
2:xinetd-2.3.14-34.el6.i686: failure: Packages/xinetd-2.3.14-34.el6.i686.rpm from RHEL: [Errno 256] No more mirrors to try.
1:telnet-server-0.17-47.el6.i686: failure: Packages/telnet-server-0.17-47.el6.i686.rpm from RHEL: [Errno 256] No more mirrors to try.
發(fā)現安裝失敗,沒有自己發(fā)現軟件包之間的依賴關系。更新一下
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Cleaning repos: RHEL
Cleaning up Everything
然后再裝,就可以了
[root@localhost yum.repos.d]# yum -y install telnet*
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
RHEL | 1.3 kB 00:00 ...
RHEL/primary | 1.3 MB 00:00 ...
RHEL 2842/2842
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package telnet.i686 1:0.17-47.el6 will be installed
---> Package telnet-server.i686 1:0.17-47.el6 will be installed
--> Processing Dependency: xinetd for package: 1:telnet-server-0.17-47.el6.i686
--> Running transaction check
---> Package xinetd.i686 2:2.3.14-34.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Installing:
telnet i686 1:0.17-47.el6 RHEL 57 k
telnet-server i686 1:0.17-47.el6 RHEL 36 k
Installing for dependencies:
xinetd i686 2:2.3.14-34.el6 RHEL 121 k
Transaction Summary
===============================================================================================
Install 3 Package(s)
Total download size: 214 k
Installed size: 409 k
Downloading Packages:
-----------------------------------------------------------------------------------------------
Total 4.1 MB/s | 214 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 2:xinetd-2.3.14-34.el6.i686 1/3
Installing : 1:telnet-server-0.17-47.el6.i686 2/3
Installing : 1:telnet-0.17-47.el6.i686 3/3
Installed products updated.
Verifying : 1:telnet-server-0.17-47.el6.i686 1/3
Verifying : 2:xinetd-2.3.14-34.el6.i686 2/3
Verifying : 1:telnet-0.17-47.el6.i686 3/3
Installed:
telnet.i686 1:0.17-47.el6 telnet-server.i686 1:0.17-47.el6
Dependency Installed:
xinetd.i686 2:2.3.14-34.el6
Complete!
做一下YUM的緩存,方便加速
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
RHEL | 1.3 kB 00:00 ...
RHEL/filelists | 2.9 MB 00:00 ...
RHEL/other | 1.3 MB 00:00 ...
RHEL 2842/2842
RHEL 2842/2842
Metadata Cache Created
提醒注意:yum install [軟件名] 這里最好不要用全名,雖然有些包的安裝也是可以的。但是本人測試,遇到安裝失敗的麻煩。
一些有用的YUM命令:
yum remove | erase 軟件名1 [軟件名2] [...]
yum list [...]
yum info [...]
yum provides | whatprovides feature1 [feature2] [...]
yum clean [ packages | headers | metadata | dbcache | all ]
yum makecache
自動分析依賴性關系是YUM最好的一個特點,也是目前最方便的安裝方法。
用的上的命令
createrepo --update /Packages/ # 更新本地源,如果新增了RPM包
createrepo /Packages/ # 重新生成metadata
createrepo --update:
有時候你的軟件倉庫中含有很多的軟件包,雖然只是其中的一小部分有所改動但是你卻不必為每個軟件包重新產生元數據,這樣做明顯太浪費時間了。createrepo只更新那些在上次產生元數據之后被改變,添加或者刪除了的項目.
使用ftp做 yum源
上面的設置只能使本機使用yum源,為了使其他機器也可以使用,所以在源機器上配置ftp server
1. yum install vsftpd
2. 在其他機器上通過ftp命令訪問測試,如果出現500 OOPS: cannot change directry, 那么在源機器執(zhí)行setsebool -P ftp_home_dir on, 然后service vsftpd restart
3. 在 /var/ftp/pub 下面做mount, 而不是做符號鏈接,因為如果是符號鏈接那么從瀏覽器訪問會出現550 Failed to change directory.當然也可以把/Packages下的所有拷貝到pub下。
#mkdir /rh75
#umount /dev/sr0
# mount /dev/sr0 /rh75
cd /var/ftp/pub , mkdir yum, mount --bind /rh75 yum
4. 設置yum ftp連接方式(包括源機器也可以這樣設置,兩邊的repo可以一樣)
/etc/yum.repos.d下修改一下yum.repo
[RHEL1]
name=rhel6.3
baseurl=ftp://192.168.1.130/pub/yum/
gpgcheck=0
enabled=1
使用HTTP做YUM源
1 安裝httpd安裝包 #yum -y install httpd
2 如上創(chuàng)建本地更新源
#cd /var/www/html/
#mkdir yum
# mount --bind /rh75 /yum
或者比如yum文件都在/rh75下
[root@localhost html]# vi /etc/yum.repos.d/yum.repo
[root@localhost html]# cat /etc/yum.repos.d/yum.repo
[RHEL]
name=rhel6.3
baseurl=http://192.168.1.130/yum/
gpgcheck=0
enabled=1
3 service httpd start #啟動httpd守護進程,否則在其他機器上會提示找不到相關源
4 測試一下
[root@localhost yum.repos.d]# rpm -qa|grep telnet
[root@localhost yum.repos.d]# yum -y install telnet*
Installed:
telnet.i686 1:0.17-47.el6 telnet-server.i686 1:0.17-47.el6
Dependency Installed:
xinetd.i686 2:2.3.14-34.el6
Complete!
使用ISO光盤直接掛成本地YUM源
1、先把ISO光盤掛接到系統(tǒng),然后mount看一下
[root@localhost network-scripts]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/sr0 on /media/RHEL_6.3 i386 Disc 1 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)
2、接著在根下或在其他目錄建一個目錄
#cd /
#mkdir rhel6
#umount /dev/sr0
# mount /dev/sr0 /rhel6
3、編輯REPO文件
#cd /etc/yum.repos.d
#vi yum.repo
[RHEL]
name=rhel6.3
baseurl=file:///rhel6 (如果是rhel5,則是file:///rhel5/Server,因為repodata/repomd.xml不在光盤根下)
enabled=1
# service iptables stop
# setenforce 0
# yum -y install telnet
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
RHEL | 4.0 kB 00:00 ...
RHEL/primary_db | 2.5 MB 00:00 ...
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package telnet.i686 1:0.17-47.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
telnet i686 1:0.17-47.el6 RHEL 57 k
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 57 k
Installed size: 102 k
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Public key for telnet-0.17-47.el6.i686.rpm is not installed
注意這是出現NOKEY錯誤,檢查YUM.REPO文件沒有問題,那么需要看yum.conf主配文件
#cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
將/etc/yum.conf中的gpgcheck=1改為gpgcheck=0(不檢查軟件包簽名)即可。
注:在做YUM源時,確保源和使用源的LINUX主機的REPO文件和yum.conf文件配置一致。
最后再試就正常了
#yum -y install telnet
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 1:telnet-0.17-47.el6.i686 1/1
Installed products updated.
Verifying : 1:telnet-0.17-47.el6.i686 1/1
Installed:
telnet.i686 1:0.17-47.el6
Complete!
vim /etc/udev/rules.d/70-persistent-net.rules
vim /etc/sysconfig/network-scripts/ifcfg-eth0
感謝你能夠認真閱讀完這篇文章,希望小編分享的“rhel6.3中yum源如何配置”這篇文章對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián),關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關知識等著你來學習!