7.1 安装软件包的三种方法7.2 rpm包介绍 7.3 rpm工具用法 7.4 yum工具用法7.5 yum搭建本地仓库
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了7.1 安装软件包的三种方法7.2 rpm包介绍 7.3 rpm工具用法 7.4 yum工具用法7.5 yum搭建本地仓库相关的知识,希望对你有一定的参考价值。
- 7.1 安装软件包的三种方法 - 7.2 rpm包介绍 - 7.3 rpm工具用法 - 7.4 yum工具用法 - 7.5 yum搭建本地仓库 - 扩展 1. yum保留已经安装过的包 http://www.360doc.com/content/11/0218/15/4171006_94080041.shtml 2. 搭建局域网yum源 http://ask.apelearn.com/question/7627 # 7.1 安装软件包的三种方法 - windows的.exe文件实际上是一种二进制的安装包 - linux下有三种方法 1. rpm 工具 这种包和windows下的exe比较像,直接用rpm工具就可以,路径和文件名都是固定好的, 2. yum 工具 yum是另外一种工具安装rpm包的,用Python开发的一个工具,支持自动安装依赖的包, 3. 源码包 实际上是源代码,可以看到程序包,当时作者写的 c语言c++ ,用编程语言开发的各个文件都可以看到,需要通过一种编译器,把源码包编译成可以执行的文件 - 这三种方法,源码包是最难的,yum是最简单的 # 7.2 rpm包介绍 ![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170809/221054992.png?imageslim) - 怎么去把rpm工具怎么用,这个包是什么样子的? - 先打开虚拟机,看下右下方小光盘,点右键连接上,先把光盘连接到linux系统里面来,然后进行一个挂载 ![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170809/221300341.png?imageslim) 先看下/mnt/有没有在用 ``` [[email protected] ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/sda3 28G 1.4G 27G 5% / devtmpfs 479M 0 479M 0% /dev tmpfs 489M 0 489M 0% /dev/shm tmpfs 489M 6.7M 482M 2% /run tmpfs 489M 0 489M 0% /sys/fs/cgroup /dev/sda1 197M 109M 88M 56% /boot tmpfs 98M 0 98M 0% /run/user/0 [[email protected] ~]# ls /mnt/ [[email protected] ~]# mount /dev/cdrom /mnt/ mount: /dev/sr0 写保护,将以只读方式挂载 [[email protected] ~]# [[email protected] ~]# cd /mnt/ [[email protected] mnt]# ls CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7 EFI images Packages RPM-GPG-KEY-CentOS-Testing-7 EULA isolinux repodata TRANS.TBL [[email protected] mnt]# cd Packages/ [[email protected] Packages]# ls xvattr-1.3-27.el7.x86_64.rpm xz-5.2.2-1.el7.x86_64.rpm xz-devel-5.2.2-1.el7.x86_64.rpm xz-libs-5.2.2-1.el7.x86_64.rpm yajl-2.0.4-4.el7.x86_64.rpm yelp-3.14.2-1.el7.x86_64.rpm yelp-libs-3.14.2-1.el7.x86_64.rpm yelp-xsl-3.14.0-1.el7.noarch.rpm ypbind-1.37.1-7.el7.x86_64.rpm ypserv-2.31-8.el7.x86_64.rpm yp-tools-2.14-3.el7.x86_64.rpm yum-3.4.3-150.el7.centos.noarch.rpm yum-langpacks-0.4.2-7.el7.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-plugin-aliases-1.1.31-40.el7.noarch.rpm yum-plugin-changelog-1.1.31-40.el7.noarch.rpm yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm yum-plugin-tmprepo-1.1.31-40.el7.noarch.rpm yum-plugin-verify-1.1.31-40.el7.noarch.rpm yum-plugin-versionlock-1.1.31-40.el7.noarch.rpm yum-utils-1.1.31-40.el7.noarch.rpm zenity-3.8.0-5.el7.x86_64.rpm zip-3.0-11.el7.x86_64.rpm zlib-1.2.7-17.el7.x86_64.rpm zlib-devel-1.2.7-17.el7.x86_64.rpm zsh-5.0.2-25.el7.x86_64.rpm zziplib-0.13.62-5.el7.x86_64.rpm [[email protected] Packages]# ``` ![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170809/223245336.png?imageslim) 1. 从左到右,第一部分字符串,叫包名,包名后面是一个- 版本号,版本号又分成 主版本号,次版本号,小的版本号(修正版本),发布版本号,再往后是平台,最后就是后缀名.rpm 2. centos 4 5 6 都是区分32位 64位,centos7开始就不区分这些了 # 7.3 rpm工具的用法 ![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170809/223811716.png?imageslim) 1. 安装rpm包 使用命令rpm -ivh rpm包文件 ``` zenity-3.8.0-5.el7.x86_64.rpm zip-3.0-11.el7.x86_64.rpm zlib-1.2.7-17.el7.x86_64.rpm zlib-devel-1.2.7-17.el7.x86_64.rpm zsh-5.0.2-25.el7.x86_64.rpm zziplib-0.13.62-5.el7.x86_64.rpm [[email protected] Packages]# [[email protected] Packages]# rpm -ivh zsh-5.0.2-25.el7.x86_64.rpm 准备中... ################################# [100%] 正在升级/安装... 1:zsh-5.0.2-25.el7 ################################# [100%] [[email protected] Packages]# ``` 2. 升级rpm包 使用命令rpm -Uvh ``` [[email protected] Packages]# rpm -Uvh zsh-5.0.2-25.el7.x86_64.rpm ``` 3. 卸载rpm包 使用命令rpm -e 包名(不是整个包文件) ``` [[email protected] Packages]# rpm -e zsh [[email protected] Packages]# 也可以rpm -evh 卸载rpm包 加上vh 就是显示可视化和进度 [[email protected] Packages]# rpm -evh zsh 准备中... ################################# [100%] 正在清理/删除... 1:zsh-5.0.2-25.el7 ################################# [100%] [[email protected] Packages]# ``` 4. 查询安装的包 使用命令rpm -qa ``` [[email protected] Packages]# rpm -qa policycoreutils-2.5-8.el7.x86_64 libdaemon-0.14-7.el7.x86_64 kmod-20-9.el7.x86_64 polkit-0.112-9.el7.x86_64 dhclient-4.2.5-47.el7.centos.x86_64 crontabs-1.11-6.20121102git.el7.noarch libdrm-2.4.67-3.el7.x86_64 pciutils-3.5.1-1.el7.x86_64 [[email protected] Packages]# ``` 5. 查询指定包是否安装 使用命令 rpm -q 包名 ``` [[email protected] Packages]# rpm -q ppp ppp-2.4.5-33.el7.x86_64 [[email protected] Packages]# rpm -q ppp1 未安装软件包 ppp1 [[email protected] Packages]# ``` 6. 查询指定包信息 使用命令rpm -qi 包名 ``` [[email protected] Packages]# rpm -qi vim-enhanced Name : vim-enhanced Epoch : 2 Version : 7.4.160 Release : 1.el7_3.1 Architecture: x86_64 Install Date: 2017年08月03日 星期四 21时53分22秒 Group : Applications/Editors Size : 2292098 License : Vim Signature : RSA/SHA256, 2016年12月22日 星期四 01时14分11秒, Key ID 24c6a8a7f4a80eb5 Source RPM : vim-7.4.160-1.el7_3.1.src.rpm Build Date : 2016年12月22日 星期四 01时00分52秒 Build Host : c1bm.rdu2.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : http://www.vim.org/ Summary : A version of the VIM editor which includes recent enhancements Description : VIM (VIsual editor iMproved) is an updated and improved version of the vi editor. Vi was the first real screen-based editor for UNIX, and is still very popular. VIM improves on vi by adding new features: multiple windows, multi-level undo, block highlighting and more. The vim-enhanced package contains a version of VIM with extra, recently introduced features like Python and Perl interpreters. Install the vim-enhanced package if you‘d like to use a version of the VIM editor which includes recently added enhancements like interpreters for the Python and Perl scripting languages. You‘ll also need to install the vim-common package. [[email protected] Packages]# ``` 7. 列出包安装的文件 使用命令 rpm -ql 包名 ``` [[email protected] Packages]# rpm -ql vim-enhanced /etc/profile.d/vim.csh /etc/profile.d/vim.sh /usr/bin/rvim /usr/bin/vim /usr/bin/vimdiff /usr/bin/vimtutor [[email protected] Packages]# ``` 8. 查看一个文件是由哪个包安装的 使用命令 rpm -qf 文件绝对路径 ``` [[email protected] Packages]# rpm -qf /usr/bin/vim vim-enhanced-7.4.160-1.el7_3.1.x86_64 [[email protected] Packages]# [[email protected] Packages]# rpm -qf `which cd` 这是反引号 bash-4.2.46-20.el7_2.x86_64 [[email protected] Packages]# rpm -qf `which ls` rpm: --color=auto‘: 未知的选项 [[email protected] Packages]# which ls alias ls=‘ls --color=auto‘ /usr/bin/ls 这里的ls 是俩行,所以不能把俩行作为参数 用cd 可以实现 [[email protected] Packages]# rpm -qf `which cd` bash-4.2.46-20.el7_2.x86_64 [[email protected] Packages]# which cd /usr/bin/cd [[email protected] Packages]# ``` # 7.4 yum工具的用法 ![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170811/234056261.png?imageslim) - 如果使用rpm安装包,会有很多依赖关系,安装很麻烦,安装这个包会需要安装其他的包,有很多依赖关系,但是yum可以自动帮忙解决依赖关系,只需要跟包名 ``` [[email protected] Packages]# rpm -ivh texlive-2012-38.20130427_r30134.el7.x86_64.rpm 错误:依赖检测失败: texlive-scheme-basic 被 texlive-2:2012-38.20130427_r30134.el7.x86_64 需要 texlive-collection-latexrecommended 被 texlive-2:2012-38.20130427_r30134.el7.x86_64 需要 tex-kpathsea 被 texlive-2:2012-38.20130427_r30134.el7.x86_64 需要 tex-tetex 被 texlive-2:2012-38.20130427_r30134.el7.x86_64 需要 [[email protected] Packages]# ``` - 下面来用yum试下 ``` [[email protected] Packages]# yum install texlive texlive-xdvi noarch 2:svn26689.22.85-38.el7 base 60 k texlive-xdvi-bin x86_64 2:svn26509.0-38.20130427_r30134.el7 base 278 k texlive-xkeyval noarch 2:svn27995.2.6a-38.el7 base 27 k texlive-xunicode noarch 2:svn23897.0.981-38.el7 base 44 k texlive-zapfchan noarch 2:svn28614.0-38.el7 base 102 k texlive-zapfding noarch 2:svn28614.0-38.el7 base 65 k zziplib x86_64 0.13.62-5.el7 base 81 k 事务概要 =========================================================================================== 安装 1 软件包 (+223 依赖软件包) 总下载量:118 M 安装大小:226 M Is this ok [y/d/N]: n Exiting on user command 您的事务已保存,请执行: yum load-transaction /tmp/yum_save_tx.2017-08-11.23-52.oRt6jf.yumtx 重新执行该事务 [[email protected] Packages]# ``` - 如果用rpm -ivh 一个个安装需要安装233个依赖的软件包,那要累死了,但是yum可以自动帮您安装好,这就是yum的优势 - yum list 可以列出可用的rpm包 ``` [[email protected] Packages]# yum list [[email protected] Packages]# ls /etc/yum.repos.d/ CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo [[email protected] Packages]# ls /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo [[email protected] Packages]# [[email protected] Packages]# cat /etc/yum.repos.d/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&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 ... [[email protected] Packages]# ``` - yum search vim 搜素包 搜索vim 也可以搜其他的 ``` [[email protected] Packages]# yum search vim 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.btte.net * updates: mirrors.163.com ==================================== N/S matched: vim ===================================== golang-vim.noarch : Vim plugins for Go protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers descriptions vim-X11.x86_64 : The VIM version of the vi editor for the X Window System vim-common.x86_64 : The common files needed by any version of the VIM editor vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements vim-filesystem.x86_64 : VIM filesystem layout vim-minimal.x86_64 : A minimal version of the VIM editor 名称和简介匹配 only,使用“search all”试试。 [[email protected] Packages]# ``` - yum list |grep ‘vim‘ 把yum list 命令 输出的结果里面再去 丢给后面的命令 再去过滤,中间的是管道符 ``` [[email protected] Packages]# yum list |grep ‘vim‘ vim-common.x86_64 2:7.4.160-1.el7_3.1 @updates vim-enhanced.x86_64 2:7.4.160-1.el7_3.1 @updates vim-filesystem.x86_64 2:7.4.160-1.el7_3.1 @updates vim-minimal.x86_64 2:7.4.160-1.el7 @anaconda golang-vim.noarch 1.3.3-2.el7_0 extras protobuf-vim.x86_64 2.5.0-8.el7 base vim-X11.x86_64 2:7.4.160-1.el7_3.1 updates vim-minimal.x86_64 2:7.4.160-1.el7_3.1 updates [[email protected] Packages]# ``` - yum install -y 安装包 -y表示不再询问 - yum grouplist 把可用的组列出来 ``` [[email protected] Packages]# yum grouplist 已加载插件:fastestmirror 没有安装组信息文件 Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.btte.net * updates: mirrors.163.com 可用的环境分组: 最小安装 基础设施服务器 计算节点 文件及打印服务器 基本网页服务器 虚拟化主机 带 GUI 的服务器 GNOME 桌面 KDE Plasma Workspaces 开发及生成工作站 可用组: 传统 UNIX 兼容性 兼容性程序库 图形管理工具 安全性工具 开发工具 控制台互联网工具 智能卡支持 科学记数法支持 系统管理 系统管理工具 完成 [[email protected] Packages]# 想要改成英文 使用命令LANG=en即可 [[email protected] Packages]# LANG=en [[email protected] Packages]# yum grouplist Failed to set locale, defaulting to C Loaded plugins: fastestmirror There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.btte.net * updates: mirrors.163.com Available Environment Groups: Minimal Install Compute Node Infrastructure Server File and Print Server Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstation Available Groups: Compatibility Libraries Console Internet Tools Development Tools Graphical Administration Tools Legacy UNIX Compatibility Scientific Support Security Tools Smart Card Support System Administration Tools System Management Done [[email protected] Packages]# ``` - yum groupinstall (-y) ``` [[email protected] Packages]# yum groupinstall ‘Virtualization Host‘ 如果安装的包是一个单词 就不需要用 单引号,如果中间有空格就加上单引号 Transaction Summary =========================================================================================== Install 63 Packages (+153 Dependent packages) Upgrade ( 7 Dependent packages) Total download size: 65 M Is this ok [y/d/N]: n Exiting on user command Your transaction was saved, rerun it with: yum load-transaction /tmp/yum_save_tx.2017-08-12.00-28.o4N6Ss.yumtx [[email protected] Packages]# ``` - yum remove [-y] 卸载包 同时帮你把依赖的包也卸载,这个操作比较危险 ``` Dependencies Resolved =========================================================================================== Package Arch Version Repository Size =========================================================================================== Removing: ppp x86_64 2.4.5-33.el7 @anaconda 852 k Removing for dependencies: NetworkManager x86_64 1:1.4.0-12.el7 @anaconda 10 M NetworkManager-team x86_64 1:1.4.0-12.el7 @anaconda 53 k NetworkManager-tui x86_64 1:1.4.0-12.el7 @anaconda 266 k NetworkManager-wifi x86_64 1:1.4.0-12.el7 @anaconda 144 k Transaction Summary =========================================================================================== Remove 1 Package (+4 Dependent packages) Installed size: 11 M Is this ok [y/N]: n Exiting on user command Your transaction was saved, rerun it with: yum load-transaction /tmp/yum_save_tx.2017-08-12.00-31.QLxOxc.yumtx [[email protected] Packages]# ``` - yum update [-y] 去升级一个包,如果不加包名,会默认把系统离所有包都升级到最新的包,这个操作往往是在刚刚安装完系统再做, - 如果是系统里面在运行过一些服务,就不要随便用这个升级,不然会导致系统一些服务停止,和文件丢失 - 命令 yum provides "/*/vim" 如果系统里没有vim 这个命令,也不知道vim这个包的话就使用这个命令搜一下, - 这就是怎么样去搜一个命令有哪一个包 可以安装到它 前提是这个命令 没有安装的命令 - 使用rpm -qf `which vim` 如果vim 命令根本就没有安装 就要用yum provides "/*/vim" 命令 ``` [[email protected] Packages]# yum provides "/*/vim" Failed to set locale, defaulting to C Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.btte.net * updates: mirrors.163.com cmake-2.8.12.2-2.el7.x86_64 : Cross-platform make system Repo : base Matched from: Filename : /usr/share/cmake/editors/vim 2:docker-unit-test-1.10.3-59.el7.centos.x86_64 : Automates deployment of containerized : applications - for running unit tests Repo : extras Matched from: Filename : /var/lib/docker-unit-test/contrib/syntax/vim Filename : /var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim Filename : /var/lib/docker-unit-test/docker-novolume-plugin-c5212546ab01b4b7b62caba888d298ab63f53984/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim git-1.8.3.1-6.el7_2.1.x86_64 : Fast Version Control System Repo : base Matched from: Filename : /usr/share/doc/git-1.8.3.1/contrib/vim 2:vim-common-7.4.160-1.el7.x86_64 : The common files needed by any version of the VIM : editor Repo : base Matched from: Filename : /usr/share/vim 2:vim-common-7.4.160-1.el7_3.1.x86_64 : The common files needed by any version of the VIM : editor Repo : updates Matched from: Filename : /usr/share/vim 2:vim-enhanced-7.4.160-1.el7.x86_64 : A version of the VIM editor which includes recent : enhancements Repo : base Matched from: Filename : /usr/bin/vim 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64 : A version of the VIM editor which includes recent : enhancements Repo : updates Matched from: Filename : /usr/bin/vim 2:vim-enhanced-7.4.160-1.el7_3.1.x86_64 : A version of the VIM editor which includes recent : enhancements Repo : @updates Matched from: Filename : /usr/bin/vim [[email protected] Packages]# ``` # 7.5 yum 搭建本地仓库 ![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170812/150337441.png?imageslim) - 图片中小错误:小错误: gpcheck改为gpgcheck,yum cean 改为 yum clean) - 有时候yum不能用,是yum不能联网,因为默认的仓库 是要远程连接一个资源 网站,下载rpm包 然后再去安装,那没网yum就不能用了吗 ? 就不能安装了吗?我们可以去搭建一个本地的仓库,让它来本地的仓库里来找这些rpm包 ,挂载光盘,里面Packages里有那么多rpm 包,把这些rpm包作为一个仓库, 首先要有一个光驱 ,光盘,镜像文件,挂载这个光驱,可以访问到这个里面的rpm包。 1.挂载一个光驱在/mnt/下 ``` [[email protected] ~]# mount /dev/cdrom /mnt/ mount: /dev/sr0 写保护,将以只读方式挂载 [[email protected] ~]# [[email protected] ~]# cd /mnt/ [[email protected] mnt]# cd Packages/ [[email protected] Packages]# ls /mnt/ CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7 EFI images Packages RPM-GPG-KEY-CentOS-Testing-7 EULA isolinux repodata TRANS.TBL [[email protected] Packages]# ``` 2.下面可能会删除一些文件 ,所以删除之前 先做一个备份,把这个目录拷贝一下 ``` [[email protected] Packages]# cd [[email protected] ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d.bak 再到etc目录下的yum.repos.d 目录下 把所有.repo文件全部删掉 [[email protected] ~]# cd /etc/yum.repos.d [[email protected] yum.repos.d]# ls CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo [[email protected] yum.repos.d]# rm -rf ./* [[email protected] yum.repos.d]# vi dvd.repo 创建一个dvd.repo 文件 [[email protected] yum.repos.d]# vi dvd.repo ~ ~ ~ "dvd.repo" [New File] 按i进入编辑模式 [dvd] dvd 最右侧仓库的名字 name=install dvd baseurl=file:///mnt 你这些rpm包在哪里,在/mnt/下也就是光驱的路径 enable=1 enable=1是否可用 改成=0 就是源,yum仓库不能用 gpcheck=0 gpcheck 是否要检测 =0 不检测 ~ ~ ~ ~ ~ ~ ~ -- INSERT -- :wq 保存退出 [[email protected] yum.repos.d]# rm -rf ./* [[email protected] yum.repos.d]# vi dvd.repo [[email protected] yum.repos.d]# yum clean all 把之前的缓存都进行一个清除 已加载插件:fastestmirror 正在清理软件源: dvd Cleaning up everything Cleaning up list of fastest mirrors [[email protected] yum.repos.d]# 然后再yum list 看下 [[email protected] yum.repos.d]# yum list [[email protected] yum.repos.d]# yum list |less 加个管道符 less 用less 查看下,可以一屏一屏看 带@说明是已经安装过的包 yum.noarch 3.4.3-150.el7.centos @anaconda yum-metadata-parser.x86_64 1.1.4-10.el7 @anaconda yum-plugin-fastestmirror.noarch 1.1.31-40.el7 @anaconda zip.x86_64 3.0-11.el7 @base zlib.x86_64 1.2.7-17.el7 @anaconda 可安装的软件包 389-ds-base.x86_64 1.3.5.10-11.el7 dvd 389-ds-base-libs.x86_64 1.3.5.10-11.el7 dvd ElectricFence.x86_64 2.2.2-39.el7 dvd GConf2.x86_64 3.2.6-8.el7 dvd ImageMagick.x86_64 6.7.8.9-15.el7_2 dvd ImageMagick-c++.x86_64 6.7.8.9-15.el7_2 dvd ImageMagick-perl.x86_64 6.7.8.9-15.el7_2 dvd LibRaw.x86_64 0.14.8-5.el7.20120830git98d925 dvd ModemManager.x86_64 1.6.0-2.el7 dvd ModemManager-glib.x86_64 1.6.0-2.el7 dvd mysql-python.x86_64 1.2.5-1.el7 dvd NetworkManager-adsl.x86_64 1:1.4.0-12.el7 dvd NetworkManager-bluetooth.x86_64 1:1.4.0-12.el7 dvd NetworkManager-glib.x86_64 1:1.4.0-12.el7 dvd 带@ 的 上面的 是已经按照的包 下面是可以安装的包 ``` 下面来安装一个 dvd里面的 ``` [[email protected] yum.repos.d]# yum list |less 由于管道被破坏而退出 [[email protected] yum.repos.d]# yum install GConf2 已加载插件:fastestmirror Loading mirror speeds from cached hostfile 正在解决依赖关系 --> 正在检查事务 ---> 软件包 GConf2.x86_64.0.3.2.6-8.el7 将被 安装 --> 正在处理依赖关系 /usr/bin/killall,它被软件包 GConf2-3.2.6-8.el7.x86_64 需要 --> 正在检查事务 ---> 软件包 psmisc.x86_64.0.22.20-11.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 =========================================================================================== Package 架构 版本 源 大小 =========================================================================================== 正在安装: GConf2 x86_64 3.2.6-8.el7 dvd 1.0 M 为依赖而安装: psmisc x86_64 22.20-11.el7 dvd 141 k 事务概要 =========================================================================================== 安装 1 软件包 (+1 依赖软件包) 总下载量:1.1 M 安装大小:6.8 M Is this ok [y/d/N]: y Downloading packages: ------------------------------------------------------------------------------------------- 总计 8.9 MB/s | 1.1 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : psmisc-22.20-11.el7.x86_64 1/2 正在安装 : GConf2-3.2.6-8.el7.x86_64 2/2 验证中 : GConf2-3.2.6-8.el7.x86_64 1/2 验证中 : psmisc-22.20-11.el7.x86_64 2/2 已安装: GConf2.x86_64 0:3.2.6-8.el7 作为依赖被安装: psmisc.x86_64 0:22.20-11.el7 完毕! [[email protected] yum.repos.d]# ``` - 这个就方便我们使用本地的光盘作为它的一个仓库,很方便去安装一些依赖的包,如果直接用rpm 会有很多依赖的包,很麻烦,很浪费时间,直接搞一个yum本地仓库,直接帮您全部搞定。 ## 扩展 - [ ] 1. yum保留已经安装过的包 http://www.360doc.com/content/11/0218/15/4171006_94080041.shtml -可以设置使yum保留已经下载的rpm包,供以后升级或重新安装时使用。 修改/etc/yum.conf即可: [main] cachedir=/home/soft1/yumcache keepcache=1 debuglevel=2 chchedir是放置下载的包的地方,可以修改为自己想放置的位置。 keepcache为1时表示保存已经下载的rpm包。 - [ ] 2. 搭建局域网yum源 http://ask.apelearn.com/question/7627 -yum局域网软件源搭建 来源:CSDN 作者:bhq2010 1、搭建Apache服务器或ftp服务器 yum安装或二进制包安装 2、准备RPM包把CentOS的DVD1和DVD2.iso都下载下来,把DVD1.iso里的所有内容解压出来,放到/var/www/html/centos-6目录下,然后把DVD2.iso解压出来的Packages目录下的rpm包复制到/var/html/centos-6/Packages目录下,这样/var/html/centos-6/Packages里面就有了6000多个rpm包。 3、创建yum仓库 准备createrepo:yum -y install createrepo 创建repository:createrepo /var/www/html/centos-6/ 创建完成之后,会在/var/www/html/centos-6/repodata下生成一些文件。 4、使用软件源 在其他centos机器上试试软件源能不能用。 首先修改机器上软件源配置文件: ``` # cd /etc/yum.repos.d/ # mkdir bk # mv *.repo bk/ # cp bk/CentOS-Base.repo ./ # vi CentOS-Base.repo CentOS-Base.repo文件修改之后如下: [base] name=CentOS-$releasever - Base baseurl=http://*.*.*.*/centos-6/ gpgcheck=1(改成0下面那行就不用设置了) gpgkey=http:///*.*.*.*/centos-6/RPM-GPG-KEY-CentOS-6 enabled=1 #released updates #[updates] #name=CentOS-$releasever - Updates #baseurl=http:///*.*.*.*/centos-6/ #gpgcheck=1 #gpgkey=http:///*.*.*.*/centos-6/RPM-GPG-KEY-CentOS-6 #enabled = 1 保存之后,就可以使用局域网的软件源了: - # yum update ``` 原地址:http://www.linuxidc.com/Linux/2013-07/87315.htm
以上是关于7.1 安装软件包的三种方法7.2 rpm包介绍 7.3 rpm工具用法 7.4 yum工具用法7.5 yum搭建本地仓库的主要内容,如果未能解决你的问题,请参考以下文章
7.1 安装软件包的三种方法 7.2 rpm包介绍 7.3 rpm工具用法 7.4 yum工具用法
7.1 安装软件包的三种方法 7.2 rpm包介绍 7.3 rpm工具用法 7.4 yum工具用法
7.1 安装软件包的三种方法7.2 rpm包介绍 7.3 rpm工具用法 7.4 yum工具用法7.5 yum搭建本地仓库