Redhat下YUM服务器的搭建

这几天有大批量的机器需要打包并配置snmp服务,suse下有yast可以用,Redhat下有YUM可以用,我都实际动手搞了下。本篇是Redhat下的YUM配置文档。

 

零、本地文件源

1、本地光驱挂载源

有光驱的服务器,挂载光盘到本地。

[root@asmdb yum.repos.d]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       97G   12G   80G  13% /
/dev/sda1              99M   33M   61M  36% /boot
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/dev/hdc              3.4G  3.4G     0 100% /mnt/cdiso


cd /etc/yum.repos.d

vi mycdyum.repo

[mycdyum]                  ##可以随便自己取
name=LocalYumResource        ##可以随便自己取
baseurl=file:///mnt/localiso/Server    ##rpm包所在目录,一般只写挂载点会报错。
enabled=1             ##启用该配置文件
gpgcheck=0          ##禁用key文件检查


yum  clean

yum  list

(补充:     echo 'multilib_policy=all' >> /etc/yum.conf     )



如果遇到“Error: Cannot retrieve repository metadata (repomd.xml) for repository”, 在repo文件或者/etc/yum.conf增加以下选项

skip_if_unavailable=True

2、本地ISO文件挂载

cd /soft

[root@asmdb soft]# ls
asm  database  Disk1  rhel-server-5.4-x86_64-dvd.iso rpm

[root@asmdb soft]# mount -o loop /soft/rhel-server-5.4-x86_64-dvd.iso /mnt/localiso

[root@asmdb soft]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       97G   12G   80G  13% /
/dev/sda1              99M   33M   61M  36% /boot
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/soft/rhel-server-5.4-x86_64-dvd.iso
                      3.4G  3.4G     0 100% /mnt/localiso

cd /etc/yum.repos.d

vi mycdyum.repo
[rhel-debuginfo]
name=LocalYumResource
##baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
baseurl=file:///mnt/cdiso/Server
enabled=1
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

yum  clean

yum  list

3、本地rpm文件

将iso镜像文件先在自己笔记本上解压到文件夹rpms,然后将文件夹上传到服务器/soft目录

cd /soft/

[root@asmdb soft]# ls
asm  database  Disk1  rpms

[root@asmdb rpms]# ls  /soft/rpms
Cluster                RELEASE-NOTES-ko.html     RELEASE-NOTES-U4-kn.html
ClusterStorage         RELEASE-NOTES-ml.html     RELEASE-NOTES-U4-ko.html
EULA                   RELEASE-NOTES-mr.html     RELEASE-NOTES-U4-ml.html
eula.en_US             RELEASE-NOTES-or.html     RELEASE-NOTES-U4-mr.html
GPL                    RELEASE-NOTES-pa.html     RELEASE-NOTES-U4-or.html
images                 RELEASE-NOTES-pt_BR.html  RELEASE-NOTES-U4-pa.html
isolinux               RELEASE-NOTES-ru.html     RELEASE-NOTES-U4-pt_BR.html
README-en              RELEASE-NOTES-si.html     RELEASE-NOTES-U4-ru.html
README-en.html         RELEASE-NOTES-ta.html     RELEASE-NOTES-U4-si.html
RELEASE-NOTES-as.html  RELEASE-NOTES-te.html     RELEASE-NOTES-U4-ta.html
RELEASE-NOTES-bn.html  RELEASE-NOTES-U4-as.html  RELEASE-NOTES-U4-te.html
RELEASE-NOTES-de.html  RELEASE-NOTES-U4-bn.html  RELEASE-NOTES-U4-zh_CN.html
RELEASE-NOTES-en       RELEASE-NOTES-U4-de.html  RELEASE-NOTES-U4-zh_TW.html
RELEASE-NOTES-en.html  RELEASE-NOTES-U4-en       RELEASE-NOTES-zh_CN.html
RELEASE-NOTES-es.html  RELEASE-NOTES-U4-en.html  RELEASE-NOTES-zh_TW.html
RELEASE-NOTES-fr.html  RELEASE-NOTES-U4-es.html  RPM-GPG-KEY-redhat-beta
RELEASE-NOTES-gu.html  RELEASE-NOTES-U4-fr.html  RPM-GPG-KEY-redhat-release
RELEASE-NOTES-hi.html  RELEASE-NOTES-U4-gu.html  Server                     --------这个Server文件夹里装的全部是rpm包
RELEASE-NOTES-it.html  RELEASE-NOTES-U4-hi.html  TRANS.TBL
RELEASE-NOTES-ja.html  RELEASE-NOTES-U4-it.html  VT
RELEASE-NOTES-kn.html  RELEASE-NOTES-U4-ja.html

