Linux—-软件安装 一、开放源码、编译程序、可执行文件 二、tarball安装的基本步骤 三、一般tarball软件安装的建议事项(如何删除、升级) 四、安装ntp中了解下英文 五、利用patch 更新源码 六、RPM 七、RPM属性依赖的解决方式: YUM在线升级 八、RPM 软件管理程序:rpm 九、YUM在线升级机制 yum 的设置文件

1Linux系统上真正识别的可执行文件是二进制文件。

2Shell script

shell script并不是可执行文件,shell script 只是利用shell这个程序的功能进行一些判断式,而最终执行的除了bash提供的功能外,仍是调用一些已经编译好的二进制程序来执行的。

3linux上如何判断一个文件是否为二进制文件

使用file命令

例如:file /etc/init.d/syslog

如果是二进制程序而且是可执行的时候,他就会显示可执行文件类(ELF 32-bit LSBexecutable),同时会说明是否使用共享库(shared libs),而如果是一般的script,那他就会显示出text executables之类的字样。

4二进制程序是如何来的呢?

linux 上面最标准的程序语言c语言,我们在书写完c语言代码之后,需要用gcc来对c语言进行编译,这样就可以制作一个可以执行的二进制程序。事实上,在编译的过程中还会生成“目标文件”这些文件是以*.0的扩展名形式存在的。至于c语言的源代码文件通常以.*c

作为扩展名。此外,有的时候,我们会在程序当中引用、调用其他的外部子程序,或者是利用其他软件提供的“函数功能”,这个时候我们就必须要在编译的过程当中将该函数库加进去,如此一来,编译程序就可以将所有的程序代码与函数库做一个链接(Link)以生成正确的执行文件。

总之,我们可以这么说:

开放源码:就是程序代码,写给人类看的程序语言,但机器并不认识,所以无法执行;

编译程序:将程序代码转译成为机器看得懂的语言,就类似翻译者的角色;

可执行文件:经过编译程序变成二进制程序后机器看得懂所以可以执行的文件。

5如何安装与升级软件

更新与升级软件可以分为两大类

1直接以源码通过编译来安装与升级

2直接以编译好的二进制程序来安装升级

上述第一点很简单,就是直接以Tarball在自己的机器上面进行检测、编译、安装与设置等操作来升级就是了。这样的操作虽然让用户在安装过程中具有很高的可选择性,但毕竟毕竟麻烦一点,如果linux distribution厂商能够针对自己的操作平台先进行编译等过程,在将编译好的二进制程序释放出的话,那由于我们的系统与该linux distribution的环境是相同的,所以它所释放出的二进制程序就可以在我们的机器上面直接安装,省略了监测与编译的复制过程。

这个预先编译好程序的机制存在于很多distribution,包括red hat系统开发的rpm管理机制与yum在线更新模式。

由于centos系统是依循标准的linux distribution ,所以可以使用tarball 直接进行编译安装与升级。在此先对tarball进行介绍。

一个软件的tarball是如何安装的呢?

流程如下:

1 tarball 由厂商的网页下载下来

2 tarball解压缩,生成很多的源码文件

3 开始以gcc进行源码的编译(会生成目标文件)

4然后以gcc进行函数库、主程序、子程序的链接,以形成主要的二进制文件。

5将上述的二进制文件以及相关的配置文件安装升级至自己的主机上面。

上面的第34步骤当中,我们可以通过make这个命令的功能来简化它,所以整个步骤其实是很简单的。只不过你就得需要至少有gcc以及make这两软件在你的linux系统里面才行。

二、tarball安装的基本步骤

1文字描述

  1取得原文件:将tarball文件在/usr/local/src目录下解压缩;

2取得步骤流程:进入新建立的目录下面,去查阅installreadme等相关文件内容。

3 相关属性软件安装:根据install/readme的内容查看并安装好一些相关的软件

4建立Makefile:以自动检测程序(configureconfig)检测操作环境,并建立makefile这个文件。

5编译:以make这个程序并使用该目录下的Makefile作为他的参数配置文件,来进行make的操作。

6安装:以make这个程序,并以Makefile这个参数配置文件,依据install这个目标的指定来安装到正确路径。

