1、启动系统,我是用iso镜像挂载,挂载到/media/cdrom
mkdir /media/cdrom
mount -a -t iso9660 -o loop /home/user1/CentOS-5.6-i386-bin-DVD.iso /media/cdrom
2、安装FTP服务(如果系统已带则在桌面 管理-服务器设置-服务 可以很方便的启动vsftpd服务)
cd /media/cdrom/CentOS
rpm -ivh vsftpd*
chkconfig vsftpd on
service vsftpd start
3、安装createrepo的软件包
cd /media/cdrom/CentOS
rpm -ivh createrepo*
4、拷贝系统盘里的文件到本机
cp -R /media/cdrom/CentOS /var/ftp/pub
cp -R /media/cdrom/repodata /var/ftp/pub
5、生成yum源
(1)生成依赖关系
[root@flyinweb repodata]# createrepo -g /var/ftp/pub/repodata/comps.xml /var/ftp/pub/CentOS/
2682/2682 - nfs-utils-lib-devel-1.0.8-7.6.el5.i386.rpm                         
Saving Primary metadata
Saving file lists metadata
Saving other metadata


若提示“Could not remove old metadata dir: .olddata”说目录有问题,不用在意,直接把目录删除掉就行了
rm -rf /var/ftp/pub/CentOS/.olddata
然后重新操作一遍就行了
(2)建立仓库文件
vim /etc/yum.repos.d/yum.repo
[Yum-ftp]
name=base
baseurl=ftp://yourip/pub/CentOS/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

下一次安装rpm直接用yum安装就可以了。如果其他机器需要访问此源的话把yum.repo拷过去就行了
yum install wireshark
OK成功

另,如果是redhat,或fedora, 得检查gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 这个文件,只需进入目录/etc/pki/rpm-gpg/查看是哪个文件即可,否则会报错如下
yum install wireshark
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
不过错了也没关系,这是因为yum安装了不同版本的GPG keys造成的,按上述方法解决,或者
rpm --import /etc/pki/rpm-gpg/RPM*
再重新yum install wireshark

OK,问题解决,已经装上了
yum install wireshark。注意这样并无法使用wireshark命令和图形界面。但提供了抓包基本功能。
yum install wireshark-gnome。这样就可以方便的使用了。

OK,进入桌面可以正常启动wireshark

*****

Sometimes it can be handy to set up your own repository to prevent from downloading the remote repository over and over again. This tutorial shows how to create a CentOS mirror for your local network. If you have to install multiple systems in your local network then all needed packages can be downloaded over the fast LAN connection, thus saving your internet bandwidth.

Create the Directories:

mkdir -pv /var/www/html/centos/4/{os,updates}/i386

Replacing 4 and i386 with your major version and architecture.
Additionally you'll need some deeper directories. This is the correct location to copy the CD/DVD rpms.

Quote:
mkdir -pv /var/www/html/centos/4/os/i386/CentOS/RPMS/

The Base Repository

Copy the RPMs from the CDs/DVD to /var/www/html/centos/base.

Create the base repository headers:

createrepo /var/www/html/centos/4/os/i386/

The Updates Repository

Select an rsync mirror for updates: check out this list of aviable mirrors: Centos OS Mirror list and these are identified with rsync.

For example: rsync://ftp.belnet.be/packages/centos/

The mirrors share a common structure for updates. Simply append /updates/<d version>/<base arch>.

Rsync to create the updates-released repository:

/usr/bin/rsync -avrt rsync://ftp.riken.jp/centos/4/updates/i386 --exclude=debug/ /var/www/html/centos/4/updates/

This will create a complete update repository at /var/www/html/centos/4/updates/i386. The repodata directory will be created with all of the headers.

You can additionally pipe this into mail to receive an email when updates are available.

/usr/bin/rsync -avrt rsync://ftp.riken.jp/centos/4/updates/i386 --exclude=debug /var/www/html/centos/4/updates/ | /bin/mail you@example.com -s "New Repo Updates"

Next I would advise to setup a cron job to run the rsync (above). In this manner your repository is kept updated and only new updates and headers will be downloaded to your repository.

Yum Configuration

Edit yum.conf:

