rpm 软件包管理

 

rpm

作用:管理 rpm  安装卸载

语法 rpm [选项] 包名

 

挂载光盘

mount: mount point /nt does not exist

[root@server63 ~]# mount /dev/sr0 /mnt

mount: block device /dev/sr0 is write-protected, mounting read-only


 

[root@server63 ~]# ls /mnt

CentOS_BuildTag  isolinux                  RPM-GPG-KEY-CentOS-Debug-6

EFI              Packages                  RPM-GPG-KEY-CentOS-Security-6

EULA             RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Testing-6

GPL              repodata                  TRANS.TBL

images           RPM-GPG-KEY-CentOS-6

 

[root@server63 ~]# ls /mnt/Packages/ | wc-l      # wc -l  统计行数

3996

 

linux 软件包的命令规则

[root@server63 ~]# cd /mnt/Packages/

[root@server63 Packages]# lszsh-4.3.10-7.el6.x86_64.rpm

zsh-4.3.10-7.el6.x86_64.rpm

 

zsh       -4          .3          .10            -4.1                     

软件名   主版本号    次版本号    修订         release(第几次发布版本)

 x86                  _64

cpu架构系统平台      支持的系统位数  

 

安装rpm

[root@server63 Packages]# rpm -ivh/mnt/Packages/lrzsz-0.12.20-27.1.el6.x86_64.rpm

warning:/mnt/Packages/lrzsz-0.12.20-27.1.el6.x86_64.rpm: Header V3 RSA/SHA256Signature, key ID c105b9de: NOKEY

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

       packagelrzsz-0.12.20-27.1.el6.x86_64 is already installed 说明系统已装上这个包

 

 

[root@server63 Packages]# rpm -ivh/mnt/Packages/zsh-4.3.10-7.el6.x86_64.rpm

warning:/mnt/Packages/zsh-4.3.10-7.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key IDc105b9de: NOKEY

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

  1:zsh                   ########################################### [100%]

 

rpm --help

-i install                   installpackage

-v verbose 详细            provide moredetailed output

-h hash                    print hash marks as packageinstalls 安装时打印散列标记号#

 

记住这几个选项就好了。安装时默认就用这几个选项

 

安装时解决依赖关系:

安装mysql数据库

 

[root@server63 Packages]# rpm -ivh/mnt/Packages/mysql-server-5.1.71-1.el6.x86_64.rpm

warning: /mnt/Packages/mysql-server-5.1.71-1.el6.x86_64.rpm:Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY

error: Failed dependencies:

       mysql = 5.1.71-1.el6 is needed by mysql-server-5.1.71-1.el6.x86_64

       perl(DBI) is needed by mysql-server-5.1.71-1.el6.x86_64

       perl-DBD-MySQL is needed by mysql-server-5.1.71-1.el6.x86_64

       perl-DBI is needed by mysql-server-5.1.71-1.el6.x86_64

 

 

[root@server63 Packages]# ls*perl-DBD-MySQ*

perl-DBD-MySQL-4.013-3.el6.x86_64.rpm

 

如果找不到  可以 找部分关键字

*DBD*  *perl-DBD*

 

方法2 rpm包相关网站找

http://rpm.pbone.net/

http://rpmfind.net/

http://www.rpmseek.com/index.html

 wKioL1cfNRngZX-bAACNPoTOTU8071.jpg

 

