Yum

(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。

yum客户端:

配置文件:

/etc/yum.conf:为所有仓库提供公共配置

/etc/yum.repos.d/*.repo:为仓库的指向提供配置

yum repository: yum repo

存储了众多rpm包,以及包的相关的元数据文件(放置于特定目录下:repodata);


文件服务器:

ftp://

http://

nfs://

file:///

仓库指向的含义:


# 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.

# remarked out baseurl= line instead.

#

#


[base]

name=CentOS-$releasever - Base - mirrors.aliyun.com

failovermethod=priority

baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/

        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

gpgcheck=1

gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7


yum的repo配置文件中可用的变量:

    $releasever: 当前OS的发行版的主版本号;

    $arch: 平台;

    $basearch:基础平台;

    $YUM0-$YUM9

[repositoryID]

name=Some name for this repository

baseurl=url://path/to/repository/

enabled={1|0}

gpgcheck={1|0}

gpgkey=URL

enablegroups={1|0}

failovermethod={roundrobin|priority}

默认为:roundrobin,意为随机挑选;

cost=

默认为1000



yum命令

install 安装,多个软件用空格隔开

update 升级所有软件包到最新版本,如果不带版本包名称

update-to 升级软件到指定版本

check-update 检查可用升级

upgrade

upgrade-to

distribution-synchronization

remove | erase 卸载

list 显示程序包列表

info 查看程序包信息

provides | whatprovides 查看指定文件是由哪个程序包所提

clean 清理本地缓存

makecache 构建缓存

groupinstall 分组安装

groupupdate 分组升级

grouplist 分组列表

groupremove 分组卸载

groupinfo 包组信息

search 搜索yum库中程序

shell

resolvedep 显示仓库列表

localinstall 依靠yum解决依赖关系,安装本地程序包

localupdate 依靠yum解决依赖关系,升级本地程序包

reinstall 重新安装

downgrade 降级程序

deplist 查看指定包所依赖的库

repolist 显示仓库列表

version 版本号

history 查看活动历史

check 检查



使用光盘当作本地yum仓库:

    # mount -r /dev/sr0 /media/


CentOS7以前的版本只有DVD版本,如果要把程序包放在一起,需要自建包组

创建yum仓库:

    createrepo [options] <directory>


程序包编译安装:

    filename-version-release.src.rpm

    可以使用rpmbuild命令制作成二进制格式的rpm包,而后再安装;


    C代码编译安装三步骤:

    ./configure:

    (1) 通过选项传递参数,指定启用特性、安装路径等;执行时会参考用户的指定以及Makefile.in文件生成makefile;

    安装路径设定:

    --prefix=/PATH/TO/SOMEWHERE: 指定默认安装位置;默认为/usr/local/

    --sysconfdir=/PATH/TO/SOMEWHERE:配置文件安装位置;

    System types:


    Optional Features: 可选特性

    --disable-FEATURE

    --enable-FEATURE[=ARG]


    Optional Packages: 可选包

    --with-PACKAGE[=ARG]

    --without-PACKAGE


    (2) 检查依赖到的外部环境;

    make:

    根据makefile文件,构建应用程序;

    make install


    建议:安装前查看insatll,readme文档


    第二步:make


    第三步:make install


    开发工具:

    autoconf: 生成configure脚本

    automake:生成Makefile.in


    安装后的配置:

    (1) 导出二进制程序目录至PATH环境变量中;

    编辑文件/etc/profile.d/NAME.sh

    export PATH=/PATH/TO/BIN:$PATH


    (2) 导出库文件路径

    编辑/etc/ld.so.conf.d/NAME.conf

    添加新的库文件所在目录至此文件中;


    让系统重新生成缓存:

    ldconfig [-v]


    (3) 导出头文件

    基于链接的方式实现:

    ln -sv 


    (4) 导出帮助手册

    编辑/etc/man.config文件

    添加一个MANPATH


rpm结合yum后安装及管理

    yum install /PATH/TO/SOMEWHERE xxx.rpm

rpm命令之安装卸载

-i安装

-U升级,-F

-e卸载

-V校验

--initdb数据库维护,--builddb

--test 测试安装

-h输出进度条

-v详细信息

--nodeps忽略依赖关系 卸载的时候需要,不要把依赖库一起删

--allmatches:卸载所有匹配指定名称的程序包的各版本


rpm命令之查询

-qa 列出所有安装过的包  

     -q name 

     -ql 列出安装包文件安装的路径

  -qi 列出安装包的文件信息



程序包编译安装:

    xxx.src.rpm --> 安装后,使用rpmbuild命令制作成二进制格式的rpm包,而后再安装;


 源码编译安装

     $ ./configure --prefix=PREFIX 指定安装目录,默认为/usr/local/安装文件名

     $ make

     $ make install

     $ PREFIX/bin/xxx start

下载源码包,一般在镜像源的Sources目录下

  如果后缀为压缩包,需要先解压缩,归档的还需先解档

  进入解压缩出来的目录,查看安装文件,一般为INSTALL

  安装后还需要配置:

    (1) 导出二进制程序目录至PATH环境变量中;

    编辑文件/etc/profile.d/NAME.sh

    export PATH=/PATH/TO/BIN:$PATH


    (2) 导出库文件路径

    编辑/etc/ld.so.conf.d/NAME.conf

    添加新的库文件所在目录至此文件中;


    让系统重新生成缓存:

    ldconfig [-v]


    (3) 导出头文件

    基于链接的方式实现:

    ln -sv 源 地


    (4) 导出帮助手册

    编辑/etc/man.config文件

    添加一个MANPATH