vi /etc/yum.repos.d/CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
baseurl=http://192.168.*.*/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#released updates
[update]
name=CentOS-$releasever - Updates
baseurl=http://192.168.*.*/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

That's it.

Configuring local yum repository for CentOS 5.5

Configuring Yum Server

Step 1:

Check if vsftpd is installed on your system or not
[root@ns1 ~]# rpm -q vsftpd
package vsftpd is not installed

Step 2:

Insert the media and if vsftpd is not already installed on your system install it
[root@ns1 ~]# cd /media/CentOS_5.5_Final/CentOS/
[root@ns1 CentOS]# rpm -ivh vsftpd-2.0.5-16.el5_4.1.i386.rpm
warning: vsftpd-2.0.5-16.el5_4.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:vsftpd ########################################### [100%]
[root@ns1 CentOS]#

Step 3:

copy the contents of media in /var/ftp/pub/centos5.5/.
[root@ns1 CentOS]# cp -rvf /media/CentOS_5.5_Final/ /var/ftp/pub/centos5.5/

You can also use .iso file without extracting packages from it. So, in this case you will have to do the following instead of using cp command as shown above.
[root@ns1 CentOS]# mkdir /var/ftp/pub/centos5.5
[root@ns1 CentOS]# mount -o loop CentOS-5.5-i386-bin-DVD.iso /var/ftp/pub/centos5.5

You will have to make an entry in /etc/fstab so that the contents of .iso should be available in /var/ftp/pub/rhel5.4 on your next reboot.
/root/CentOS-5.5-i386-bin-DVD.iso /var/ftp/pub/centos5.5/ iso9660 defaults,loop 0 0
here I am assuming that your .iso image is stored in /root directory.

Step 4:

As we want to use our local repository for package instalaltion, we will move the two files in /etc/yum.repos.d/ to /root. We can also change the value of enabled=0 in these files. In this case there will be no need to move them from /etc/yum.repos.d/
[root@ns1 CentOS]# cd /etc/yum.repos.d/
[root@ns1 yum.repos.d]# ll
total 16
-rw-r--r-- 1 root root 2245 Apr 25 2010 CentOS-Base.repo
-rw-r--r-- 1 root root 626 Apr 25 2010 CentOS-Media.repo
[root@ns1 yum.repos.d]# mv CentOS-* /root/

Step 5:

Create a file named base.repo in /etc/yum.repos.d with the following contents
[base]
name=CentOS Base
baseurl=ftp://192.168.1.250/pub/centos5.5/
enabled=1
gpgcheck=0
192.168.1.250 is the ip address of your system which you are configuring as yum server.

You can also use the baseurl as shown below. If you choose the above you need step 6, if you choose below configuration, you need don't need step 6.
[base]
name=CentOS Base
baseurl=file:///var/ftp/pub/centos5.5/
enabled=1
gpgcheck=0

Step 6:

You need to start vsftpd demon and mark it on at runlevel 345 so that this service starts automatically no next reboot.
[root@ns1 yum.repos.d]# service vsftpd restart
Shutting down vsftpd: [FAILED]
Starting vsftpd for vsftpd: [ OK ]
[root@ns1 yum.repos.d]# chkconfig vsftpd --level 345 on
Step 6 is must if your server is going to act as a yum server for other clients.

Configuring yum client

Step 1:

Create a file named base.repo in /etc/yum.repos.d with the following contents
[base]
name=CentOS Base
baseurl=ftp://192.168.1.250/pub/centos5.5/
enabled=1
gpgcheck=0


And your system is ready to send request to yum server.

Configuring local yum repository for RHEL5.4

Configuring Yum Server

Step 1:

Check if vsftpd is installed on your system or not
[root@ns1 ~]# rpm -q vsftpd
package vsftpd is not installed

Step 2:

Insert the media and if vsftpd is not already installed on your system install it
[root@ns1 ~]# cd /media/RHEL_5.4\ i386\ DVD/Server/
[root@ns1 Server]# rpm -ivh vsftpd-2.0.5-16.el5_4.1.i386.rpm
warning: vsftpd-2.0.5-16.el5_4.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing... ########################################### [100%]
1:vsftpd ########################################### [100%]
[root@ns1 Server]#

