No.21 Yum(Yellowdog Updater Modified)软件管理

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了No.21 Yum(Yellowdog Updater Modified)软件管理相关的知识,希望对你有一定的参考价值。

基于RPM包构建的软件更新机制。

自动解决软件包安装依赖关系

所有软件包由集中的Yum软件提供

 

软件仓库提供的方式:

本地:file://

FTPHTTPftp://http://

 

Yum配置文件解析:

基本设置:/etc/yum.conf

仓库设置:/etc/yum.repos.d/*.repo

日志文件:/var/log/yum.log

 

Yum缓存目录:

存放下载的软件包,仓库记录等文件

/var/cache/yum/$baserach/$releaserver

 

Yum*.repo文件解析:

[base]  # 定义名称,具有唯一性。

name=CentOS-$releasever - Base  # 软件源描述字符串

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra   # Yum源地址

#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/

enabled   # 是否使用该频道

gpgcheck=1 # 是否验证待安装的RPM包文件

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 # 用于RPM软件包检验的密钥

 

检查*.repo文件:

[[email protected] ~]# yum repolist

Loaded plugins: fastestmirror, security

Loading mirror speeds from cached hostfile

repo id              repo name                           status                                                    

dvd_                 added from: file:///dvd/          6,575

repolist: 6,575

 

查看软件信息:

yum list 软件名称

[[email protected] ~]# yum list lrzsz

Loaded plugins: fastestmirror, security

Loading mirror speeds from cached hostfile

dvd_                                                                                                 | 4.0 kB     00:00 ...

Installed Packages

lrzsz.x86_64                                  0.12.20-27.1.el6                 @dvd_                          

检索软件信息:

yum search 软件名称

[[email protected] ~]# yum search lynx

Loaded plugins: fastestmirror, security

Loading mirror speeds from cached hostfile

============================== N/S Matched: lynx ============================

lynx.x86_64 : A text-based Web browser

Name and summary matches only, use "search all" for everything.

yum info 软件名称

[[email protected] ~]# yum info lynx

Loaded plugins: fastestmirror, security

Loading mirror speeds from cached hostfile

Available Packages

Name        : lynx

Arch        : x86_64

Version     : 2.8.6

Release     : 27.el6

Size        : 1.3 M

Repo        : dvd_

Summary     : A text-based Web browser

URL         : http://lynx.isc.org/

License     : GPLv2

Description : Lynx is a text-based Web browser. Lynx does not display any images,

            : but it does support frames, tables, and most other html tags. One

            : advantage Lynx has over graphical browsers is speed; Lynx starts and

            : exits quickly and swiftly displays web pages.

yum provides 命令绝对路径

[[email protected] ~]# yum provides /bin/ls

Loaded plugins: fastestmirror, security

Loading mirror speeds from cached hostfile

coreutils-8.4-37.el6.x86_64 : A set of basic GNU tools commonly used in shell scripts

Repo        : dvd_

Matched from:

Filename    : /bin/ls

coreutils-8.4-37.el6.x86_64 : A set of basic GNU tools commonly used in shell scripts

Repo        : installed

Matched from:

Other       : Provides-match: /bin/ls

 

安装卸载软件:

 

yum 选项 软件名称

install:安装

update:升级指定软件

remove:卸载指定软件

 

清空Yum缓存:一般用于Yum是否有效

[[email protected] ~]# yum clean all

Loaded plugins: fastestmirror, security

Cleaning repos: dvd_

Cleaning up Everything

Cleaning up list of fastest mirrors

************************************************************************************************

安装软件的时候使用yum进行安装,卸载软件的时候使用rpm命令进行卸载,因为使用yum卸载有可能会卸载其他软件导致系统运行不稳定。

************************************************************************************************

查询安装卸载软件包组:

yum 选项 软件包组名

grouplist:查看软件组列表

groupinfo:查看软件组的说明信息

groupinstall:安装指定软件组

groupupdate:升级指定软件组

groupremove:卸载指定软件组

 

源码编译安装:

源码释放到/src目录,安装到/app目录。

检查gccmake是否安装:

[[email protected] lnmp_soft]# rpm -qa make gcc

make-3.81-20.el6.x86_64

gcc-4.4.7-16.el6.x86_64

创建源码和安装目录:

[[email protected] lnmp_soft]# mkdir /src /app

[[email protected] lnmp_soft]# ll /src /app/

/app/:

total 0

 

/src:

total 0

解压文件:

[[email protected] lnmp_soft]# tar -zxvf ./nginx-1.8.0.tar.gz -C /src

nginx-1.8.0/

nginx-1.8.0/auto/

nginx-1.8.0/conf/

nginx-1.8.0/contrib/

nginx-1.8.0/src/

nginx-1.8.0/configure

nginx-1.8.0/LICENSE

nginx-1.8.0/README

nginx-1.8.0/html/

nginx-1.8.0/man/

nginx-1.8.0/CHANGES.ru

nginx-1.8.0/CHANGES

nginx-1.8.0/man/nginx.8

nginx-1.8.0/html/50x.html

nginx-1.8.0/html/index.html

nginx-1.8.0/src/core/

nginx-1.8.0/src/event/

nginx-1.8.0/src/http/

nginx-1.8.0/src/mail/

nginx-1.8.0/src/misc/

nginx-1.8.0/src/os/

nginx-1.8.0/src/os/unix/

nginx-1.8.0/src/os/unix/ngx_aio_read_chain.c

nginx-1.8.0/src/os/unix/ngx_aio_read.c

......

进入源码目录:

[[email protected] lnmp_soft]# cd /src/nginx-1.8.0/

[[email protected] nginx-1.8.0]# ll

total 652K

drwxr-xr-x. 6 1001 1001 4.0K Nov 19 17:43 auto

-rw-r--r--. 1 1001 1001 244K Apr 21  2015 CHANGES

-rw-r--r--. 1 1001 1001 371K Apr 21  2015 CHANGES.ru

drwxr-xr-x. 2 1001 1001 4.0K Nov 19 17:43 conf

-rwxr-xr-x. 1 1001 1001 2.5K Apr 21  2015 configure

drwxr-xr-x. 4 1001 1001 4.0K Nov 19 17:43 contrib

drwxr-xr-x. 2 1001 1001 4.0K Nov 19 17:43 html

-rw-r--r--. 1 1001 1001 1.4K Apr 21  2015 LICENSE

drwxr-xr-x. 2 1001 1001 4.0K Nov 19 17:43 man

-rw-r--r--. 1 1001 1001   49 Apr 21  2015 README

drwxr-xr-x. 8 1001 1001 4.0K Nov 19 17:43 src

使用./configure --help获取编译参数帮助:

[[email protected] nginx-1.8.0]# ./configure --help

 

  --help                             print this message

 

  --prefix=PATH                      set installation prefix

  --sbin-path=PATH                   set nginx binary pathname

  --conf-path=PATH                   set nginx.conf pathname

  --error-log-path=PATH              set error log pathname

  --pid-path=PATH                    set nginx.pid pathname

  --lock-path=PATH                   set nginx.lock pathname

 

  --user=USER                        set non-privileged user for

                                     worker processes

  --group=GROUP                      set non-privileged group for

                                     worker processes

 

  --build=NAME                       set build name

  --builddir=DIR                     set build directory

 

  --with-rtsig_module                enable rtsig module

  --with-select_module               enable select module

  --without-select_module            disable select module

  --with-poll_module                 enable poll module

  --without-poll_module              disable poll module

 

  --with-threads                     enable thread pool support

 

  --with-file-aio                    enable file AIO support

  --with-ipv6                        enable IPv6 support

 

  --with-http_ssl_module             enable ngx_http_ssl_module

  --with-http_spdy_module            enable ngx_http_spdy_module

  --with-http_realip_module          enable ngx_http_realip_module

  --with-http_addition_module        enable ngx_http_addition_module

  --with-http_xslt_module            enable ngx_http_xslt_module

  --with-http_image_filter_module    enable ngx_http_image_filter_module

  --with-http_geoip_module           enable ngx_http_geoip_module

  --with-http_sub_module             enable ngx_http_sub_module

  --with-http_dav_module             enable ngx_http_dav_module

  --with-http_flv_module             enable ngx_http_flv_module

  --with-http_mp4_module             enable ngx_http_mp4_module

  --with-http_gunzip_module          enable ngx_http_gunzip_module

  --with-http_gzip_static_module     enable ngx_http_gzip_static_module

  --with-http_auth_request_module    enable ngx_http_auth_request_module

  --with-http_random_index_module    enable ngx_http_random_index_module

  --with-http_secure_link_module     enable ngx_http_secure_link_module

  --with-http_degradation_module     enable ngx_http_degradation_module

  --with-http_stub_status_module     enable ngx_http_stub_status_module

 

  --without-http_charset_module      disable ngx_http_charset_module

  --without-http_gzip_module         disable ngx_http_gzip_module

  --without-http_ssi_module          disable ngx_http_ssi_module

  --without-http_userid_module       disable ngx_http_userid_module

  --without-http_access_module       disable ngx_http_access_module

  --without-http_auth_basic_module   disable ngx_http_auth_basic_module

  --without-http_autoindex_module    disable ngx_http_autoindex_module

  --without-http_geo_module          disable ngx_http_geo_module

  --without-http_map_module          disable ngx_http_map_module

  --without-http_split_clients_module disable ngx_http_split_clients_module

  --without-http_referer_module      disable ngx_http_referer_module

  --without-http_rewrite_module      disable ngx_http_rewrite_module

  --without-http_proxy_module        disable ngx_http_proxy_module

  --without-http_fastcgi_module      disable ngx_http_fastcgi_module

  --without-http_uwsgi_module        disable ngx_http_uwsgi_module

  --without-http_scgi_module         disable ngx_http_scgi_module

  --without-http_memcached_module    disable ngx_http_memcached_module

  --without-http_limit_conn_module   disable ngx_http_limit_conn_module

  --without-http_limit_req_module    disable ngx_http_limit_req_module

  --without-http_empty_gif_module    disable ngx_http_empty_gif_module

  --without-http_browser_module      disable ngx_http_browser_module

  --without-http_upstream_hash_module

                                     disable ngx_http_upstream_hash_module

  --without-http_upstream_ip_hash_module

                                     disable ngx_http_upstream_ip_hash_module

  --without-http_upstream_least_conn_module

                                     disable ngx_http_upstream_least_conn_module

  --without-http_upstream_keepalive_module

                                     disable ngx_http_upstream_keepalive_module

 

  --with-http_perl_module            enable ngx_http_perl_module

  --with-perl_modules_path=PATH      set Perl modules path

  --with-perl=PATH                   set perl binary pathname

 

  --http-log-path=PATH               set http access log pathname

  --http-client-body-temp-path=PATH  set path to store

                                     http client request body temporary files

  --http-proxy-temp-path=PATH        set path to store

                                     http proxy temporary files

  --http-fastcgi-temp-path=PATH      set path to store

                                     http fastcgi temporary files

  --http-uwsgi-temp-path=PATH        set path to store

                                     http uwsgi temporary files

  --http-scgi-temp-path=PATH         set path to store

                                     http scgi temporary files

 

  --without-http                     disable HTTP server

  --without-http-cache               disable HTTP cache

 

  --with-mail                        enable POP3/IMAP4/SMTP proxy module

  --with-mail_ssl_module             enable ngx_mail_ssl_module

  --without-mail_pop3_module         disable ngx_mail_pop3_module

  --without-mail_imap_module         disable ngx_mail_imap_module

  --without-mail_smtp_module         disable ngx_mail_smtp_module

 

  --with-google_perftools_module     enable ngx_google_perftools_module

  --with-cpp_test_module             enable ngx_cpp_test_module

 

  --add-module=PATH                  enable an external module

 

  --with-cc=PATH                     set C compiler pathname

  --with-cpp=PATH                    set C preprocessor pathname

  --with-cc-opt=OPTIONS              set additional C compiler options

  --with-ld-opt=OPTIONS              set additional linker options

  --with-cpu-opt=CPU                 build for the specified CPU, valid values:

                                     pentium, pentiumpro, pentium3, pentium4,

                                     athlon, opteron, sparc32, sparc64, ppc64

 

  --without-pcre                     disable PCRE library usage

  --with-pcre                        force PCRE library usage

  --with-pcre=DIR                    set path to PCRE library sources

  --with-pcre-opt=OPTIONS            set additional build options for PCRE

  --with-pcre-jit                    build PCRE with JIT compilation support

 

  --with-md5=DIR                     set path to md5 library sources

  --with-md5-opt=OPTIONS             set additional build options for md5

  --with-md5-asm                     use md5 assembler sources

 

  --with-sha1=DIR                    set path to sha1 library sources

  --with-sha1-opt=OPTIONS            set additional build options for sha1

  --with-sha1-asm                    use sha1 assembler sources

 

  --with-zlib=DIR                    set path to zlib library sources

  --with-zlib-opt=OPTIONS            set additional build options for zlib

  --with-zlib-asm=CPU                use zlib assembler sources optimized

                                     for the specified CPU, valid values:

                                     pentium, pentiumpro

 

  --with-libatomic                   force libatomic_ops library usage

  --with-libatomic=DIR               set path to libatomic_ops library sources

 

  --with-openssl=DIR                 set path to OpenSSL library sources

  --with-openssl-opt=OPTIONS         set additional build options for OpenSSL

 

  --with-debug                       enable debug logging

指定编译参数,进行安装:

[[email protected] nginx-1.8.0]# ./configure --prefix=/app/nginx-1.8.0 --with-http_ssl_module

......

checking for PCRE library in /usr/local/ ... not found

checking for PCRE library in /usr/include/pcre/ ... not found

checking for PCRE library in /usr/pkg/ ... not found

checking for PCRE library in /opt/local/ ... not found

# 导致编译检查不通过报错,由于缺少pcerpcre-devel导致

./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using --without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

statically from the source with nginx by using --with-pcre=<path> option.

 

......

checking for zlib library ... found

creating objs/Makefile  # 表示安装完成

 

Configuration summary

  + using system PCRE library

  + using system OpenSSL library

  + md5: using OpenSSL library

  + sha1: using OpenSSL library

  + using system zlib library

 

  nginx path prefix: "/app/nginx-1.8.0"

  nginx binary file: "/app/nginx-1.8.0/sbin/nginx"

  nginx configuration prefix: "/app/nginx-1.8.0/conf"

  nginx configuration file: "/app/nginx-1.8.0/conf/nginx.conf"

  nginx pid file: "/app/nginx-1.8.0/logs/nginx.pid"

  nginx error log file: "/app/nginx-1.8.0/logs/error.log"

  nginx http access log file: "/app/nginx-1.8.0/logs/access.log"

  nginx http client request body temporary files: "client_body_temp"

  nginx http proxy temporary files: "proxy_temp"

  nginx http fastcgi temporary files: "fastcgi_temp"

  nginx http uwsgi temporary files: "uwsgi_temp"

  nginx http scgi temporary files: "scgi_temp"

[[email protected] nginx-1.8.0]# make && make install # 编译安装开始

......

cp conf/scgi_params             '/app/nginx-1.8.0/conf/scgi_params.default'

test -f '/app/nginx-1.8.0/conf/nginx.conf'              || cp conf/nginx.conf '/app/nginx-1.8.0/conf/nginx.conf'

cp conf/nginx.conf '/app/nginx-1.8.0/conf/nginx.conf.default'

test -d '/app/nginx-1.8.0/logs'                 || mkdir -p '/app/nginx-1.8.0/logs'

test -d '/app/nginx-1.8.0/logs' ||              mkdir -p '/app/nginx-1.8.0/logs'

test -d '/app/nginx-1.8.0/html'                 || cp -R html '/app/nginx-1.8.0'

test -d '/app/nginx-1.8.0/logs' ||              mkdir -p '/app/nginx-1.8.0/logs'

make[1]: Leaving directory `/src/nginx-1.8.0'  # 安装完成

[[email protected] nginx-1.8.0]# ll /app/nginx-1.8.0/

total 16K

drwxr-xr-x. 2 root root 4.0K Nov 19 17:50 conf

drwxr-xr-x. 2 root root 4.0K Nov 19 17:50 html

drwxr-xr-x. 2 root root 4.0K Nov 19 17:50 logs

drwxr-xr-x. 2 root root 4.0K Nov 19 17:50 sbin

自动配置yum源:

使用yum-config-manager --add yum源地址

yum仓库的定义:

安装createrepo软件包

将软件集中到某个目录,使用createrepo 文件路径 定义仓库数据

[[email protected] test]# mkdir myrpm   # 上传文件

[[email protected] test]# cd myrpm/ # 进入目录

[[email protected] myrpm]# rz  # 上传RPM包文件

rz waiting to receive.

Starting zmodem transfer.  Press Ctrl+C to cancel.

Transferring bash-completion-2.1-6.el7.noarch.rpm...

  100%      85 KB      85 KB/sec    00:00:01       0 Errors 

Transferring cmatrix-1.2a-1.i386.rpm...

  100%      31 KB      31 KB/sec    00:00:01       0 Errors 

Transferring convmv-1.15-2.el6.noarch.rpm...

  100%      30 KB      30 KB/sec    00:00:01       0 Errors 

Transferring elasticsearch-2.3.4.rpm...

  100%   26794 KB    8931 KB/sec    00:00:03       0 Errors  

Transferring ntfs-3g-2015.3.14-2.el6.x86_64.rpm...

  100%     262 KB     262 KB/sec    00:00:01       0 Errors 

Transferring xsnow-1.42-10.i386.rpm...

  100%      32 KB      32 KB/sec    00:00:01       0 Errors 

[[email protected] myrpm]# yum install createrepo -y   # 安装软件

[[email protected] myrpm]# createrepo /test/myrpm/    # 生成仓库数据库文件

Spawning worker 0 with 6 pkgs

Workers Finished

Gathering worker results

Saving Primary metadata

Saving file lists metadata

Saving other metadata

Generating sqlite DBs

Sqlite DBs complete 

[[email protected] test]# ll /test/myrpm/repodata/  # 查看数据文件

total 36K

-rw-r--r--. 1 root root 6.0K Nov 19 20:47 03a154d48fdf298f64be9dd325edd7fc1c9c5ca89b2a3f84cd75ef969ca0c3f6-primary.sqlite.bz2

-rw-r--r--. 1 root root 2.2K Nov 19 20:47 14b81f2c0f3f34e2e795772ae781dbde2f99764ed240f0129cf23283b16ac713-filelists.xml.gz

-rw-r--r--. 1 root root 2.3K Nov 19 20:47 88d559663d31ee880bcbb7125ba44570bedbdf1f616d106bdc1383c6eba69ced-other.xml.gz

-rw-r--r--. 1 root root 3.6K Nov 19 20:47 a6089e2ae8fdd4e0b1a90cb17b32c2134b7390ebb494e9b2952e43fa4abe9470-other.sqlite.bz2

-rw-r--r--. 1 root root 3.2K Nov 19 20:47 bf4ec4b1841845ba5946099ebc4ae322ff0c1b035d57d9ecab26a89d3bed29fe-primary.xml.gz

-rw-r--r--. 1 root root 4.1K Nov 19 20:47 da67962a6c9f96f8dff0a4dcb1da49da6c8ea8334b295c7db845d0682dc04dc8-filelists.sqlite.bz2

-rw-r--r--. 1 root root 3.0K Nov 19 20:47 repomd.xml

[[email protected] test]# yum-config-manager --add file:///test/myrpm/   # 建立Yum

Loaded plugins: fastestmirror

adding repo from: file:///test/myrpm/

 

[test_myrpm_]

name=added from: file:///test/myrpm/

baseurl=file:///test/myrpm/

enabled=1

repodata 目录:

filelist.xml.gz 更新文件的集中列表

other.xml.gz 其他更新包的列表

primary.xml.gz 主要更新包的列表

repomd.xml 提供.xml.gz 下载和校验信息

************************************************************************************************

执行一个命令的时候没有找到可能的原因:

[[email protected] test]# mycommand

-bash: mycommand: command not found

1.这个命令对应的软件包没有安装。

2.这个软件对应的命令名称不同。

3.这个命令的路径没有在环境变量中设置。

4.这个命令所在的磁盘没有挂载或者是所在磁盘损坏。

5.这个命令所在位置是LVM分区,启动时LVM失败或者是LVM损坏。

************************************************************************************************


以上是关于No.21 Yum(Yellowdog Updater Modified)软件管理的主要内容,如果未能解决你的问题,请参考以下文章

Linux YUM (Yellowdog Updater, Modified) Commands for Package Management

linux下执行yum updat 无效果,这是啥情况?

yum

yum

yum

yum命令和配置文件