2命令化简

  1. ./configure  

  这个步骤就是建立Makefile这个文件,通常程序开发者会写一个script来检查你的linux 系统、相关的软件属性等,这个步骤相当重要,因为将来你的案子信息都是这一步骤内完成的。另外这个步骤的相关信息应该参考一下该目录的readmeinstall相关的文件。

  1. Makeclean

 Make会读取Makefile中关于clean的工作。这个步骤不一定会有,但是希望执行一下,因为它可以去除目标文件。

  1. Make

Make会依据Makefile当中的默认工作进行编译的行为。编译的工作主要是进行gcc来将源码编译成为可以被执行的目标文件,但是这些目标文件通常还需要一些函数库之类的链接后,才能生成一个完整的可执行文件!使用make就是要将源码编译成为可以被执行的可执行文件,而这个可执行文件会放置在目录前所在的目录之下,尚未被安装到预定安装的目录中。

4make install通常这就是最后的安装步骤了,make会依据Makefile这个文件里面关于install的选项,将上一个步骤所编译完成的数据安装到默认的目录中,就完成安装。

3注意

上面的步骤是一步一步来进行,而其中只要一个步骤无法成功,那么后续的步骤就完全没有办法进行的!因此,要确定每一步都是成功的才可以。比如,万一今天你在./confiure就不成功了,那么就表示Makefile无法被建立起来,要知道,后面的步骤都是根据Makefile来进行的,既然无法建立Makefile,后续的步骤当然无法成功。

如果在make无法成功的话,那就表示源文件无法被编译成可执行文件,那么make install 主要是将编译完成的文件放置到文件系统中的,既然没有可用的执行文件了,怎么进行安装呢,所以,要每一个步骤都正确无误才能往下继续做。

三、一般tarball软件安装的建议事项(如何删除、升级)

·1 tarball 要在/usr/local/src 里面解压缩

是因为在默认情况下,原本的linux distribution发布安装的软件大多是在/usr里面的,而用户自行安装的软件则建议放置在/usr/local里面,这是考虑到管理用户所安装软件的便利性。

所以:通常建议将自己安装的软件放置在/usr/local下面,而源码(Tarball)则建议放置在/usr/local/src下面。

·2 tarball软件安装的建议事项

1最后将tarball的原始数据解压缩到/usr/local/src

2安装时,最好安装到/usr/local这个默认路径下

3考虑将来反安装的步骤,最好可以将每个软件单独安装在/usr/local下面

4为安装到单独目录的软件的man page 加入man path搜索

四、安装ntp中了解下英文

1.install

Basic Installation

==================

   These are generic *nix installation instructions.

   For Windows/NT, please see ports/winnt and html/build/hints/winnt.html.

   The `configure' shell script attempts to guess correct values for

various system-dependent variables used during compilation(编译).  It uses

those values to create a `Makefile' in each directory of the package.

It may also create one or more `.h' files containing system-dependent(依赖)

Definitions(定义).  Finally, it creates a shell script `config.status' that

you can run in the future(日后) to recreate the current configuration, a file

`config.cache' that saves the results of its tests to speed up

reconfiguring, and a file `config.log' containing compiler(汇编) output

