RHEL6___构建基于vsftd的YUM源服务器
1.为什么要构建本地YUM源
在Linux主机中使用YUM客户端工具在线升级、安装软件时,由于受到网络连接速度、网络带宽的限制,往往给用户安装带来不必要的麻烦。但是如果在局域网中构建一个基于本地的YUM源服务器,则可以大大解决用户安装软件速度较慢的问题。
2.如何构建本地YUM源
思路:可以通过从rhel6安装光盘获取需要的rpm包,结合使用HTTP或FTP协议,即可构建一个位于本地局域网的YUM源服务器
实现步骤
(1)安装createrepo工具
createrepoa主要用于收集目录中的rpm包文件的头信息,以创建repodata软件仓库数据(经gzip压缩的xml文件)。
mount /dev/cdrom /media/cdrom/ //挂载光盘
rpm -ivh /media/cdrom/Packages/createrepo-0.9.8-4.el6.noarch.rpm
(2)安装FTP服务器
rpm -ivh /media/cdrom/Packages/vsftpd
(3)配置软件仓库目录
可参考安装光盘的Server目录
mkdir /var/ftp/pub/Packages
mkdir /var/ftp/pub/repodata
从光盘把所有的RPM包复制到/var/ftp/pub/Packages目录下(要确保硬盘有足够的磁盘空间)
cp -rv /media/cdrom/Packages/* /var/ftp/pub/Packages/
(3)创建软件仓库信息文件
cd /var/ftp/pub/
createrepo --database ./
[root@server pub]# ls repodata/
filelists.sqlite.bz2 other.sqlite.bz2 primary.sqlite.bz2 repomd.xml
filelists.xml.gz other.xml.gz primary.xml.gz
可以看到已经创建好了相应的软件仓库信息文件
(4)启动vsftpd服务
service vsftpd start
chkconfig --level 35 vsftpd on
(5)在另一台客户端测试,首先创建repo文件指定YUM源位置
vi /etc/yum.repos.d/server1.repo,注意文件的扩展名要以repo结尾,文件内容如下
[rhel6] //软件仓库的名字
name=rhel6 //软件仓库的描述
baseurl=ftp://192.168.100.1/pub //软件仓库的位置
enabled=1 //是否起用软件仓库
gpgcheck=1 //是否检查GPG签名(用来验证要安装的包是不是REDHAT官方的)
gpgkey=file://etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release GPG签名密钥的位置
使用yum客户工具安装samba
[root@mail ~]# yum -y install samba*
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Package samba-winbind-clients-3.5.4-68.el6.x86_64 already installed and latest version
Package samba-common-3.5.4-68.el6.x86_64 already installed and latest version
Package samba-client-3.5.4-68.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package samba.x86_64 0:3.5.4-68.el6 set to be updated
---> Package samba-winbind.x86_64 0:3.5.4-68.el6 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================
Package Arch Version Repository Size
===================================================================================
Installing:
samba x86_64 3.5.4-68.el6 rhel6 5.0 M
samba-winbind x86_64 3.5.4-68.el6 rhel6 3.6 M
Transaction Summary
===================================================================================
Install 2 Package(s)
Upgrade 0 Package(s)
Total download size: 8.6 M
Installed size: 30 M
Downloading Packages:
(1/2): samba-3.5.4-68.el6.x86_64.rpm | 5.0 MB 00:00
(2/2): samba-winbind-3.5.4-68.el6.x86_64.rpm | 3.6 MB 00:00
-----------------------------------------------------------------------------------
Total 25 MB/s | 8.6 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : samba-winbind-3.5.4-68.el6.x86_64 1/2
Installing : samba-3.5.4-68.el6.x86_64 2/2
Installed:
samba.x86_64 0:3.5.4-68.el6 samba-winbind.x86_64 0:3.5.4-68.el6
Complete!
查询samba软件包是否正确安装
[root@mail ~]# rpm -qa | grep samba
samba-3.5.4-68.el6.x86_64
samba-client-3.5.4-68.el6.x86_64
samba-winbind-clients-3.5.4-68.el6.x86_64
samba-common-3.5.4-68.el6.x86_64
samba-winbind-3.5.4-68.el6.x86_64
大功告成。关于 yum 工具的使用,我会在以后讲解。
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 导入签名密钥
转载于:https://blog.51cto.com/xiaofeixia/571033