(1)、掛載ISO鏡像文件到/media/cdrom/下。html
將下載的CentOS-6.4-x86_64-bin-DVD1.iso鏡像文件經過下面的方式掛載到一個目錄下面,同常掛載到/media/cdrom/下:python
mount -t iso9660 -o loop/root/CentOS-6.4-x86_64-bin-DVD1.iso /media/cdrom/linux
(2)、安裝並啓動vsftpd服務。git
因爲個人服務器是最小化安裝的,默認沒有安裝vsftpd服務,這裏進入剛纔掛載的目錄。使用rpm -ivh 方式安裝vsftpd服務。centos
[root@centos6centos6.4]# cd /media/cdrom/緩存
[root@centos6cdrom]# ll服務器
總用量676dom
-r--r--r--2 root root14 3月6 2013 CentOS_BuildTagide
dr-xr-xr-x3 root root2048 3月5 2013 EFIoop
-r--r--r--2 root root212 3月3 2013 EULA
-r--r--r--2 root root18009 3月3 2013 GPL
dr-xr-xr-x3 root root2048 3月5 2013 p_w_picpaths
dr-xr-xr-x2 root root2048 3月5 2013 isolinux
dr-xr-xr-x2 root root 649216 3月6 2013 Packages
-r--r--r--2 root root1354 3月3 2013 RELEASE-NOTES-en-US.html
dr-xr-xr-x2 root root4096 3月6 2013 repodata
-r--r--r--2 root root1706 3月3 2013 RPM-GPG-KEY-CentOS-6
-r--r--r--2 root root1730 3月3 2013 RPM-GPG-KEY-CentOS-Debug-6
-r--r--r--2 root root1730 3月3 2013 RPM-GPG-KEY-CentOS-Security-6
-r--r--r--2 root root1734 3月3 2013 RPM-GPG-KEY-CentOS-Testing-6
-r--r--r--1 root root3380 3月6 2013 TRANS.TBL
[root@centos6cdrom]# rpm -ivh Packages/vsftpd-2.2.2-11.el6_3.1.x86_64.rpm
安裝完成後啓動vsftpd服務:
[root@centos6 cdrom]# service vsftpd restart
[root@centos6 cdrom]# chkconfig vsftpd on ##設置vsftpd服務爲自啓動
[root@centos6cdrom]# chkconfig --list |grep vsftpd
vsftpd0:關閉1:關閉2:啓用3:啓用4:啓用5:啓用6:關閉
(3)、創建yum倉庫目錄
上面安裝完vsftpd後默認會自動建立好/var/ftp/pub/目錄,咱們把yum倉庫目錄建立在該目錄下,命名爲centos6.4,以下:
[root@centos6 cdrom]# mkdir -p /var/ftp/pub/centos6.4/
[root@centos6 cdrom]#cp -rf /media/cdrom/* /var/ftp/pub/centos6.4/ ##將光盤鏡像裏的全部文件拷貝到yum倉庫目錄裏
這是拷貝完成後的目錄結構:
[root@centos6 cdrom]# cd/var/ftp/pub/centos6.4
[root@centos6centos6.4]# ll
總用量328
-r--r--r--1 root root14 11月6 15:03 CentOS_BuildTag
dr-xr-xr-x3 root root4096 11月6 15:03 EFI
-r--r--r--1 root root212 11月6 15:03 EULA
-r--r--r--1 root root18009 11月6 15:03 GPL
dr-xr-xr-x3 root root4096 11月6 15:03 p_w_picpaths
dr-xr-xr-x2 root root4096 11月6 15:03 isolinux
dr-xr-xr-x2 root root 266240 11月6 15:06 Packages
-r--r--r--1 root root1354 11月6 15:06 RELEASE-NOTES-en-US.html
drwxr-xr-x2 root root4096 11月6 16:04 repodata
-r--r--r--1 root root1706 11月6 15:06 RPM-GPG-KEY-CentOS-6
-r--r--r--1 root root1730 11月6 15:06 RPM-GPG-KEY-CentOS-Debug-6
-r--r--r--1 root root1730 11月6 15:06 RPM-GPG-KEY-CentOS-Security-6
-r--r--r--1 root root1734 11月6 15:06 RPM-GPG-KEY-CentOS-Testing-6
-r--r--r--1 root root3380 11月6 15:06 TRANS.TBL
(4)、建立yum源,更新軟件包依賴關係。
手工建立repository依賴關係文件,創建yum源須要安裝createrepo這個軟件包。因爲個人最小化安裝,該軟件包安裝還須要依賴下面兩個包:
python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
因而把這三個包一併都安裝上,以下:
[root@centos6cdrom]# rpm -ivh Packages/createrepo-0.9.9-17.el6.noarch.rpm Packages/python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm Packages/deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
[root@centos6 cdrom]# rm -rf /var/ftp/pub/centos6.4/repodata/ ##將原來的依賴關係文件刪除,從新生成。
[root@centos6 cdrom]#createrepo -v /var/ftp/pub/centos6.4/ ##重建依賴關係庫文件,會從新生成repodata目錄
接下來修改yum源地址的配置文件。
[root@centos6~]# cd /etc/yum.repos.d/
[root@centos6 yum.repos.d]# for i in `ls ./` ;domv $i $i-bak;done; ##把/etc/yum.repos.d/目錄下的文件都更名備份一下。
[root@centos6 yum.repos.d]#cp CentOS-Media.repo-bak CentOS-Media.repo
[root@centos6 centos6.4]# vi/ etc/yum.repos.d/CentOS-Media.repo ##只用這一個文件,修改下面加粗部份內容。你們根據本身的實際目錄更改。
以下:
[c6-media]
name=CentOS-$releasever- Media
#baseurl=file:///media/CentOS/
file:///media/cdrom/
file:///media/cdrecorder/
baseurl=ftp://192.168.0.109/pub/centos6.4/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
說明:
name=CentOS-$releasever- Media自定義說明
baseurl=file:///yum/Server 指定使用的協議和yum源所在位置
enabled=1 是否啓用該yum倉庫,1爲使用,0爲不使用
gpgcheck=0 是否進程gpg祕鑰檢查,1爲檢查,0爲不檢查
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RedHat-release 指定gpg祕鑰所在位置
說明:
baseurl= 一欄是指定使用何種yum源
file 表示使用本地yum源,格式爲file://源路徑
ftp 表示使用ftp協議方式得到yum源,格式爲ftp://sourceIP/repository目錄
http 表示使用http協議方式得到Yum源,格式爲http://sourceIP/repository目錄
gpgcheck= 一欄表示是否祕鑰檢測,若是須要檢查,能夠手工導入祕鑰
#rpm --import /etc/pki/rpm-gpg/gpg祕鑰文件名
在/etc/yum.repo.d/目錄下,最好只存在一個後綴名爲repo的文件,其餘的文件更名,防止干擾。
[root@centos6 centos6.4]# yum clean all ##清除一下yum緩存,不然可能 yum安裝的時候還會報錯。
Loadedplugins: fastestmirror, security
Cleaningrepos: c6-media
Cleaningup Everything
Cleaningup list of fastest mirrors
二、配置客戶端
#rm -rf /etc/yum.repos.d/* ---清楚/etc/yum.repos.d/下面的文件
#vi /etc/yum.repos.d/yum-Media.repo 添加如下內容
[c4-media]
name=RHEL4 - Media
baseurl=ftp://192.168.5.118/4-32/RHEL
gpgcheck=0
enabled=1
gpgkey=ftp://192.168.5.118/4-32/RHEL/RPM-GPG-KEY
#yum clean all
用yum安裝screen軟件包,測試正常。以下:
[root@centos6 centos6.4]# yum install screen -y ##使用-y參數,意思是直接安裝不用再次確認。
Loadedplugins: fastestmirror, security
Determiningfastest mirrors
c6-media| 2.9 kB00:00
c6-media/primary_db| 3.3 MB00:00
Settingup Install Process
ResolvingDependencies
-->Running transaction check
--->Package screen.x86_64 0:4.0.3-16.el6 will be installed
-->Finished Dependency Resolution
DependenciesResolved
============================================================================================================================================================
PackageArchVersionRepositorySize
============================================================================================================================================================
Installing:
screenx86_644.0.3-16.el6c6-media494 k
TransactionSummary
============================================================================================================================================================
Install1 Package(s)
Totaldownload size: 494 k
Installedsize: 795 k
DownloadingPackages:
screen-4.0.3-16.el6.x86_64.rpm| 494 kB00:00
warning:rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrievingkey from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
ImportingGPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 OfficialSigning Key) <centos-6-key@centos.org>
Package:centos-release-6-4.el6.centos.10.x86_64(@anaconda-CentOS-201303020151.x86_64/6.4)
From:/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Runningrpm_check_debug
RunningTransaction Test
TransactionTest Succeeded
RunningTransaction
Warning:RPMDB altered outside of yum.
Installing : screen-4.0.3-16.el6.x86_641/1
Verifying: screen-4.0.3-16.el6.x86_641/1
Installed:
screen.x86_64 0:4.0.3-16.el6
Complete!
推薦閱讀:
RedHat Linux 本地yum源的配置 http://www.linuxidc.com/Linux/2013-08/88217.htm
RedHat 6.2 Linux修改yum源無償使用CentOS源 http://www.linuxidc.com/Linux/2013-07/87383.htm
配置EPEL YUM源 http://www.linuxidc.com/Linux/2012-10/71850.htm
Redhat 本地yum源配置 http://www.linuxidc.com/Linux/2012-11/75127.htm
yum的配置文件說明 http://www.linuxidc.com/Linux/2013-04/83298.htm
RedHat 6.1下安裝yum(圖文) http://www.linuxidc.com/Linux/2013-06/86535.htm
YUM 安裝及清理 http://www.linuxidc.com/Linux/2013-07/87163.htm
更多CentOS相關信息見CentOS 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=14