cd /etc/yum.repos.d

vi mycdyum.repo
[rhel-debuginfo]
name=YumRpms

baseurl=file:///soft/rpms/Server
enabled=1
gpgcheck=0


yum  clean

yum  list


 

一、搭建NFS Server

10.1.123.60

查看挂载上来的光盘

[root@localhost RHEL_5.4 x86_64 DVD]# df -h

FilesystemSizeUsed Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

97G9.8G82G11% /

/dev/sda199M13M82M14% /boot

tmpfs 2.0G 0 2.0G 0% /dev/shm

/dev/hdc 3.4G 3.4G 0 100% /media/RHEL_5.4 x86_64 DVD

创建rpm包目录,拷贝光盘,将RHEL 5光盘中的ServerVTClusterClusterStorage四个目录复制到/var/ftp/pub下(如不使用虚拟化及群集后三个目录可不复制)。

mkdir –p/yumrepo/RHEL5.4

# cd /media/RHEL_5.4 x86_64 DVD/

cp -r /media/RHEL_6.0 x86_64 Disc 1/*.* /yumrepo/RHEL6

[root@localhost RHEL_5.4 x86_64 DVD]# cp -ar * /yumrepo/RHEL5.4/

查询nfs需要的安装包是否已经安装

[root@localhost yumrepo]#rpm -qa |grep nfs

nfs-utils-lib-1.0.8-7.6.el5

nfs-utils-1.0.9-42.el5

[root@localhost yumrepo]#rpm -qa |grep portmap

portmap-4.0-65.2.2.1

配置nfs共享参数文件

[root@localhost yumrepo]# vi /etc/exports

添加如下部分

/yumrepo/RHEL6/*(ro,sync,no_root_squash,no_all_squash)

[root@localhost yumrepo]# more /etc/exports

/yumrepo/RHEL6/*(ro,sync,no_root_squash,no_all_squash)

重新载入参数文件,不必重启nfs服务的小技巧

[root@localhost yumrepo]# exportfs -rv

exporting *:/yumrepo/RHEL6

查看已经分享出来的目录

[root@localhost yumrepo]# showmount -e

mount clntudp_create: RPC: Program not registered

发现没有起到nfs服务,那么启动吧

[root@localhost yumrepo]#service nfs start

Starting NFS services:[OK]

Starting NFS quotas: [OK]

Starting NFS daemon: [OK]

Starting NFS mountd: [OK]

再次查看共享出的目录

[root@localhost yumrepo]# showmount -e

Export list for localhost.localdomain:

/yumrepo/RHEL6 *

二、搭建YUM Server

10.1.123.60

[root@localhost yumrepo]# rpm -qa | grep yum

yum-3.2.22-20.el5

yum-security-1.1.16-13.el5

yum-metadata-parser-1.1.2-3.el5

yum-updatesd-0.9-2.el5

yum-rhn-plugin-0.5.4-13.el5

[root@localhost yumrepo]# rpm -qa | grep createrepo

[root@localhost Server]# rpm -ivh createrepo-0.4.11-3.el5.noarch.rpm

warning: createrepo-0.4.11-3.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186

Preparing...########################################### [100%]

1:createrepo########################################### [100%]

建立分组文件:

RHEL 5中每个目录下的repodata目录下都有一个repomd.xml,该文件中就记录了rpm包的依赖关系,还有一个comps-rhel5-*.xml文件,这个文件主要记录分组情况,建立yum仓库时,需要先重建该文件。

Xml文件做个简单展示,不一一列举:

[root@localhost Server]# ls -al /yumrepo/RHEL5.4/Server/repodata/*.xml

-r--r--r-- 1 root root 1027081 Aug 192009 /yumrepo/RHEL5.4/Server/repodata/comps-rhel5-server-core.xml

-r--r--r-- 1 root root1314 Aug 192009 /yumrepo/RHEL5.4/Server/repodata/repomd.xml

[root@localhost Server]# ls -al /yumrepo/RHEL5.4/Cluster/repodata/*.xml

-r--r--r-- 1 root root 102997 Aug 192009 /yumrepo/RHEL5.4/Cluster/repodata/comps-rhel5-cluster.xml

-r--r--r-- 1 root root1310 Aug 192009 /yumrepo/RHEL5.4/Cluster/repodata/repomd.xml

[root@localhost Server]# ls -al /yumrepo/RHEL5.4/ClusterStorage/repodata/*.xml

-r--r--r-- 1 root root 107900 Aug 192009 /yumrepo/RHEL5.4/ClusterStorage/repodata/comps-rhel5-cluster-st.xml

-r--r--r-- 1 root root1313 Aug 192009 /yumrepo/RHEL5.4/ClusterStorage/repodata/repomd.xml

这里需要重新建立目录只有Server,其他的因为无集群所以暂时不用不上:

[root@localhost Server]#createrepo -g /yumrepo/RHEL5.4/Server/repodata/comps-rhel5-server-core.xml/yumrepo/RHEL5.4/Server/

结束之后,会看到如下字样

[root@localhost Server]# createrepo -g /yumrepo/RHEL5.4/Server/repodata/comps-rhel5-server-core.xml/yumrepo/RHEL5.4/Server/

3040/3040 - gnome-keyring-0.6.0-1.fc6.i386.rpmrpm

Saving Primary metadata

Saving file lists metadata

Saving other metadata

三、搭建YUM Client

10.1.123.61

先确认是否已经安装yum

[root@localhost ~]# rpm -qa | grep yum

yum-3.2.22-20.el5

yum-security-1.1.16-13.el5

yum-metadata-parser-1.1.2-3.el5

yum-updatesd-0.9-2.el5

yum-rhn-plugin-0.5.4-13.el5

yum客户端定义库文件(/etc/yum.repos.d/rhel-debuginfo.repo)复制备份一份(名称任意,但必须以.repo结尾)修改其bashurl及名称即可。

[root@localhost yum.repos.d]# ls

rhel-debuginfo.reporhel-debuginfo.repo.bak

配置客户端参数文件:

[root@localhost yum.repos.d]# vi rhel-debuginfo.repo

[rhel-debuginfo]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[Server]

name=Server

#baseurl=file:///mnt/yumrepofile/Server/Packages

baseurl=file:///mnt/yumrepofile/Server

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

~

重新加载客户端yum配置参数:

[root@localhost yum.repos.d]#yumclean all

Loaded plugins: rhnplugin, security

Cleaning up Everything

测试安装:

[root@localhost yum.repos.d]#yum install mysql

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Server | 1.1 kB 00:00

Server/primary| 1.0 MB00:00

Server 3040/3040

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package mysql.i386 0:5.0.77-3.el5 set to be updated

--> Processing Dependency: perl(DBI) for package: mysql

---> Package mysql.x86_64 0:5.0.77-3.el5 set to be updated

--> Running transaction check

---> Package perl-DBI.x86_64 0:1.52-2.el5 set to be updated

--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================

PackageArchVersionRepositorySize

===============================================================================================

Installing:

mysqli3865.0.77-3.el5Server4.8 M

mysqlx86_645.0.77-3.el5Server4.8 M

Installing for dependencies:

perl-DBIx86_641.52-2.el5Server605 k

Transaction Summary

===============================================================================================

Install 3 Package(s)

Update 0 Package(s)

Remove 0 Package(s)

Total download size: 10 M

Is this ok [y/N]:N这里是测试,所以不安装,选择N,实际安装中应该选择Y

Exiting on user Command

Complete!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值