(useful mainly for debugging `configure').

   If you need to do unusual things to compile the package, please try

to figure(估算) out how `configure' could check whether to do them, and mail

diffs or instructions to the address given in the `README' so they can

be considered for(被认为是) the next release.  If at some point `config.cache'

contains results you don't want to keep, you may remove or edit it.

   The file `configure.in' is used to create `configure' by a program

called `autoconf'.  You only need `configure.in' if you want to change

it or regenerate `configure' using a newer version of `autoconf'.

The simplest way to compile(汇编、编制) this package is:

  1. `cd' to the directory containing the package's source code and type

     `./configure' to configure the package for your system.  If you're

     using `csh' on an old version of System V, you might need to type

     `sh ./configure' instead to prevent `csh' from trying to execute(执行)

     `configure' itself.

     Running `configure' takes a while.  While running, it prints some

     messages telling which features(特征) it is checking for.

  2. Type `make' to compile the package.

  3. Optionally, type `make check' to run any self-tests that come with

     the package.

  4. Type `make install' to install the programs and any data files and

     Documentation(记录).

  5. You can remove the program binaries and object files from the

     source code directory by typing `make clean'.  To also remove the

     files that `configure' created (so you can compile the package for

     a different kind of computer), type `make distclean'.  There is

     also a `make maintainer-clean' target, but that is intended mainly

     for the package's developers.  If you use it, you may have to get

     all sorts of other programs in order to regenerate(回收) files that came

     with the distribution(分配).

Compilers and Options

=====================

   Some systems require unusual options for compilation or linking that

the `configure' script does not know about.  You can give `configure'

initial values(初始值) for variables by setting them in the environment.  Using

a Bourne-compatible shell, you can do that on the command line like

this:

     CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure

Or on systems that have the `env' program, you can do it like this:

     env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure

Compiling For Multiple Architectures

====================================

   You can compile the package for more than one kind of computer at the

same time, by placing the object files for each architecture in their

own directory.  To do this, you must use a version of `make' that

supports the `VPATH' variable, such as GNU `make'.  `cd' to the

directory where you want the object files and executables(可执行的) to go and run

the `configure' script.  `configure' automatically checks for the

source code in the directory that `configure' is in and in `..'.

   If you have to use a `make' that does not supports the `VPATH'

variable, you have to compile the package for one architecture at a time

in the source code directory.  After you have installed the package for

one architecture, use `make distclean' before reconfiguring(重新配置) for another

architecture.

Installation Names

==================

   By default(默认情况下), `make install' will install the package's files in

`/usr/local/bin', `/usr/local/man', etc.  You can specify(指定) an

installation prefix other than `/usr/local' by giving `configure' the

option `--prefix=PATH'.

   You can specify(指定) separate(分开) installation prefixes(前缀) for

architecture-specific files and architecture-independent files.  If you

give `configure' the option `--exec-prefix=PATH', the package will use

PATH as the prefix for installing programs and libraries.

Documentation and other data files will still use the regular prefix.

   If the package supports it, you can cause programs to be installed

with an extra prefix or suffix(后缀) on their names by giving `configure' the

option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.

Optional Features

=================

   Some packages pay attention to `--enable-FEATURE' options to

`configure', where FEATURE indicates(指示) an optional part of the package.

They may also pay attention to `--with-PACKAGE' options, where PACKAGE

is something like `gnu-as' or `x' (for the X Window System).  The

`README' should mention any `--enable-' and `--with-' options that the

package recognizes.

   For packages that use the X Window System, `configure' can usually

find the X include and library files automatically(自动的), but if it doesn't,

you can use the `configure' options `--x-includes=DIR' and

`--x-libraries=DIR' to specify their locations.

Specifying(指定) the System Type

   There may be some features(特色) `configure' can not figure out

automatically, but needs to determine(决定) by the type of host the package

will run on.  Usually `configure' can figure that out, but if it prints

a message saying it can not guess the host type, give it the

`--host=TYPE' option.  TYPE can either be a short name for the system

type, such as `sun4', or a canonical name with three fields:

     CPU-COMPANY-SYSTEM

See the file `config.sub' for the possible values of each field.  If

`config.sub' isn't included in this package, then this package doesn't

need to know the host type.

   If you are building compiler tools for cross-compiling, you can also

use the `--target=TYPE' option to select the type of system they will

produce code for and the `--build=TYPE' option to select the type of

system on which you are compiling the package.

Sharing Defaults

================

   If you want to set default values for `configure' scripts to share,

you can create a site shell script called `config.site' that gives

default values for variables like `CC', `cache_file', and `prefix'.

`configure' looks for `PREFIX/share/config.site' if it exists, then

`PREFIX/etc/config.site' if it exists.  Or, you can set the

`CONFIG_SITE' environment variable to the location of the site script.

A warning: not all `configure' scripts look for a site script.

Operation Controls

==================

   `configure' recognizes(确认承认) the following options to control how it

operates.

`--cache-file=FILE'

     Use and save the results of the tests in FILE instead of

     `./config.cache'.  Set FILE to `/dev/null' to disable caching, for

     debugging `configure'.

`--help'

     Print a summary of the options to `configure', and exit.

`--quiet'

`--silent'

`-q'

     Do not print messages saying which checks are being made.

`--srcdir=DIR'

     Look for the package's source code in directory DIR.  Usually

     `configure' can determine that directory automatically.

`--version'

     Print the version of Autoconf used to generate the `configure'

     script, and exit.

`configure' also accepts some other, not widely useful, options.

2configure 支持参数

`configure' configures ntp 4.2.4p7 to adapt(适应于) to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign(分派) environment variables (e.g., CC, CFLAGS...), specify(详细说明) them as

VAR=VALUE.  See below for(下面的) descriptions of some of the useful variables.

Defaults for the options are specified (指定的)in brackets(在括号内).

Configuration:

  -h, --help              display this help and exit

      --help=short        display options specific to this package

      --help=recursive(递归)    display the short help of all the included packages

  -V, --version           display version information(消息) and exit

  -q, --quiet, --silent   do not print `checking...' messages

      --cache-file=FILE   cache test results in FILE [disabled]

  -C, --config-cache      alias for(别名) `--cache-file=config.cache'

  -n, --no-create         do not create output(产出) files

      --srcdir=DIR        find the sources(来源) in DIR [configure dir or `..']

Installation directories:

  --prefix=PREFIX         install architecture-independent(自主的目录) files in PREFIX

  [/usr/local]

  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX(前缀)

  [PREFIX]

By default, `make install' will install all the files in

`/usr/local/bin', `/usr/local/lib' etc.  You can specify(指定)

an installation prefix other than `/usr/local' using `--prefix',

for instance(例子、情况)`--prefix=$HOME'.

For better control, use the options below.

Fine tuning of(微调) the installation directories:

  --bindir=DIR           user executables [EPREFIX/bin]

  --sbindir=DIR          system admin executables(可执行的) [EPREFIX/sbin]

  --libexecdir=DIR       program executables [EPREFIX/libexec]

  --datadir=DIR          read-only architecture-independent data [PREFIX/share]

  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]

  --sharedstatedir=DIR   modifiable(可更改的) architecture-independent data [PREFIX/com]

  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]

  --libdir=DIR           object code libraries [EPREFIX/lib]

  --includedir=DIR       C header files [PREFIX/include]

  --oldincludedir=DIR    C header files for non-gcc [/usr/include]

  --infodir=DIR          info documentation [PREFIX/info]

  --mandir=DIR           man documentation [PREFIX/man]

Program names:

  --program-prefix=PREFIX            prepend PREFIX to installed program names

  --program-suffix=SUFFIX            append SUFFIX to installed program names

  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names

System types:

  --build=BUILD     configure for building on BUILD [guessed]

  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

Optional Features:

  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)

  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]

  --disable-dependency-tracking  speeds up one-time build

  --enable-dependency-tracking   do not reject slow dependency extractors

  --enable-shared[=PKGS]

                          build shared libraries [default=no]

  --enable-local-libopts  Force using the supplied libopts tearoff code

  --disable-libopts-install

                          Do not install libopts with client installation

  --disable-optional-args not wanting optional option args

  --enable-static[=PKGS]

                          build static libraries [default=yes]

  --enable-fast-install[=PKGS]

                          optimize for fast installation [default=yes]

  --disable-libtool-lock  avoid locking (might break parallel builds)

  --enable-getifaddrs     s Enable the use of getifaddrs() [yes|no|glibc].

                          glibc: Use getifaddrs() in glibc if you know it

                          supports IPv6.

  --enable-debugging      + include debugging code

  --enable-debug-timing   - include processing time debugging code (costs

                          performance)

  --enable-dst-minutes    n minutes per DST adjustment [60]

  --enable-ignore-dns-errors

                          - retry DNS queries on any error

  --enable-BANCOMM        - Datum/Bancomm bc635/VME interface

  --enable-GPSVME         - TrueTime GPS receiver/VME interface

  --enable-all-clocks     + include all suitable non-PARSE clocks:

  --enable-ACTS           s ACTS modem service

  --enable-ARBITER        + Arbiter 1088A/B GPS receiver

  --enable-ARCRON-MSF     + Arcron MSF receiver

  --enable-AS2201         + Austron 2200A/2201A GPS receiver

  --enable-ATOM           s ATOM PPS interface

  --enable-CHRONOLOG      + Chrono-log K-series WWVB receiver

  --enable-CHU            + CHU modem/decoder

  --enable-AUDIO-CHU      s CHU audio/decoder

  --enable-DATUM          s Datum Programmable Time System

  --enable-DUMBCLOCK      + Dumb generic hh:mm:ss local clock

  --enable-FG             + Forum Graphic GPS

  --enable-HEATH          s Heath GC-1000 WWV/WWVH receiver

  --enable-HOPFSERIAL     + hopf serial clock device

  --enable-HOPFPCI        + hopf 6039 PCI board

  --enable-HPGPS          + HP 58503A GPS receiver

  --enable-IRIG           s IRIG audio decoder

  --enable-JJY            + JJY receiver

  --enable-JUPITER        s Rockwell Jupiter GPS receiver

  --enable-LEITCH         + Leitch CSD 5300 Master Clock System Driver

  --enable-LOCAL-CLOCK    + local clock reference

  --enable-MX4200         s Magnavox MX4200 GPS receiver

  --enable-NEOCLOCK4X     + NeoClock4X DCF77 / TDF receiver

  --enable-NMEA           + NMEA GPS receiver

  --enable-ONCORE         s Motorola VP/UT Oncore GPS receiver

  --enable-PALISADE       s Palisade clock

  --enable-PCF            + Conrad parallel port radio clock

  --enable-PST            + PST/Traconex 1020 WWV/WWVH receiver

  --enable-RIPENCC        - RIPENCC specific Trimble driver

  --enable-SHM            s SHM clock attached thru shared memory

  --enable-SPECTRACOM     + Spectracom 8170/Netclock/2 WWVB receiver

  --enable-TPRO           s KSI/Odetics TPRO/S GPS receiver/IRIG interface

  --enable-TRUETIME       s Kinemetrics/TrueTime receivers

  --enable-TT560          - TrueTime 560 IRIG-B decoder

  --enable-ULINK          + Ultralink WWVB receiver

  --enable-WWV            s WWV Audio receiver

  --enable-ZYFER          + Zyfer GPStarplus receiver

  --enable-parse-clocks   - include all suitable PARSE clocks:

  --enable-COMPUTIME      s Diem Computime Radio Clock

  --enable-DCF7000        s ELV/DCF7000 clock

  --enable-HOPF6021       s HOPF 6021 clock

  --enable-MEINBERG       s Meinberg clocks

  --enable-RAWDCF         s DCF77 raw time code

  --enable-RCC8000        s RCC 8000 clock

  --enable-SCHMID         s Schmid DCF77 clock

  --enable-TRIMTAIP       s Trimble GPS receiver/TAIP protocol

  --enable-TRIMTSIP       s Trimble GPS receiver/TSIP protocol

  --enable-WHARTON        s WHARTON 400A Series clock

  --enable-VARITEXT       s VARITEXT clock

  --enable-kmem           s read /dev/kmem for tick and/or tickadj

  --enable-accurate-adjtime

                          s the adjtime() call is accurate

  --enable-tick=VALUE     s force a value for 'tick'

  --enable-tickadj=VALUE  s force a value for 'tickadj'

  --enable-simulator      - build/install the NTPD simulator?

  --enable-slew-always    s always slew the time

  --enable-step-slew      s step and slew the time

  --enable-ntpdate-step   s if ntpdate should step the time

  --enable-hourly-todr-sync

                          s if we should sync TODR hourly

  --enable-kernel-fll-bug s if we should avoid a kernel FLL bug

  --enable-irig-sawtooth  s if we should enable the IRIG sawtooth filter

  --enable-nist           - if we should enable the NIST lockclock scheme

  --enable-ntp-signd      - Provide support for Samba's signing daemon,

                          =/var/run/ntp_signd

  --enable-wintime        - Provide the windows symmetric client hack

  --enable-clockctl       s Use /dev/clockctl for non-root clock control

  --enable-linuxcaps      + Use Linux capabilities for non-root clock control

  --enable-ipv6           s use IPv6?

Optional Packages:

  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]

  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)

  --with-autoopts-config  specify the config-info script

  --with-regex-header     a reg expr header is specified

  --with-libregex         libregex installation prefix

  --with-libregex-cflags  libregex compile flags

  --with-libregex-libs    libregex link command arguments

  --with-binsubdir        bin ={bin,sbin}

  --with-arlib            - Compile the async resolver library?

  --without-rpath         s Disable auto-added -R linker paths

  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]

  --with-pic              try to use only PIC/non-PIC objects [default=use

                          both]

  --with-tags[=TAGS]

                          include additional configurations [automatic]

  --with-openssl-libdir   + =/something/reasonable

  --with-openssl-incdir   + =/something/reasonable

  --with-crypto           + =openssl

  --with-electricfence    - compile with ElectricFence malloc debugger

  --with-kame             - =/usr/local/v6

Some influential environment variables:

  CC          C compiler command

  CFLAGS      C compiler flags

  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a

              nonstandard directory <lib dir>

  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have

              headers in a nonstandard directory <include dir>

  CPP         C preprocessor

Use these variables to override(覆盖) the choices made by `configure' or to help

it to find libraries and programs with nonstandard(不标准的) names/locations.

五、利用patch 更新源码

六、RPM

1Rpm的优点:

RPM内含已经编译过的程序与设置文件等数据,可以让用户免除重新编译的困扰;

RPM在被安装之前,会先检查系统的硬盘容量、操作系统版本等,可避免文件被错误安装;

RPM文件本身提供软件版本信息、依赖属性名称、软件用途说明、软件所含文件等信,便于了解软件;

RPM管理的方式使用数据库记录RPM文件的相关参数,便于升级、删除、查询与验证。

2、rpm相关性问题

为了解决具有相关性的软件之间的问题(就是所谓的软件依赖属性)。Rpm就在提供打包的软件时,同时加入一些信息记录的功能,这些信息包括软件的版本,打包软件者、依赖属性的其他软件、本软件的功能说明、本软件的所有文件记录等,然后在linux系统上面也建立一个rpm软件数据库,如此一来,当你要安装某个以rpm类型提供的软件时,在安装过程中,rpm会去检验一下数据库里面是否已经存在相关的软件了,如果数据库显示不存在,那么这个rpm文件“默认”就不能安装。这个就是rpm类型的文件最为人诟病的“软件的属性依赖”问题。

七、RPM属性依赖的解决方式: YUM在线升级

因为rpm软件文件有所谓的属性依赖的问题。RPM软件文件内部不是会记录依赖属性的数据吗?那想一下,要是我们将这些依赖属性的软件先列表,在有要安装软件需求的时候先到这个列表去找,同时与系统内已安装的软件相比较,没安装到的依赖软件就一口气同时安装起来,那不就解决了依赖属性的问题了吗。这种机制就是yum机制。

Centos先将发布的软件放置到yum服务器内,然后分析这些软件的依赖属性问题,将软件内的记录信息写下来。然后在将这些信息分析后记录成软件相关性的清单列表。这些列表数据与软件所在的位置可以称为容器。当客户端有软件安装的需求时,客户端主机会主动向网络上面的yum服务器的容器网址下载清单列表,然后通过清单列表的数据与本机rpm数据库已存在的软件数据库相比较,没安装到的依赖软件就一口气同时安装起来,那不就解决了依赖属性的问题了吗。

Centos先将发布的软件放置到yum服务器内,然后分析这些软件的依赖属性问题,将软件内的记录信息写下来。然后在将这些信息分析后记录成软件相关性的清单列表。客户端主机会主动向网络上面的yum服务器的容器网址下载清单列表,然后通过清单列表的数据与本机rpm数据库已存在的软件数据库相比较,就能一口气安装所有需要的具有依赖属性的软件了。

流程如下:

当客户端有升级、安装的需求时,yum会向容器要求清单的更新,等到清单更新到本机的/var/cache/yum 里面后,等一下更新时就会用到这个本机清单与本机的rpm数据库进行比较,这样就知道该下载什么软件。接下来yum会跑到容器服务器下载所需要的软件。然后在通过rpm的机制开始安装软件。这就是整个流程。

八、RPM 软件管理程序:rpm

1、rpm安装软件

Command

rpm -ivh package_name

-i:install 的意思

-v:查看详细的安装信息

h:以安装信息栏显示安装进度条

2、RPM升级与更新

Command

-Uvh:后面接的软件即使没有安装过,则系统将予以直接安装;若后面接的软件有安装过旧版本,则系统自动更新至新版。

-Fvh:如果后面接的软件并未安装到你的linux系统上,则该软件不会被安装;亦即只有已安装到你Linux系统内的软件会被“升级”

3、RPM查询

rpm -qa                     <== 已安装软件

参数说明:

-q:仅查询,后面接的软件名称是否有安装;找出linux是否安装该软件

-ql:列出该软件所有的文件目录与目录所在完整文件名;列出属于该软件所提供的所有目录与文件

-qi:列出该软件的详细信息,包含开发商、版本与说明等;列出软件的相关说明数据

-qR:列出与该软件有关的依赖软件所含文件。

-qf:由后面接的文件名称找出该文件属于哪一个已安装的软件。查询某个rpm文件内含有的信息。注意!做个参数后面接的是“文件”不像其他的接的是软件。这个功能在于查询系统的某个文件属于哪一个软件所有的。

 

 

 

4简单的练习:(很重要)

1查询系统当中以c开头的软件有几个?

Command

Rpm -qa |grep ^c | wc -l

 

2我的www服务器为apache,我知道他使用的rpm软件文件名为httpd。现在我想要知道这个软件的所有设置文件放置在何处,可以怎么做?

Command

Rpm -qc httpd

 

3承上题,如果查出来的设置文件已经被我改过,但是我忘记了曾经修改过哪些地方,所以想直接重新安装一次该软件,该怎么做

 

假设该软件在网络上的地址为:

http//web.site.name/path/httpd-xxx.xx.xx.i386.rpm

则我们可以这样做:

rpm -ivh http//web.site.name/patch/httpd-xx.xx.xx.i386.rpm --replacepkgs

 

  1. 如果我误删了某个重要文件,例如/etc/crontab,偏偏不晓得它属于那个软件,该怎么办?

 

虽然已经没有这个文件了,不过没有关系,因为RPM有记录在/var/lib/rpm 当中的数据库啊!

所以直接执行:

rpm -qf /etc/crontab

就可以知道是哪个软件。重新安装一次该软件即可。

 

5卸载RPM与重建数据库

卸载就是将软件解除安装。要注意的是,解安装的过程一定要由最上层往下解除。否则就会发生结构上的问题。   这个可以由建筑物来说明,如果你要拆除五、六楼,那么当然要由六楼拆起,否则先拆的是第五楼时,那么上面的楼层难道会悬空?

删除的选项很简单,就通过-e即可删除。不过,很常发生软件属性依赖导致无法删除某些软件的问题。如果关联性不是很强的,例如删除卸载rsync时,我们可以使用--nodeps参数

--nodeps

使用时机:当发生软件属性依赖问题而无法安装卸载,但你执意安装卸载时

危险性:软件会有依赖性的原因是因为彼此会使用到对方的机制或功能,如果强制安装卸载而不考虑软件的属性依赖,则可能会造成该软件的无法正常使用。

九、YUM在线升级机制

1 查询功能

yum  [option] [查询工作项目][相关参数]

主要参数

-y :当yum要等待用户输入时,这个选项可以自动提供yes的响应

Search:搜索某个软件名称或者是描述的重要关键字

List:列出目前yum所管理的所有软件的名称与版本,有点类似于rpm -qa

Info:同上,不过有点类似与rpm -qai 的运行结果

Provides:从文件去搜索软件!类似于rpm -qf的功能!

例:

1 搜索磁盘阵列(raid)相关软件有哪些功能:

 yum search raid

2找出mdadm这个软件的功能为何

 yum info madm

 

3列出yum服务器上面提供的所有软件名称

yum list

 

4列出目前服务器上可供本机进行升级的软件有哪些

yum list updates

 

5列出提供passwd这个文件的软件有哪些

yum provides passwd

 

2 安装升级功能

 yum  [option] [查询工作项目] [相关参数]

 install :后面接要安装的软件

update:后面接要升级的软件,若要整个系统都升级,就直接update即可

3删除功能

yum [remove] 软件

yum remove pam-devel

yum 的设置文件

1参考文章

https://blog.csdn.net/inslow/article/details/54177191

https://blog.csdn.net/betty_xfy/article/details/78018398

https://blog.csdn.net/wdy_2099/article/details/70578529