强制安装:(用的很少不解决依赖关系 直接安装

[root@server Packages]# rpm -ivh --nodeps/mnt/Packages/mysql-server-5.1.71-1.el6.x86_64.rpm

 

 

rpm查询功能:

[root@server Packages]# rpm -ivh/mnt/Packages/zsh-4.3.10-7.el6.x86_64.rpm

[root@server Packages]# cat /etc/shells

/bin/sh

/bin/bash

/sbin/nologin

/bin/dash

/bin/tcsh

/bin/csh

/bin/zsh

 

zsh 是什么

zsh unix 系统下的一种shell 高度兼容bash

 

 

rpm -q zsh (查询 zsh软件是否安装)如果能列出来就是安装了

[root@server63 Packages]# rpm -q zsh

zsh-4.3.10-7.el6.x86_64

 

 

使用yum安装软件

 

yum 自动解决依赖关系,自动下载软件包。基于C/S机构。

S

直接使用光盘的根所在的目录/media/xxx  /mnt

 

C 配置yum源配置文件

[root@server63 ~]# cat/etc/yum.repos.d/test.repo

[name] #用于区别各个不同yum软件包库,如有多个yum这里的命名要唯一

name=test #用于对软件包库的描述  随意

baseurl=file:///mnt  repodata  所在的目录)#repodata 用于解决yum的依赖关系。如果网络yum源也要指定到repodata目录所在的目录

#baseurl=http://mirrors.ustc.edu.cn/centos/6.7/os/x86_64/

wKioL1cfNZjh-_PMAALLwU4Zwqs252.jpg

enabled=1 # 默认为1 表示启用本yum

gpgcheck=0 #使用公钥检验rpm正确性  0 不检测

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

 

 

yum 使用

1 mount 挂载

mount /dev/sr0 /mnt

 

2 yum clean all  清空本地缓存

yum list 列出可以安装的包

3 yum install zsh   #安装

 

yum grouplist

 [root@server63~]# yum grouplist | grep Dev*

  Additional Development

  Debugging Tools

  Desktop

  Desktop Debugging and Performance Tools

  Desktop Platform

   GeneralPurpose Desktop

  Desktop Platform Development

  Development tools

  KDE Desktop

  Remote Desktop Clients

  Server Platform Development

[root@xuegod63 ~]# yum groupinstall"Development tools"  # linux 空格代表分割符 要用“”括起来代表一个整体  linux 单引号 里面所有字符串原意输出 不做翻译。双引号会解释特殊字符的意思

 

yum 查询

[root@server63 ~]# yum search zsh

Loaded plugins: fastestmirror,refresh-packagekit, security

Loading mirror speeds from cached hostfile

=============================== N/SMatched: zsh ===============================

python-twisted-core-zsh.x86_64 : Tabcompletion for Zsh and Twisted Core

zsh-html.x86_64 : Zsh shell manual in htmlformat

zsh.x86_64 : A powerful interactive shell

[root@server63 ~]# rpm -qpi/mnt/Packages/zsh-4.3.10-7.el6.x86_64.rpm 查看一个包的作用

#未安装的包用 -pqi   已安装的 -qi

 

 

 

yum删除

yum remove zsh

[root@server63 ~]# rpm -q zsh

package zsh is not installed

 

不交互安装  -y

yum install -y zsh

 

源码编译安装软件包

前提:系统必须安装:开发工具开发库。

步骤:

1 获得源码包

2 解压

tar -zxvf /-jxvf

3 配置 检测安装环境

./configure #检查安装环境是否符合需求,如果没问题,生成 Makefile文件

4 编译

make (编译时会读取Makefile文件)

5 安装

make install

6删除

make uninstall

[root@server63 ~]# tar -jxvfextundelete-0.2.4.tar.bz2

[root@server63 ~]# cd extundelete-0.2.4

[root@server63 extundelete-0.2.4]#./configure

Configuring extundelete 0.2.4

configure: error: Can't find ext2fs library

 

[root@server63 Packages]# yum search *2fs*

Loaded plugins: fastestmirror,refresh-packagekit, security

Loading mirror speeds from cached hostfile

Warning: No matches found for:e2fsprogs-1.41.12-18.el6.x86_64.rpm

Warning: No matches found for:e2fsprogs-devel-1.41.12-18.el6.i686.rpm

Warning: No matches found for:e2fsprogs-devel-1.41.12-18.el6.x86_64.rpm

Warning: No matches found for:e2fsprogs-libs-1.41.12-18.el6.i686.rpm

Warning: No matches found for:e2fsprogs-libs-1.41.12-18.el6.x86_64.rpm

 

[root@server63 Packages]# rpm -ivhe2fsprogs-devel-1.41.12-18.el6.x86_64.rpm

 [root@server63Packages]# rpm -ivh e2fsprogs-libs-1.41.12-18.el6.x86_64.rpm

d

 

[root@server63 extundelete-0.2.4]# ./configure

[root@server63 extundelete-0.2.4]# make

[root@xuegod63 extundelete-0.2.4]# make install

 

删除

[root@server63 extundelete-0.2.4]# pwd

/root/extundelete-0.2.4

[root@server63 extundelete-0.2.4]# makeuninstall

 

有时怕删除不干净在安装时 configure步骤添加一个 --prefix 参数。这样删除或备份时,直接对这个目录进行操作就可以了。

 

[root@server63 extundelete-0.2.4]# makeclean  清空上次编译时产生的文件

[root@server63 extundelete-0.2.4]#./configure --prefix=/usr/local/extundelete 指定安装路径

[root@server63 extundelete-0.2.4]# make&& make install

 

[root@server63 ~]# cd /usr/local/

[root@server63 local]# rm -rf extundelete/   这样删除就很干净

 

 

软件安装方法特点

rpm+yum 方便 ,软件版本低。稳定性好,管理方便 性能稍差

手动:麻烦,软件版本新。稳定性稍差,管理稍差。性能好