CentOS搭建本地光盤YUM源

1. 搭建本地光盤YUM

[root@yum ~]# mkdir /mnt/cdrom/  ------》創建光盤掛載目錄

[root@yum ~]# mount /dev/cdrom /mnt/cdrom/  --------》掛在光盤

[root@yum ~]# cd /etc/yum.repos.d/    --------》切換到YUM配置目錄

[root@yum yum.repos.d]# tar czf repo.tar.gz ./*  --------》將原來所有的文件進行打包備份

[root@yum yum.repos.d]# rm -f CentOS*   --------》刪除原文件

[root@yum yum.repos.d]# vim CentOS-Media.repo   --------》配置光盤源文件

[c6-media]

name=CentOS-$releasever - Media

baseurl=file:///mnt/cdrom    --------》這裏爲你光盤的掛載目錄

gpgcheck=1    --------》是否啓動檢查GPG-KEY

enabled=1      --------》是否啓用YUM

gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-6  --》指定掛載目錄下的GPG-KEY文件

驗證:

wKioL1OrwjHCLicfAAP8mQCdCnE866.jpg

 

 

2. 如果要讓公司所有的Linux主機可用內部源服務,可以用FTP/HTTP搭建一個YUM服務器,由於Http較爲簡便,我這裏就以HTTP的方式搭建一個YUM服務了。

繼上面的操作,我借用本地光盤源搭建一個HTTPYUM服務!

 

2.1 

HTTP我在上面已經通過YUM的方式安裝了,如果大家沒有安裝可以通過光盤裏面的安裝包進行安裝,聯網也可以通過網絡的YUM進行安裝。啓動http服務!關閉防火牆和SELinux

[root@yum ~]# service  httpd start

Starting httpd: httpd: apr_sockaddr_info_get() failed for yum.server    [  OK  ]

[root@yum ~]# chkconfig httpd on

[root@yum ~]# service iptables stop

[root@yum ~]# chkconfig iptables off

[root@yum ~]# setenforce 0

 

2.2 

Apache根目錄下建立子文件夾,如果想讓本YUM服務器爲不同版本的Linux服務,可根據情況創建目錄,然後將光盤內所有的文件CP至該目錄!

注:一般使用DVD1即可,當然也可以合併DVD1DVD2來作爲源。

 

[root@yum ~]# mkdir -p /var/www/html/yum

[root@yum ~]# mkdir -p /var/www/html/yum/CentOS-6

[root@yum ~]# cp -prf /mnt/cdrom/* /var/www/html/yum/CentOS-6/

 

2.3

客戶端修改CentOS-Base.repo,建議先備份一個副本哦,這樣以後要從外網更新的話,可以再用。

[root@test1 yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.bak1

[root@test1 yum.repos.d]# vim CentOS-Base.repo

 

###################CentOS-Base.repo內容修改後,如下#####################


# CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client.  You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the 

# remarked out baseurl= line instead.

#

#

 

[base]

name=CentOS-$releasever - Base

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

baseurl=http://172.20.1.11/yum/CentOS-6

enable=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

#released updates 

[updates]

name=CentOS-$releasever - Updates

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates

baseurl=http://172.20.1.11/yum/CentOS-6

enable=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

baseurl=http://172.20.1.11/yum/CentOS-6

enable=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus

#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

#contrib - packages by Centos Users

[contrib]

name=CentOS-$releasever - Contrib

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib

#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

centosplus][contrib]的內容不需要修改,它們的enabled值默認值是0,即模塊不啓用。

 

2.4

客戶端測試!

wKioL1OrwuryGR4FAAR4BI6JAjQ515.jpg

 

附加:

DVD1和DVD2文件合併的步驟:

1.將DVD2光盤中Packages目錄下所有的rpm文件CPDVD1的目錄下。

Cp /mnt/dvd2/Packages/*.rpm /var/www/html/yum/CentOS-6/Packages/

2.合併TRANS.TBLDVD2TRANS.TBL的信息追加到DVD1TRANS.TBL後面並排序保存

cat  mnt/dvd2/Packages/TRANS.TBL >> /var/www/html/yum/centos-6/Packages/TRANS.TBL

Mv  /var/www/html/yum/centos-6/Packages/{TRANS.TBL,TRANS.TBL.BAK}

Sort  /var/www/html/yum/centos-6/Packages/TRANS.TBL.BAK/var/www/html/yum/centos-6/Packages/TRANS.TBL


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章