Step 3:

copy the contents of media in /var/ftp/pub/rhel5.4/.
[root@ns1 Server]# cp -rvf /media/RHEL_5.4\ i386\ DVD/ /var/ftp/pub/rhel5.4/

You can also use .iso file without extracting packages from it. So, in this case you will have to do the following instead of using cp command as shown above.
# mkdir /var/ftp/pub/rhel5.4
# mount -o loop rhel-server-5.4-i386-dvd.iso /var/ftp/pub/rhel5.4

You will have to make an entry in /etc/fstab so that the contents of .iso should be available in /var/ftp/pub/rhel5.4 on your next reboot.
/root/rhel-server-5.4-i386-dvd.iso /var/ftp/pub/rhel5.4/ iso9660 defaults,loop 0 0
here I am assuming that your .iso image is stored in /root directory.

Step 5:

Create a file named base.repo in /etc/yum.repos.d with the following contents
[base]
name=rhel5.4 base
baseurl=ftp://192.168.1.250/pub/rhel5.4/Server
enabled=1
gpgcheck=0

[Cluster]
name=rhel5.4 Cluster
baseurl=ftp://192.168.1.250/pub/rhel5.4/Cluster
enabled=1
gpgcheck=0

[ClusterStorage]
name=rhel5.4 ClusterStorage
baseurl=ftp://192.168.1.250/rhel5.4/ClusterStorage
enabled=1
gpgcheck=0

[VT]
name=rhel5.4 VT
baseurl=ftp://192.168.1.250/pub/rhel5.4/VT
enabled=1
gpgcheck=0
192.168.1.250 is the ip address of your system which you are configuring as yum server.

You can also use the baseurl as shown below. If you choose the above you need step 6, if you choose below configuration, you need don't need step 6.
[base]
name=rhel5.4 base
baseurl=file:///var/ftp/pub/rhel5.4/Server
enabled=1
gpgcheck=0

[Cluster]
name=rhel5.4 Cluster
baseurl=file:///var/ftp/pub/rhel5.4/Cluster
enabled=1
gpgcheck=0

[ClusterStorage]
name=rhel5.4 ClusterStorage
baseurl=file:///var/ftp/pub/rhel5.4/ClusterStorage
enabled=1
gpgcheck=0

[VT]
name=rhel5.4 VT
baseurl=file:///var/ftp/pub/rhel5.4/VT
enabled=1
gpgcheck=0

Step 6:

You need to start vsftpd demon and mark it on at runlevel 345 so that this service starts automatically no next reboot.
[root@ns1 yum.repos.d]# service vsftpd restart
Shutting down vsftpd: [FAILED]
Starting vsftpd for vsftpd: [ OK ]
[root@ns1 yum.repos.d]# chkconfig vsftpd --level 345 on
Step 6 is must if your server is going to act as a yum server for other clients.

Configuring yum client

Step 1:

Create a file named base.repo in /etc/yum.repos.d with the following contents
[base]
name=rhel5.4 base
baseurl=ftp://192.168.1.250/pub/rhel5.4/Server
enabled=1
gpgcheck=0

[Cluster]
name=rhel5.4 Cluster
baseurl=ftp://192.168.1.250/pub/rhel5.4/Cluster
enabled=1
gpgcheck=0

[ClusterStorage]
name=rhel5.4 ClusterStorage
baseurl=ftp://192.168.1.250/rhel5.4/ClusterStorage
enabled=1
gpgcheck=0

[VT]
name=rhel5.4 VT
baseurl=ftp://192.168.1.250/pub/rhel5.4/VT
enabled=1
gpgcheck=0

And your system is ready to send request to yum server.

此文章由 flyinweb 于 2011-06-01 09:18:18 编辑

本日志由 flyinweb 于 2011-05-31 18:14:27 发表,目前已经被浏览 1436 次,评论 0 次;

作者添加了以下标签: yum

引用通告:http://www.517sou.net/Article/613/Trackback.ashx

评论订阅:http://www.517sou.net/Article/613/Feeds.ashx

评论列表

    暂时没有评论
(必填)
(必填,不会被公开)