1. 程式人生 > >No.21 Yum(Yellowdog Updater Modified)軟件管理

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

yum軟件管理 yum倉庫 linux

基於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文件:

[root@node0 ~]# 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 軟件名稱

[root@node0 ~]# 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 軟件名稱

[root@node0 ~]# 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 軟件名稱

[root@node0 ~]# 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 命令絕對路徑

[root@node0 ~]# 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是否有效

[root@node0 ~]# 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是否安裝:

[root@node0 lnmp_soft]# rpm -qa make gcc

make-3.81-20.el6.x86_64

gcc-4.4.7-16.el6.x86_64

創建源碼和安裝目錄:

[root@node0 lnmp_soft]# mkdir /src /app

[root@node0 lnmp_soft]# ll /src /app/

/app/:

total 0

/src:

total 0

解壓文件:

[root@node0 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

......

進入源碼目錄:

[root@node0 lnmp_soft]# cd /src/nginx-1.8.0/

[root@node0 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獲取編譯參數幫助:

[root@node0 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

指定編譯參數,進行安裝:

[root@node0 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"

[root@node0 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' # 安裝完成

[root@node0 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 文件路徑 定義倉庫數據

[root@node0 test]# mkdir myrpm # 上傳文件

[root@node0 test]# cd myrpm/ # 進入目錄

[root@node0 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

[root@node0 myrpm]# yum install createrepo -y # 安裝軟件

[root@node0 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

[root@node0 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

[root@node0 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 下載和校驗信息

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

執行一個命令的時候沒有找到可能的原因:

[root@node0 test]# mycommand

-bash: mycommand: command not found

1.這個命令對應的軟件包沒有安裝。

2.這個軟件對應的命令名稱不同。

3.這個命令的路徑沒有在環境變量中設置。

4.這個命令所在的磁盤沒有掛載或者是所在磁盤損壞。

5.這個命令所在位置是LVM分區,啟動時LVM失敗或者是LVM損壞。

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


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