YUM(Yellow dog Updater Modified)为多个Linux发行版的软件包管理器,例如Redhat RHEL,CentOS&Fedoro。
YUM主要用于自动安装、升级rpm软件包,它能自动查找并解决rpm包之间的依赖关系。
YUM自动下载rpm包并安装。类似某软件的一键安装。
1.1 yum源是什么?
要成功的使用YUM工具安装更新软件或系统,就需要有一个包含各种rpm软件包的repository(软件仓库),这个软件仓库我们习惯称为yum源。
网络上有大量的yum源,但由于受到网络环境的限制,导致软件安装耗时过长甚至失败令人难以忍受特别是当有大量服务器大量软件包需要安装时,缓慢的进度条因此我们在优化系统时,都会更换国内的源。
相比较而言,本地YUM源服务器最大优点是局域网的快速网络连接和稳定性。有了局域网中的YUM源服务器,即便在Internet连接中断的情况下,也不会影响其他YUM客户端的软件安装和升级。
1.2 yum工作原理
1.2.1 yum配置文件
[root@nfs01yum_bak]# cat /etc/yum.conf
[main]定义了全局配置选项
cachedir=/var/cache/yum/$basearch/$releaseveryum缓存的目录,存储下载的rpm包和数据库
keepcache=0 是否保留安装包0为不保留,1为保留
debuglevel=2 debug信息输出等级,默认为2,范围0-10
logfile=/var/log/yum.log日志文件位置
exactarch=1 update的参数,相当于upgrade,允许更新旧的rpm包
obsoletes=1
有1和0两个选择,分别代表是否进行gpg(GNUPrivate Guard)校验,以确定rpm包的来源都是有效和安全的.这个选项如果设置在[main]部分,则对每个repository都有效.默认值 0
gpgcheck=1
plugins=1 是否启用插件,1表示允许,0不允许
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release 指定一个软件包
# This is the default, if you make this biggeryum won't see if the metadata
# is neweron the remote and so you'll "gain" the bandwidth of not having to
# downloadthe new metadata and "pay" for it by yum not having correct
#information.
# It is esp. important, to have correctmetadata, for distributions like
# Fedorawhich don't keep old packages around. If you don't like this checking
#interupting your command line usage, it's much better to have something
# manuallycheck the metadata once an hour (yum-updatesd will do this).
#metadata_expire=90m
# PUT YOURREPOS HERE OR IN separate files named file.repo
# in/etc/yum.repos.d
1.2.2 yum命令用法
1.2.3 查看rpm帮助
[root@m01~]# man rpm
RPM(8) RPM(8)
NAME
rpm - RPM Package Manager
SYNOPSIS
QUERYING AND VERIFYING PACKAGES:
rpm {-q|--query} [select-options][query-options]
rpm {-V|--verify} [select-options][verify-options]
rpm --import PUBKEY ...
rpm {-K|--checksig} [--nosignature][--nodigest]
PACKAGE_FILE ...
INSTALLING, UPGRADING, AND REMOVINGPACKAGES:
rpm {-i|--install} [install-options]PACKAGE_FILE ...
rpm {-U|--upgrade} [install-options]PACKAGE_FILE ...
rpm {-F|--freshen} [install-options]PACKAGE_FILE ...
rpm {-e|--erase} [--allmatches][--nodeps] [--noscripts]
[--notriggers] [--test] PACKAGE_NAME...
MISCELLANEOUS:
rpm {--initdb|--rebuilddb}
rpm {--addsign|--resign} PACKAGE_FILE...
rpm {--querytags|--showrc}
1.2.4 查看rpm包信息
[root@m01/server/scripts]# rpm -qpinginx-1.6.3-1.x86_64.rpm
Name : nginx Relocations: /
Version : 1.6.3 Vendor: root@m01
Release : 1 Build Date: 2016年06月26日 星期日 10时57分54秒
InstallDate: (not installed) BuildHost: m01
Group : default Source RPM:nginx-1.6.3-1.src.rpm
Size : 5252902 License: unknown
Signature : (none)
Packager : <root@m01>
URL : http://example.com/no-uri-given
Summary : no description given
Description:
nodescription given
1.2.5 查看rpm包内容
[root@m01~]# rpm -qvl nginx-1.6.3-1.x86_64.rpm
packagenginx-1.6.3-1.x86_64.rpm is not installed
1.2.6 查看rpm包的依赖
[root@m01~]# rpm -qpR nginx-1.6.3-1.x86_64.rpm
pcre-devel
openssl-devel
/bin/sh
rpmlib(PayloadFilesHavePrefix)<= 4.0-1
rpmlib(CompressedFileNames)<= 3.0.4-1
1.2.7 多个rpm包互相依赖强制安装
rpm -Uvh--aid *.rpm
或
rpm –ivh *.rpm--nodeps --force
1.2.8 查看rpm自带脚本
[root@m01~]# rpm -qp --scriptsnginx-1.6.3-1.x86_64.rpm
postinstallscriptlet (using /bin/sh):
#!/bin/bash
useraddnginx -M -s /sbin/nologin
ln -s/application/nginx-1.6.3/ /application/nginx
cp/application/nginx/sbin/* /usr/local/sbin/
1.3 安装createrepo软件
1.3.1 方法1
上传createrepo.tar.gz软件安装
[root@m01~]# cd /tmp/
[root@m01tmp]# ls
yum.log
[root@m01tmp]# rz -E
rz waitingto receive.
[root@m01tmp]# tar xf
createrepo.tar.gz .ICE-unix/ yum.log
[root@m01tmp]# tar xf createrepo.tar.gz
[root@m01tmp]# ls
createrepo-0.9.9-24.el6.noarch.rpm deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm yum.log
createrepo.tar.gz python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
[root@m01tmp]# rpm -ivh *.rpm
Preparing... ########################################### [100%]
1:deltarpm ########################################### [ 33%]
2:python-deltarpm ########################################### [ 67%]
3:createrepo ########################################### [100%]
1.3.2 方法2
[root@m01~]# yum -y install createrepo
已加载插件:fastestmirror, security
设置安装进程
Loadingmirror speeds from cached hostfile
epel/metalink | 5.5 kB 00:00
* base: mirrors.yun-idc.com
* epel: mirrors.neusoft.edu.cn
* extras: mirrors.yun-idc.com
* updates: mirrors.tuna.tsinghua.edu.cn
base | 3.7 kB 00:00
epel | 4.3 kB 00:00
epel/primary_db | 5.8 MB 00:25
extras | 3.4 kB 00:00
updates |3.4 kB 00:00
解决依赖关系
--> 执行事务检查
--->Package createrepo.noarch 0:0.9.9-24.el6 will be 安装
--> 处理依赖关系 python-deltarpm,它被软件包 createrepo-0.9.9-24.el6.noarch 需要
--> 执行事务检查
---> Packagepython-deltarpm.x86_64 0:3.5-0.5.20090913git.el6 will be 安装
--> 处理依赖关系 deltarpm =3.5-0.5.20090913git.el6,它被软件包python-deltarpm-3.5-0.5.20090913git.el6.x86_64 需要
--> 执行事务检查
--->Package deltarpm.x86_64 0:3.5-0.5.20090913git.el6 will be 安装
--> 完成依赖关系计算
依赖关系解决
====================================================================================================================
软件包 架构 版本 仓库 大小
====================================================================================================================
正在安装:
createrepo noarch 0.9.9-24.el6 base 96 k
为依赖而安装:
deltarpm x86_64 3.5-0.5.20090913git.el6 base 71 k
python-deltarpm x86_64 3.5-0.5.20090913git.el6 base 27 k
事务概要
====================================================================================================================
Install 3 Package(s)
总下载量:194 k
Installedsize: 520 k
下载软件包:
(1/3):createrepo-0.9.9-24.el6.noarch.rpm | 96 kB 00:00
(2/3):deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm | 71 kB 00:00
(3/3):python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm | 27 kB 00:00
--------------------------------------------------------------------------------------------------------------------
总计 422 kB/s | 194 kB 00:00
运行 rpm_check_debug
执行事务测试
事务测试成功
执行事务
Warning:RPMDB altered outside of yum.
正在安装 :deltarpm-3.5-0.5.20090913git.el6.x86_64 1/3
正在安装 :python-deltarpm-3.5-0.5.20090913git.el6.x86_64 2/3
正在安装 :createrepo-0.9.9-24.el6.noarch 3/3
Verifying : python-deltarpm-3.5-0.5.20090913git.el6.x86_64 1/3
Verifying : deltarpm-3.5-0.5.20090913git.el6.x86_64 2/3
Verifying : createrepo-0.9.9-24.el6.noarch 3/3
已安装:
createrepo.noarch 0:0.9.9-24.el6
作为依赖被安装:
deltarpm.x86_640:3.5-0.5.20090913git.el6 python-deltarpm.x86_64 0:3.5-0.5.20090913git.el6
完毕!
1.4 创建yum仓库目录
1.4.1.1 执行命令
mkdir -p /application/yum/centos6/x86_64/
cd /application/yum/centos6/x86_64/
1.4.1.2 执行结果
[root@m01~]# mkdir -p /application/yum/centos6/x86_64/
[root@m01~]# cd /application/yum/centos6/x86_64/
[root@m01/application/yum/centos6/x86_64]# cp/root/*.rpm .
[root@m01 /application/yum/centos6/x86_64]#ls -l
总用量 7100
-rw-r--r--1 root root 29456 6月 26 14:22 keyutils-libs-devel-1.4-5.el6.x86_64.rpm
-rw-r--r--1 root root 515904 6月 26 14:22 krb5-devel-1.10.3-57.el6.x86_64.rpm
-rw-r--r--1 root root 788956 6月 26 14:22 krb5-libs-1.10.3-57.el6.x86_64.rpm
-rw-r--r--1 root root 33424 6月 26 14:22 libcom_err-devel-1.41.12-22.el6.x86_64.rpm
-rw-r--r--1 root root 111508 6月 26 14:22 libselinux-2.0.94-7.el6.x86_64.rpm
-rw-r--r--1 root root 140160 6月 26 14:22 libselinux-devel-2.0.94-7.el6.x86_64.rpm
-rw-r--r--1 root root 84072 6月 26 14:22 libselinux-utils-2.0.94-7.el6.x86_64.rpm
-rw-r--r--1 root root 65484 6月 26 14:22 libsepol-devel-2.0.41-4.el6.x86_64.rpm
-rw-r--r--1 root root 2273453 6月 26 14:22 nginx-1.6.3-1.x86_64.rpm
-rw-r--r--1 root root 1597532 6月 26 14:22 openssl-1.0.1e-48.el6_8.1.x86_64.rpm
-rw-r--r--1 root root 1226260 6月 26 14:22openssl-devel-1.0.1e-48.el6_8.1.x86_64.rpm
-rw-r--r--1 root root 327960 6月 26 14:22 pcre-devel-7.8-7.el6.x86_64.rpm
-rw-r--r--1 root root 44984 6月 26 14:22 zlib-devel-1.2.3-29.el6.x86_64.rpm
1.4.2 单独指定软件包下载
yumdownloader pcre-devel
1.5 初始化repodata索引文件
1.5.1 第一次初始化
[root@m01/application/yum/centos6/x86_64]# createrepo-pdo /application/yum/centos6/x86_64/ /application/yum/centos6/x86_64/
Spawningworker 0 with 13 pkgs
WorkersFinished
Gatheringworker results
SavingPrimary metadata
Saving filelists metadata
Savingother metadata
Generatingsqlite DBs
Sqlite DBscomplete
[root@m01/application/yum/centos6/x86_64]# ls -l
总用量 7104
-rw-r--r--1 root root 29456 6月 26 14:22 keyutils-libs-devel-1.4-5.el6.x86_64.rpm
-rw-r--r--1 root root 515904 6月 26 14:22 krb5-devel-1.10.3-57.el6.x86_64.rpm
-rw-r--r--1 root root 788956 6月 26 14:22 krb5-libs-1.10.3-57.el6.x86_64.rpm
-rw-r--r--1 root root 33424 6月 26 14:22 libcom_err-devel-1.41.12-22.el6.x86_64.rpm
-rw-r--r--1 root root 111508 6月 26 14:22 libselinux-2.0.94-7.el6.x86_64.rpm
-rw-r--r--1 root root 140160 6月 26 14:22 libselinux-devel-2.0.94-7.el6.x86_64.rpm
-rw-r--r--1 root root 84072 6月 26 14:22 libselinux-utils-2.0.94-7.el6.x86_64.rpm
-rw-r--r--1 root root 65484 6月 26 14:22 libsepol-devel-2.0.41-4.el6.x86_64.rpm
-rw-r--r--1 root root 2273453 6月 26 14:22 nginx-1.6.3-1.x86_64.rpm
-rw-r--r--1 root root 1597532 6月 26 14:22 openssl-1.0.1e-48.el6_8.1.x86_64.rpm
-rw-r--r--1 root root 1226260 6月 26 14:22openssl-devel-1.0.1e-48.el6_8.1.x86_64.rpm
-rw-r--r--1 root root 327960 6月 26 14:22 pcre-devel-7.8-7.el6.x86_64.rpm
drwxr-xr-x2 root root 4096 6月 26 14:25 repodata
-rw-r--r--1 root root 44984 6月 26 14:22 zlib-devel-1.2.3-29.el6.x86_64.rpm
[root@m01/application/yum/centos6/x86_64]#
1.5.2 增加内容更新
createrepo -update /application/yum/centos6/x86_64/
1.6 共享目录
[root@m01/application/yum/centos6/x86_64]# cd/application/yum/centos6/x86_64/
[root@m01/application/yum/centos6/x86_64]# python-m SimpleHTTPServer 80 &>/dev/null &
[1] 6096
[root@m01/application/yum/centos6/x86_64]# ps -ef| grep 6096
root 6096 6019 0 14:29 pts/0 00:00:00 python -m SimpleHTTPServer 80
root 6098 6019 0 14:29 pts/0 00:00:00 grep --color=auto 6096
2.1 以nfs为客户端测试
2.1.1 备份
cd /etc/yum.repos.d
mkdir yum_bak&& mv *.repo yum_bak
2.1.2 建立新的文件
vim xeon.repo
[xeon]
name=Server
baseurl=http://10.0.0.61
enable=1
gpgcheck=0
[xeon]
name=Server
baseurl=http://172.16.1.61
enable=1
gpgcheck=0
2.2 查看安装包
[root@m01/etc/yum.repos.d]# yum clean all
已加载插件:fastestmirror, security
Cleaningrepos: oldboyedu
清理一切
Cleaning uplist of fastest mirrors
[root@nfs01/etc/yum.repos.d]# yum repolist
已加载插件:fastestmirror, security
Loadingmirror speeds from cached hostfile
仓库标识 仓库名称 状态
super Server 14
repolist:14
[root@nfs01/etc/yum.repos.d]# yum list
已加载插件:fastestmirror, security
Determiningfastest mirrors
oldboyedu | 2.9 kB 00:00
oldboyedu/primary_db | 12 kB 00:00
已安装的软件包
ConsoleKit.x86_64 0.4.1-3.el6 @anaconda-CentOS-201508042137.x86_64/6.7
ConsoleKit-libs.x86_64 0.4.1-3.el6 @anaconda-CentOS-201508042137.x86_64/6.7
MAKEDEV.x86_64 3.24-6.el6 @anaconda-CentOS-201508042137.x86_64/6.7
abrt.x86_64 2.0.8-34.el6.centos @anaconda-CentOS-201508042137.x86_64/6.7
abrt-addon-ccpp.x86_64 2.0.8-34.el6.centos @anaconda-CentOS-201508042137.x86_64/6.7
abrt-addon-kerneloops.x86_64 2.0.8-34.el6.centos @anaconda-CentOS-201508042137.x86_64/6.7
abrt-addon-python.x86_64 2.0.8-34.el6.centos @anaconda-CentOS-201508042137.x86_64/6.7
abrt-cli.x86_64 2.0.8-34.el6.centos @anaconda-CentOS-201508042137.x86_64/6.7
abrt-libs.x86_64 2.0.8-34.el6.centos @anaconda-CentOS-201508042137.x86_64/6.7
abrt-python.x86_64 2.0.8-34.el6.centos @anaconda-CentOS-201508042137.x86_64/6.7
abrt-tui.x86_64 2.0.8-34.el6.centos @anaconda-CentOS-201508042137.x86_64/6.7
acl.x86_64 2.2.49-6.el6 @anaconda-CentOS-201508042137.x86_64/6.7
acpid.x86_64 1.0.10-2.1.el6 @anaconda-CentOS-201508042137.x86_64/6.7
aic94xx-firmware.noarch 30-2.el6 @anaconda-CentOS-201508042137.x86_64/6.7
alsa-lib.x86_64 1.0.22-3.el6 @anaconda-CentOS-201508042137.x86_64/6.7
alsa-utils.x86_64 1.0.22-9.el6_6 @anaconda-CentOS-201508042137.x86_64/6.7
apr.x86_64 1.3.9-5.el6_2 @anaconda-CentOS-201508042137.x86_64/6.7
apr-util.x86_64 1.3.9-3.el6_0.1 @anaconda-CentOS-201508042137.x86_64/6.7
at.x86_64 3.1.10-48.el6 @anaconda-CentOS-201508042137.x86_64/6.7
atk.x86_64 1.30.0-1.el6 @anaconda-CentOS-201508042137.x86_64/6.7
atmel-firmware.noarch 1.3-7.el6 @anaconda-CentOS-201508042137.x86_64/6.7
attr.x86_64 2.4.44-7.el6 @anaconda-CentOS-201508042137.x86_64/6.7
audit.x86_64 2.3.7-5.el6 @anaconda-CentOS-201508042137.x86_64/6.7
audit-libs.x86_64 2.3.7-5.el6 @anaconda-CentOS-201508042137.x86_64/6.7
augeas-libs.x86_64 1.0.0-10.el6 @anaconda-CentOS-201508042137.x86_64/6.7
authconfig.x86_64 6.1.12-23.el6 @anaconda-CentOS-201508042137.x86_64/6.7
autoconf.noarch 2.63-5.1.el6 @anaconda-CentOS-201508042137.x86_64/6.7
automake.noarch 1.11.1-4.el6 @anaconda-CentOS-201508042137.x86_64/6.7
avahi-libs.x86_64 0.6.25-15.el6 @anaconda-CentOS-201508042137.x86_64/6.7
b43-fwcutter.x86_64 012-2.2.el6 @anaconda-CentOS-201508042137.x86_64/6.7
b43-openfwwf.noarch 5.2-10.el6 @anaconda-CentOS-201508042137.x86_64/6.7
basesystem.noarch 10.0-4.el6 @anaconda-CentOS-201508042137.x86_64/6.7
bash.x86_64 4.1.2-33.el6_7.1 @updates
bc.x86_64 1.06.95-1.el6 @anaconda-CentOS-201508042137.x86_64/6.7
bfa-firmware.noarch 3.2.23.0-2.el6 @anaconda-CentOS-201508042137.x86_64/6.7
省略
2.2.1 可安装的软件包
keyutils-libs-devel.x86_64 1.4-5.el6 oldboyedu
krb5-devel.x86_64 1.10.3-57.el6 oldboyedu
krb5-libs.x86_64 1.10.3-57.el6 oldboyedu
libcom_err-devel.x86_64 1.41.12-22.el6 oldboyedu
libselinux.x86_64 2.0.94-7.el6 oldboyedu
libselinux-devel.x86_64 2.0.94-7.el6 oldboyedu
libselinux-utils.x86_64 2.0.94-7.el6 oldboyedu
libsepol-devel.x86_64 2.0.41-4.el6 oldboyedu
nginx.x86_64 1.6.3-1 oldboyedu
openssl.x86_64 1.0.1e-48.el6_8.1 oldboyedu
openssl-devel.x86_64 1.0.1e-48.el6_8.1 oldboyedu
pcre-devel.x86_64 7.8-7.el6 oldboyedu
zlib-devel.x86_64 1.2.3-29.el6 oldboyedu
2.2.2 安装测试
[root@nfs01yum.repos.d]# yum install nginx
已加载插件:fastestmirror, security
设置安装进程
Loadingmirror speeds from cached hostfile
解决依赖关系
--> 执行事务检查
--->Package nginx.x86_64 0:1.6.3-1 will be 安装
--> 处理依赖关系 pcre-devel,它被软件包 nginx-1.6.3-1.x86_64 需要
--> 处理依赖关系 openssl-devel,它被软件包 nginx-1.6.3-1.x86_64 需要
--> 执行事务检查
--->Package openssl-devel.x86_64 0:1.0.1e-48.el6_8.1 will be 安装
--> 处理依赖关系 openssl = 1.0.1e-48.el6_8.1,它被软件包 openssl-devel-1.0.1e-48.el6_8.1.x86_64 需要
--> 处理依赖关系 zlib-devel,它被软件包 openssl-devel-1.0.1e-48.el6_8.1.x86_64 需要
--> 处理依赖关系 krb5-devel,它被软件包 openssl-devel-1.0.1e-48.el6_8.1.x86_64 需要
--->Package pcre-devel.x86_64 0:7.8-7.el6 will be 安装
--> 执行事务检查
--->Package krb5-devel.x86_64 0:1.10.3-57.el6 will be 安装
--> 处理依赖关系 krb5-libs = 1.10.3-57.el6,它被软件包 krb5-devel-1.10.3-57.el6.x86_64 需要
--> 处理依赖关系 libselinux-devel,它被软件包 krb5-devel-1.10.3-57.el6.x86_64 需要
--> 处理依赖关系 libcom_err-devel,它被软件包 krb5-devel-1.10.3-57.el6.x86_64 需要
--> 处理依赖关系 keyutils-libs-devel,它被软件包 krb5-devel-1.10.3-57.el6.x86_64 需要
--->Package openssl.x86_64 0:1.0.1e-42.el6_7.4 will be 升级
--->Package openssl.x86_64 0:1.0.1e-48.el6_8.1 will be an update
--->Package zlib-devel.x86_64 0:1.2.3-29.el6 will be 安装
--> 执行事务检查
--->Package keyutils-libs-devel.x86_64 0:1.4-5.el6 will be 安装
--->Package krb5-libs.x86_64 0:1.10.3-42z1.el6_7 will be 升级
--->Package krb5-libs.x86_64 0:1.10.3-57.el6 will be an update
--->Package libcom_err-devel.x86_64 0:1.41.12-22.el6 will be 安装
--->Package libselinux-devel.x86_64 0:2.0.94-7.el6 will be 安装
--> 处理依赖关系 libselinux = 2.0.94-7.el6,它被软件包 libselinux-devel-2.0.94-7.el6.x86_64 需要
--> 处理依赖关系 libsepol-devel >= 2.0.32-1,它被软件包 libselinux-devel-2.0.94-7.el6.x86_64 需要
--> 处理依赖关系 pkgconfig(libsepol),它被软件包 libselinux-devel-2.0.94-7.el6.x86_64 需要
--> 执行事务检查
--->Package libselinux.x86_64 0:2.0.94-5.8.el6 will be 升级
--> 处理依赖关系 libselinux = 2.0.94-5.8.el6,它被软件包 libselinux-utils-2.0.94-5.8.el6.x86_64 需要
---> Packagelibselinux.x86_64 0:2.0.94-7.el6 will be an update
--->Package libsepol-devel.x86_64 0:2.0.41-4.el6 will be 安装
--> 执行事务检查
--->Package libselinux-utils.x86_64 0:2.0.94-5.8.el6 will be 升级
--->Package libselinux-utils.x86_64 0:2.0.94-7.el6 will be an update
--> 完成依赖关系计算
依赖关系解决
===============================================================================================================================
软件包 架构 版本 仓库 大小
===============================================================================================================================
正在安装:
nginx x86_64 1.6.3-1 xeon 2.2 M
为依赖而安装:
keyutils-libs-devel x86_64 1.4-5.el6 xeon 29 k
krb5-devel x86_64 1.10.3-57.el6 xeon 504 k
libcom_err-devel x86_64 1.41.12-22.el6 xeon 33 k
libselinux-devel x86_64 2.0.94-7.el6 xeon 137 k
libsepol-devel x86_64 2.0.41-4.el6 xeon 64 k
openssl-devel x86_64 1.0.1e-48.el6_8.1 xeon 1.2 M
pcre-devel x86_64 7.8-7.el6 xeon 320 k
zlib-devel x86_64 1.2.3-29.el6 xeon 44 k
为依赖而更新:
krb5-libs x86_64 1.10.3-57.el6 xeon 770 k
libselinux x86_64 2.0.94-7.el6 xeon 109 k
libselinux-utils x86_64 2.0.94-7.el6 xeon 82 k
openssl x86_64 1.0.1e-48.el6_8.1 xeon 1.5 M
事务概要
===============================================================================================================================
Install 9 Package(s)
Upgrade 4 Package(s)
总下载量:6.9 M
确定吗?[y/N]:y
下载软件包:
(1/13):keyutils-libs-devel-1.4-5.el6.x86_64.rpm | 29 kB 00:00
(2/13):krb5-devel-1.10.3-57.el6.x86_64.rpm | 504 kB 00:00
(3/13):krb5-libs-1.10.3-57.el6.x86_64.rpm | 770 kB 00:00
(4/13):libcom_err-devel-1.41.12-22.el6.x86_64.rpm | 33 kB 00:00
(5/13):libselinux-2.0.94-7.el6.x86_64.rpm | 109 kB 00:00
(6/13):libselinux-devel-2.0.94-7.el6.x86_64.rpm | 137 kB 00:00
(7/13):libselinux-utils-2.0.94-7.el6.x86_64.rpm | 82 kB 00:00
(8/13):libsepol-devel-2.0.41-4.el6.x86_64.rpm | 64 kB 00:00
(9/13):nginx-1.6.3-1.x86_64.rpm | 2.2 MB 00:00
(10/13):openssl-1.0.1e-48.el6_8.1.x86_64.rpm | 1.5 MB 00:00
(11/13):openssl-devel-1.0.1e-48.el6_8.1.x86_64.rpm | 1.2 MB 00:00
(12/13):pcre-devel-7.8-7.el6.x86_64.rpm | 320 kB 00:00
(13/13):zlib-devel-1.2.3-29.el6.x86_64.rpm | 44 kB 00:00
-------------------------------------------------------------------------------------------------------------------------------
总计 32 MB/s | 6.9 MB 00:00
运行 rpm_check_debug
执行事务测试
事务测试成功
执行事务
正在升级 :libselinux-2.0.94-7.el6.x86_64 1/17
正在升级 :krb5-libs-1.10.3-57.el6.x86_64 2/17
正在升级 :openssl-1.0.1e-48.el6_8.1.x86_64 3/17
正在安装 :pcre-devel-7.8-7.el6.x86_64 4/17
正在安装 :zlib-devel-1.2.3-29.el6.x86_64 5/17
正在安装 :libsepol-devel-2.0.41-4.el6.x86_64 6/17
正在安装 :libselinux-devel-2.0.94-7.el6.x86_64 7/17
正在安装 : libcom_err-devel-1.41.12-22.el6.x86_64 8/17
正在安装 :keyutils-libs-devel-1.4-5.el6.x86_64 9/17
正在安装 : krb5-devel-1.10.3-57.el6.x86_64 10/17
正在安装 :openssl-devel-1.0.1e-48.el6_8.1.x86_64 11/17
正在安装 : nginx-1.6.3-1.x86_64 12/17
正在升级 :libselinux-utils-2.0.94-7.el6.x86_64 13/17
清理 : openssl-1.0.1e-42.el6_7.4.x86_64 14/17
清理 :krb5-libs-1.10.3-42z1.el6_7.x86_64 15/17
清理 :libselinux-utils-2.0.94-5.8.el6.x86_64 16/17
清理 :libselinux-2.0.94-5.8.el6.x86_64 17/17
Verifying : keyutils-libs-devel-1.4-5.el6.x86_64 1/17
Verifying : nginx-1.6.3-1.x86_64 2/17
Verifying : libcom_err-devel-1.41.12-22.el6.x86_64 3/17
Verifying : libselinux-utils-2.0.94-7.el6.x86_64 4/17
Verifying : libselinux-devel-2.0.94-7.el6.x86_64 5/17
Verifying : libsepol-devel-2.0.41-4.el6.x86_64 6/17
Verifying : libselinux-2.0.94-7.el6.x86_64 7/17
Verifying : zlib-devel-1.2.3-29.el6.x86_64 8/17
Verifying : openssl-devel-1.0.1e-48.el6_8.1.x86_64 9/17
Verifying : krb5-libs-1.10.3-57.el6.x86_64 10/17
Verifying : krb5-devel-1.10.3-57.el6.x86_64 11/17
Verifying : openssl-1.0.1e-48.el6_8.1.x86_64 12/17
Verifying : pcre-devel-7.8-7.el6.x86_64 13/17
Verifying : libselinux-2.0.94-5.8.el6.x86_64 14/17
Verifying : libselinux-utils-2.0.94-5.8.el6.x86_64 15/17
Verifying : krb5-libs-1.10.3-42z1.el6_7.x86_64 16/17
Verifying : openssl-1.0.1e-42.el6_7.4.x86_64 17/17
已安装:
nginx.x86_64 0:1.6.3-1
作为依赖被安装:
keyutils-libs-devel.x86_64 0:1.4-5.el6 krb5-devel.x86_64 0:1.10.3-57.el6 libcom_err-devel.x86_64 0:1.41.12-22.el6
libselinux-devel.x86_64 0:2.0.94-7.el6 libsepol-devel.x86_64 0:2.0.41-4.el6 openssl-devel.x86_64 0:1.0.1e-48.el6_8.1
pcre-devel.x86_64 0:7.8-7.el6 zlib-devel.x86_640:1.2.3-29.el6
作为依赖被升级:
krb5-libs.x86_64 0:1.10.3-57.el6 libselinux.x86_64 0:2.0.94-7.el6 libselinux-utils.x86_640:2.0.94-7.el6
openssl.x86_64 0:1.0.1e-48.el6_8.1
完毕!
2.2.3启动测试
[root@nfs01~]# /application/nginx/sbin/nginx
[root@nfs01~]# curl -I 10.0.0.61
HTTP/1.0200 OK
Server: SimpleHTTP/0.6Python/2.6.6
Date: Tue,28 Jun 2016 03:36:03 GMT
Content-type:text/html; charset=UTF-8
Content-Length:1416
2.3 镜像同步公网yum源
上面只是将自己制作的rpm包,放入yum源。但还有一种企业需求,说的更具体一点,平时学生上课yum安装软件都是从公网下载的,占用带宽,因此在学校里搭建一个内网yum服务器,但又考虑到学生回家也要使用yum安装软件,如果yum软件的数据库文件repodata不一样,就会有问题。因此我 想到的解决方法就是直接使用公网yum源的repodata。
上游yum源必须要支持rsync协议,否则不能使用rsync进行同步。
http://mirrors.ustc.edu.cn/status/
CentOS官方标准源:rsync://mirrors.ustc.edu.cn/centos/
epel源:rsync://mirrors.ustc.edu.cn/epel/
2.3.1 同步命令:
使用rsync同步yum源,为了节省带宽、磁盘和下载时间,我只同步了CentOS6的rpm包,这样所有的rpm包只占用了21G,全部同步需要300G左右。
同步base源,小技巧,我们安装系统的光盘镜像含有部分rpm包,大概3G,这些就不用重新下载。
/usr/bin/rsync-av rsync://mirrors.ustc.edu.cn/centos/6/os/x86_64/ /data/yum_data/centos/6/os/x86_64/
/usr/bin/rsync-av rsync://mirrors.ustc.edu.cn/centos/6/extras/x86_64/ /data/yum_data/centos/6/extras/x86_64/
/usr/bin/rsync-av rsync://mirrors.ustc.edu.cn/centos/6/updates/x86_64/ /data/yum_data/centos/6/updates/x86_64/
# epel源
/usr/bin/rsync-av --exclude=debug rsync://mirrors.ustc.edu.cn/epel/6/x86_64/ /data/yum_data/epel/6/x86_64/
2.3.2 学生使用内网yum源方法
# 可以自建一个内网dns,如果没有,可使用hosts解析。
echo'192.168.0.200 mirrors.aliyun.com' >>/etc/hosts
2.3.3 结果展示
[root@KVMdata]# du -sh yum_data
21G yum_data
[root@KVMdata]# tree -L 3 yum_data/
yum_data/
├── centos
│ ├── 6
│ │ ├── extras
│ │ ├── os
│ │ └── updates
│ └── RPM-GPG-KEY-CentOS-6
├── epel
│ └── 6
│ └── x86_64
2.4 报错
2.4.1解决yum本地客户端failed to retrieve错误
下载软件包出错:
ruby-libs-1.8.7.374-4.el6_6.x86_64: failed to retrieveruby-libs-1.8.7.374-4.el6_6.x86_64.rpm from xeon
error was[Errno 2] Local file does not exist:/etc/yum.repos.d/pdate/ruby-libs-1.8.7.374-4.el6_6.x86_64.rpm
ruby-1.8.7.374-4.el6_6.x86_64: failed toretrieve ruby-1.8.7.374-4.el6_6.x86_64.rpm from xeon
error was[Errno 2] Local file does not exist: /etc/yum.repos.d/pdate/ruby-1.8.7.374-4.el6_6.x86_64.rpm
解决方法
[root@m01~]# cat /server/scripts/start_yum.sh
#!/bin/sh
#date:2016.07.11from xeon
#start yumwarehouse
cd /application/yum/centos6/x86_64
/usr/bin/python-m SimpleHTTPServer 80 &>/dev/null &
[root@m01~]# cat /server/scripts/restart_yum.sh
#!/bin/sh
#date:2016.07.11from xeon
#killpython and restart yum warehouse
/usr/bin/pkillpython
cd/application/yum/centos6/x86_64/
/bin/rm -rfrepodata/
/usr/bin/createrepo-pdo /application/yum/centos6/x86_64/ /application/yum/centos6/x86_64/
2.4.2注意本地防火墙
参考链接:http://blog.oldboyedu.com/autodeploy-yum/