软件包管理

  应用程序:

程序,Architecture(平台架构)

C语言:源代码-->(编译)二进制格式

脚本:解释器(二进制程序)

源代码-->编译-->链接-->运行

  程序:

    库

      静态

      动态

      静态链接

      动态链接

        共享库

程序:指定+数据

.so:shared object共享对象

配置文件:程序在启动的时候会自动从这个文件读取一些定义的属性,这些属性可以为变量;

dir=/path/to/somewhere

程序组成部分:

  二进制程序

  库

  配置文件

  帮助文件

Linux一级目录:

/boot

/etc

/usr

/var

/dev

/lib

/tmp

/bin

/sbin

/proc

/sys

/mnt

/media

/home

/root

/misc

/opt

/srv

/usr/share/man

/etc, /bin, /sbin, /lib

  系统启动就需要用到的程序,这些目录不能挂载额外的分区,必须在根文件系统的分区上

/usr/

  bin

  sbin

  lib

 

  操作系统核心功能,可以单独分区

/usr/local

  bin

  sbin

  lib

  etc

  man

 

  独立王国,安装操作系统以后,安装第三方软件,这些软件跟操作系统没有关系,跟核心功能也没有关系,只是自己为了运行这个服务器附加一些外围软件进来让它能够运行,可以独立分区,建议独立分区;

/opt

  比较老的第三方软件安装在/opt目录

/proc

/sys

  尾文件系统,/proc内核启动起来以后为了能够给用户提供调用接口,/sys硬件为了能够给用户提供调用接口,不能单独分区,默认为空;

 

/dev: 设备,不能单独分区;

  udev:能够实现让内核通过驱动程序自动在识别到某个硬件以后,自动在/dev目录创建设备文件,让设备文件是按需创建,而不是像2.4内核以前准备所有的;

 

/home:建议单独分区,相当于windows的D、E、F盘,存放用户文件,还需要分大一点空间

/root: 可以没有,管理员可以四处为家,不能单独分区

/var:在有写情况作为系统运行的补充,外围文件系统,给程序运行提供存放PAD文件、锁文件、日志文件存放,建议单独分区,猜装完系统比较小,随着系统运行越来越大,建议分大一点空间

/boot:内核,initrd(initramfs)

  内核:建议单独分区,/boot作为基本分区,而/根做成LVM;

/tmp:可以单独分区

/srv:不能单独分区

/opt:可以单独分区

/misc:杂项,不便归类的

 

POST-->BIOS(HD)-->(MBR)bootloader(文件系统结构,ext2, ext3, xfs)-->内核

程序:指令+数据

  指令:芯片

    CPU: 普通指令,特权指令

    指令集

C语言:

  Powerpc: 二进制格式

  x86:

x86: 汇编

powerpc: 汇编

高级语言:

C:

软件包管理器:

一个操作系统组成内核加库各种应用程序,要在一个操作系统或文件系统平台上安装各种应用程序如何装,安装的软件可能有成千上万个,比如装500个应用程序,每个应用程序都提供二进制程序、配置文件、库文件、帮助文件,装无非就是放到响应目录下就可以了,但是要卸载,比较麻烦,这时候就有了软件包管理器,帮助我们能够把一个软件编译好所提供的基本应用程序,二进制程序、库文件、配置文件、帮助文件打包起来成一个文件,还能将打包的文件按需,要安装这个软件,只需要把这个打包文件安装,这个软件包管理器能够按照指定位置自动将二进制程序展开到响应路径上,不但如此它放进去还能追踪这些文件,安装以后到底安装那些文件,能够生成数据库,追踪所安装的每一个文件,如果要删除软件包管理也能帮助我们卸载,它根据数据库中的记录,每一个软件所生成的文件它都有记录,根据这些记录再把对应的文件给它移除即可,软件包管理器自身也是个软件,它也能够自我管理,把自己做成自己所能识别的格式来运行,它自己没装之前怎么管理别人,这就要依赖于其他机制,有个接入点能够帮我们安装第一个管理软件RPM管理器,安装完以后就可以用管理器来管理其他任何软件;

软件包管理器的核心功能:

1、制作软件包;

2、安装、卸载、升级、查询、校验;

Redhat, SUSE, Debian

Redhat, SUSE: RPM

  Redhat Package Manager

  PRM is Package Manager

Debian: dpt

依赖关系:

  X-->Y-->Z


  X-->Y-->Z

前端工具:yum, apt-get

后端工具:RPM, dpt

yum: Yellowdog Update Modifier

  yum

[root@Smoke ~]# cat /proc/cpuinfo(查看cpu信息文件)
processor        : 0
vendor_id        : GenuineIntel
cpu family        : 6
model                : 58
model name        : Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
stepping        : 9
cpu MHz                : 2494.379
cache size        : 3072 KB
fpu                : yes
fpu_exception        : yes
cpuid level        : 13
wp                : yes
flags                : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall
 nx rdtscp lm constant_tsc up arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni pclmulqdq ssse3 
cx16 pcid sse4_1 sse4_2 x2apic popcnt aes xsave avx f16c rdrand hypervisor lahf_lm ida arat epb xsaveopt pln pts dts fsgsbase smep(cpu指令集)
bogomips        : 4988.75
clflush size        : 64
cache_alignment        : 64
address sizes        : 40 bits physical, 48 bits virtual
power management:

rpm命令:

rpm:管理软件

数据库:/var/lib/rpm

rpmbuild:创建RPM包

 

安装、查询、卸载、升级、校验、数据库的重建、验正数据包等工作;

rpm命名:

包:组成部分(一个主包N个子包)

  主包:

    bind-9.7.1-1.el5(红帽5,el6红帽6).i586.rpm

  子包:

    bind-libs-9.7.1-1.el5.i586.rpm

    bind-utils-9.7.1-1.el5.i586.rpm

包名格式:

  name(名称)-version(版本号)-release(发行号).arch(平台架构).rpm

  bind-major(主版本号).minor(次版本号).release(软件开发者发行号).-release(rpm制作者).arch.rpm

主版本号:重大改进

次版本号:某个子功能发生重大变化

发行号:修正了部分bug,调整了一点功能

bind-9.7.1.tar.gz

rpm包:

  源码格式:安装维护麻烦,能够好发挥硬件性能

  二进制格式:安装简单

    rpm包作者下载源程序,编译配置完成后,制作成rpm包

    bind-9.7.1-1.noarch.rpm

    bind-9.7.1-1.ppc.rpm

el5:红帽5,el6红帽6

i686:32位平台,i586也是32位平台

x64:64位平台

x86_64:64位平台

noarch:更平台无关

ppc:power pc平台

rpm:

1、安装

rpm -i /PATH/TO/PACKAGE_FILE

  -h,--hash: 以#显示进度;每个#表示2%;

  -v: 显示详细过程

  -vv: 更详细的过程

rpm -ivh /PATH/TO/PACKAGE_FILE

  --nodeps: 忽略依赖关系,会导致软件安装上没办法运行

  --replacepkgs: 重新安装,替换原有安装;

  --replacefiles:替换原文件;

  --oldpackage:降级安装;

  --force: 强行安装,可以实现重装或降级;

  --test:测试安装检查冲突和依赖关系;

2、查询

rpm -q PACKAGE_NAME: 查询指定的包是否已经安装,不能使用软件包路径和软件包名字,只需要软件名字

rpm -qa : 查询已经安装的所有包

rpm -qi PACKAGE_NAME: 查询指定包的说明信息;

rpm -ql PACKAGE_NAME: 查询指定包安装后生成的文件列表;

rpm -qc PACEAGE_NEME:查询指定包安装的配置文件;

rpm -qd PACKAGE_NAME: 查询指定包安装的帮助文件;

rpm -q --scripts PACKAGE_NAME: 查询指定包中包含的脚本,有四类脚本安装前、安装后、卸载前、卸载后;

 

rpm -qf /path/to/somefile: 查询指定的文件是由哪个rpm包安装生成的;

 

如果某rpm包尚未安装,我们需查询其说明信息、安装以后会生成的文件;

rpm -qpi /PATH/TO/PACKAGE_FILE:安装后的说明信息

rpm -qpl:安装后生成的文件列表

rpm -qpc:安装后生成配置文件

rpm -qpd:安装后帮助文件

3、升级

rpm -Uvh /PATH/TO/NEW_PACKAGE_FILE: 如果装有老版本的,则升级;否则,则安装;

rpm -Fvh /PATH/TO/NEW_PACKAGE_FILE:如果装有老版本的,则升级;否则,退出;

  --oldpackage: 降级

4、卸载

rpm -e PACKAGE_NAME:卸载时候,这个软件包不能被其他软件包依赖,不允许被卸载;

  --nodeps:强行卸载

 

5、校验

rpm -V PACKAGE_NAME:能够查询软件包安装以后的元数据是否被修改过;

S: 文件大小改变

M:权限和文件类型改变

5: MD5校验改变

D: 设备文件的主次数量不匹配

L:路径不匹配

U:属主不匹配

G:属组不匹配

T: 最近一次修改时间发送改变

6、重建数据库

  数据库:/var/lib/rpm/

  rpm

    --rebuilddb: 重建数据库,一定会重新建立;

    --initdb:初始化数据库,没有才建立,有就不用建立;

7、检验来源合法性,及软件包完整性;

加密类型:

  对称:加密解密使用同一个密钥

  公钥:一对儿密钥,公钥,私钥;公钥隐含于私钥中,可以提取出来,并公开出去;

 

  单向:

# ls /etc/pki/rpm-gpg/

RPM-GPG-KEY-redhat-release:红帽RPM校验密钥

 

rpm -K /PAPT/TO/PACKAGE_FILE

  dsa, gpg: 验正来源合法性,也即验正签名;可以使用--nosignature,不验证合法性

  sha1, md5: 验正软件包完整性;可以使用--nodigest,不验证完整性

 

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release: 导入密钥文件

[root@Smoke ~]# uname -r(-r 查看内核版本号)
2.6.32-431.11.2.el6.x86_64
[root@Smoke ~]# uname -a(-a 查看平台各种版本)
Linux Smoke 2.6.32-431.11.2.el6(内核版本号).x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64(硬件平台版本) GNU/Linux
[root@Smoke ~]# lftp 172.16.0.1(连接ftp服务器)
lftp 172.16.0.1:/ ~> cd pub(切换到pub目录)
lftp 172.16.0.1:/pub> cd Server/(切换到server目录)
lftp 172.16.0.1:/pub/Server> get zsh-4.2.6-6.el5.i386.rpm(下载软件包)
1788589 bytes transferred
lftp 172.16.0.1:/pub/Server> bye(退出)
[root@Smoke ~]# ls(查看当前目录文件及子目录)
zsh-4.3.10-7.el6.x86_64.rpm
[root@Smoke ~]# rpm -ivh zsh-4.3.10-7.el6.x86_64.rpm(安装zsh软件包,-i安装,-h显示安装进度,-v显示详细过程)
Preparing...                ########################################### [100%]
  1:zsh                    ########################################### [100%]
[root@Smoke ~]# lftp 172.16.0.1(连接ftp服务器)
lftp 172.16.0.1:~> cd pub/Server/
lftp 172.16.0.1:/pub/Server> get php53-mysql-5.3.3-5.el5.i386.rpm
89075 bytes transferred
lftp 172.16.0.1:/pub/Server> bye
[root@Smoke ~]# ls(查看当前目录文件及子目录)
php-mysql-5.3.3-26.el6.x86_64.rpm
[root@Smoke ~]# rpm -ivh php-mysql-5.3.3-26.el6.x86_64.rpm(安装php-mysql软件包,-i安装,-h显示安装进入,-v显示详细过程)
error: Failed dependencies:(错误依赖关系)
       php-common(x86-64) = 5.3.3-26.el6 is needed by php-mysql-5.3.3-26.el6.x86_64
[root@Smoke ~]# rpm -ivh zsh-4.3.10-7.el6.x86_64.rpm(重新安装zsh软件包,提示安装过了)
Preparing...                ########################################### [100%]
       package zsh-4.3.10-7.el6.x86_64 is already installed
提示:安装过的软件包如果再安装提示已经安装,如果要强制安装使用--replacepkgs选项安装
[root@Smoke ~]# rpm -ivh --replacepkgs zsh-4.3.10-7.el6.x86_64.rpm(安装zsh软件包,-i安装,-h显示安装进入,-v显示详细过程,--replacepkgs重新安装
替换原来的安装)
Preparing...                ########################################### [100%]
  1:zsh                    ########################################### [100%]
[root@Smoke ~]# rpm -q zsh-4.3.10-7.el6.x86_64.rpm(-q 查询软件zsh是否安装通过查询软件包的名字显示没有安装)
package zsh-4.3.10-7.el6.x86_64.rpm is not installed
[root@Smoke ~]# rpm -q zsh(-q 查询软件zsh是否安装,使用名称显示安装)
zsh-4.3.10-7.el6.x86_64
提示:查询不能使用软件包的路径和软件包的名字,只需要输入软件的名字
[root@Smoke ~]# rpm -q z*(通过z*通配到当前目录的文件上去了)
package zero.txt is not installed
package zsh-4.3.10-7.el6.x86_64.rpm is not installed
[root@Smoke ~]# rpm -qa z*(把z*当成它的名字)
提示:不能使用文件名通配查询软件包安装
[root@Smoke ~]# rpm -qa(查询已经安装的所有包)
[root@Smoke ~]# rpm -qa | grep "^z"(-qa 查询已经安装的所有软件包,送给grep查找以z开头的软件包)
zip-3.0-1.el6.x86_64
zlib-devel-1.2.3-29.el6.x86_64
zenity-2.28.0-1.el6.x86_64
zd1211-firmware-1.4-4.el6.noarch
zsh-4.3.10-7.el6.x86_64
zlib-1.2.3-29.el6.x86_64
[root@Smoke ~]# rpm -qi zsh(-qi 查询zsh软件包的说明信息)
Name(名称)        : zsh                         Relocations: (not relocatable)
Version(版本)     : 4.3.10                            Vendor(提供商): CentOS
Release(发行版本)     : 7.el6                         Build Date(制作日期): Mon 25 Nov 2013 01:40:59 AM CST
Install Date: Fri 29 Aug 2014 11:12:44 PM CST      Build Host(制作主机): c6b9.bsys.dev.centos.org
Group       : System Environment/Shells     Source RPM(源码包): zsh-4.3.10-7.el6.src.rpm
Size        : 5009102                          License(版权): BSD
Signature(验证)   : RSA/SHA1, Mon 25 Nov 2013 03:33:46 AM CST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem < http://bugs.centos.org >
URL         : http://zsh.sunsite.dk/
Summary(简要信息)     : A powerful interactive shell
Description(详细信息) :
The zsh shell is a command interpreter usable as an interactive login
shell and as a shell script command processor.  Zsh resembles the ksh
shell (the Korn shell), but includes many enhancements.  Zsh supports
command line editing, built-in spelling correction, programmable
command completion, shell functions (with autoloading), a history
mechanism, and more.
[root@Smoke ~]# rpm -ql zsh | less(-ql 查询zsh软件包生成那些文件,将结果送给less分页显示)
/bin/zsh
/etc/skel/.zshrc
/etc/zlogin
/etc/zlogout
/etc/zprofile
/etc/zshenv
/etc/zshrc
/usr/lib64/zsh
/usr/lib64/zsh/4.3.10
/usr/lib64/zsh/4.3.10/zsh
/usr/lib64/zsh/4.3.10/zsh/attr.so
/usr/lib64/zsh/4.3.10/zsh/cap.so
/usr/lib64/zsh/4.3.10/zsh/clone.so
/usr/lib64/zsh/4.3.10/zsh/compctl.so
/usr/lib64/zsh/4.3.10/zsh/complete.so
[root@Smoke ~]# rpm -qf /etc/inittab(-qf 查询/etc/inittab文件是由哪个rpm包安装生成的)
initscripts-9.03.40-2.el6.centos.1.x86_64
[root@Smoke ~]# rpm -qc zsh(-qc 查询zsh软件包安装的配置文件)
/etc/skel/.zshrc
/etc/zlogin
/etc/zlogout
/etc/zprofile
/etc/zshenv
/etc/zshrc
[root@Smoke ~]# rpm -q --scripts zsh(--scripts 查询指定包中包含的脚本)
postinstall(安装后) scriptlet (using /bin/sh):
if [ ! -f /etc/shells ] ; then
   echo "/bin/zsh" > /etc/shells
else
   grep -q "^/bin/zsh$" /etc/shells || echo "/bin/zsh" >> /etc/shells
fi
if [ -f /usr/share/info/zsh.info.gz ]; then
# This is needed so that --excludedocs works.
/sbin/install-info /usr/share/info/zsh.info.gz /usr/share/info/dir \
 --entry="* zsh: (zsh).                        An enhanced bourne shell."
fi
:
preuninstall(卸载前) scriptlet (using /bin/sh):
if [ "$1" = 0 ] ; then
   if [ -f /usr/share/info/zsh.info.gz ]; then
   # This is needed so that --excludedocs works.
   /sbin/install-info --delete /usr/share/info/zsh.info.gz /usr/share/info/dir \
     --entry="* zsh: (zsh).                        An enhanced bourne shell."
   fi
fi
:
postuninstall(卸载后) scriptlet (using /bin/sh):
if [ "$1" = 0 ] ; then
   if [ -f /etc/shells ] ; then
       TmpFile=`/bin/mktemp /tmp/.zshrpmXXXXXX`
       grep -v '^/bin/zsh$' /etc/shells > $TmpFile
       cp -f $TmpFile /etc/shells
       rm -f $TmpFile
   fi
fi
[root@Smoke ~]# lftp(连接ftp服务器)
cd ok, cwd=/pub
lftp 172.16.0.1:/pub> cd Server/(切换到Server目录)
lftp 172.16.0.1:/pub/Server> get httpd-devel-2.2.3-64.el5.i386.rpm(下载httpd-devel软件包)
156353 bytes transferred
lftp 172.16.0.1:/pub/Server> bye(退出)
[root@Smoke ~]# rpm -q httpd-devel(-q 查询httpd-devel软件是否安装)
package httpd-devel is not installed
[root@Smoke ~]# rpm -qpi httpd-devel-2.2.15-29.el6.centos.x86_64.rpm(-qpi 查看httpd-devel软件包安装后的说明信息)
Name        : httpd-devel                  Relocations: (not relocatable)
Version     : 2.2.15                            Vendor: CentOS
Release     : 29.el6.centos                 Build Date: Wed 14 Aug 2013 01:30:33 AM CST
Install Date: (not installed)               Build Host: c6b8.bsys.dev.centos.org
Group       : Development/Libraries         Source RPM: httpd-2.2.15-29.el6.centos.src.rpm
Size        : 539093                           License: ASL 2.0
Signature   : RSA/SHA1, Wed 14 Aug 2013 01:32:38 AM CST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem < http://bugs.centos.org >
URL         : http://httpd.apache.org/
Summary     : Development interfaces for the Apache HTTP server
Description :
The httpd-devel package contains the APXS binary and other files
that you need to build Dynamic Shared Objects (DSOs) for the
Apache HTTP Server.
If you are installing the Apache HTTP server and you want to be
able to compile or develop additional modules for Apache, you need
to install this package.
[root@Smoke ~]# rpm -qpl httpd-devel-2.2.15-29.el6.centos.x86_64.rpm | more(-qpl 查询httpd-devel软件包安装后生成那些文件,将结果送给more分页显示)
/usr/include/httpd
/usr/include/httpd/.mmn
/usr/include/httpd/ap_compat.h
/usr/include/httpd/ap_config.h
/usr/include/httpd/ap_config_auto.h
/usr/include/httpd/ap_config_layout.h
/usr/include/httpd/ap_listen.h
/usr/include/httpd/ap_mmn.h
/usr/include/httpd/ap_mpm.h
/usr/include/httpd/ap_provider.h
[root@Smoke ~]# rpm -q nano(-q 查看nano软件是否安装)
nano-2.0.9-7.el6.x86_64
[root@Smoke ~]# lftps(连接ftp服务器)
cd ok, cwd=/pub
lftp 172.16.0.1:/pub> cd gls(切换到gls目录)
lftp 172.16.0.1:/pub/gls> cd errata(切换到errata目录)
lftp 172.16.0.1:/pub/gls/errata> get nano-1.3.12-1.1.1.gls.i386.rpm(下载nano软件包新版本)
488321 bytes transferred
lftp 172.16.0.1:/pub/gls/errata> bye(退出)
[root@Smoke ~]# rpm -ivh nano-2.0.9-7.el6.x86_64.rpm(安装nano软件,提示安装过了)
Preparing...                ########################################### [100%]
       package nano-2.0.9-7.el6.x86_64 is already installed
[root@Smoke ~]# rpm -Uvh nano-2.0.9-7.el6.x86_64.rpm(-Uvh 升级nano软件包)
Preparing...                ########################################### [100%]
  1:nano                    ########################################### [100%]
提示:如果升级完成发现和其他软件有冲突,不能使用,可以使用降级
[root@Smoke ~]# lftps(连接ftp服务器)
cd ok, cwd=/pub
lftp 172.16.0.1:/pub> cd Server/(切换到server目录)
lftp 172.16.0.1:/pub/Server> get nano-1.3.12-1.1.i386.rpm(下载nano老版本)
487480 bytes transferred
lftp 172.16.0.1:/pub/Server> bye(退出)
[root@Smoke ~]# rpm -ivh --oldpackage nano-2.0.9-7.el6.x86_64.rpm(--oldpackage 降级安装nano老版本软件包)
Preparing...                ########################################### [100%]
       package nano-2.0.9-7.el6.x86_64 is already installed
[root@Smoke ~]# rpm -Uvh --oldpackage nano-2.0.9-7.el6.x86_64.rpm(--oldpackage 降级更新老版本nano软件包)
Preparing...                ########################################### [100%]
       package nano-2.0.9-7.el6.x86_64 is already installed
[root@Smoke ~]# rpm -q nano(-q 查看nano软件是否安装)
nano-2.0.9-7.el6.x86_64
[root@Smoke ~]# rpm -e zsh(-e 卸载zsh软件)
[root@Smoke ~]# rpm -ivh zsh-4.3.10-7.el6.x86_64.rpm(安装zsh软件,-i安装,-v详细过程,-h进度条)
Preparing...                ########################################### [100%]
  1:zsh                    ########################################### [100%]
[root@Smoke ~]# rpm -V zsh(-V 校验zsh软件是否被修改过)
[root@Smoke ~]# rpm -ql zsh | more(-ql 查看zsh软件生成那些文件管道送给more分页显示)
/bin/zsh
/etc/skel/.zshrc
/etc/zlogin
/etc/zlogout
/etc/zprofile
/etc/zshenv
/etc/zshrc
/usr/lib64/zsh
/usr/lib64/zsh/4.3.10
/usr/lib64/zsh/4.3.10/zsh
/usr/lib64/zsh/4.3.10/zsh/attr.so
[root@Smoke ~]# rm /usr/share/zsh/4.3.10/functions/zfls(删除zsh软件生成的zfls文件)
rm: remove regular file `/usr/share/zsh/4.3.10/functions/zfls'? y
[root@Smoke ~]# vim /usr/share/zsh/4.3.10/functions/zkbd(编辑zsh软件生成的zkbd文件进行内容修改删除)
[root@Smoke ~]# rpm -V zsh(-V 检测zsh软件是否被修改过)
missing     /usr/share/zsh/4.3.10/functions/zfls(没有zfls文件)
S.5....T.    /usr/share/zsh/4.3.10/functions/zkbd(S表示文件大小改变,5标识MD5校验不匹配,T标识最近一次修改时候发生改变)
[root@Smoke ~]# ls /etc/pki/(查看/etc/pki目录文件及子目录)
CA  ca-trust  java  nssdb  rpm-gpg  rsyslog  tls
[root@Smoke ~]# ls /etc/pki/rpm-gpg/(查看/etc/pki/rpm-gpg目录文件及子目录)
RPM-GPG-KEY-CentOS-6  RPM-GPG-KEY-CentOS-Debug-6  RPM-GPG-KEY-CentOS-Security-6  RPM-GPG-KEY-CentOS-Testing-6
[root@Smoke ~]# rpm -K zsh-4.3.10-7.el6.x86_64.rpm(-K 检查zsh软件包的合法性)
zsh-4.3.10-7.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK
[root@Smoke ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6(--import 导入红帽RPM软件校验密钥)
[root@Smoke ~]# rpm -K zsh-4.3.10-7.el6.x86_64.rpm(-K 检查zsh软件包的合法性)
zsh-4.3.10-7.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK
[root@Smoke ~]# rpm -K --nodigest zsh-4.3.10-7.el6.x86_64.rpm(--nodigest 不验证 完整性只验证签名)
zsh-4.3.10-7.el6.x86_64.rpm: rsa (md5) pgp OK
[root@Smoke ~]# ls /var/lib/rpm/(查看RPM数据库文件目录)
Basenames     __db.002  Dirnames     Installtid    Packages(包名)        Pubkeys(公钥信息)         Sha1header
Conflictname  __db.003  Filedigests  Name(名字)          Providename     Requirename     Sigmd5
__db.001      __db.004  Group(多少个组)        Obsoletename  Provideversion  Requireversion  Triggername

rpm --> yum

rpm: 依赖关系

x --> y

C/S:

Client,Server

yum repository(yum仓库):所有RPM软件包存储的场所

文件服务:

  ftp

  web

  file

yum:rpm能力,元数据文件

Client:

  配置文件

    yum仓库

RedHat

DVD

  rpm包

  元数据文件

    createrepo:创建元数据文件

HTML: HyperText Mark Language

XML: eXtended Mark Language

XML, JSON: 半结构化的数据

yum仓库中的元数据文件:

primary.xml.gz

  所有RPM包的列表;

  依赖关系;

  每个RPM安装生成的文件列表;

filelists.xml.gz

  当前仓库中所有RPM包的所有文件列表;

other.xml.gz

  额外信息,RPM包的修改日志;

repomd.xml

  记录的是上面三个文件的时间戳和校验和;

yum install zsh

comps*.xml: RPM包分组信息

yum:

  install package1 [package2] [...]:安装

  update [package1] [package2] [...]:升级

  update-to [package1] [package2] [...]:升级到指定版本

  check-updae:检查有多少可用更新

  upgrade [package1] [package2] [...]:升级

  upgrade-to [package1] [package2] [...]:升级到指定版本

  remote | erase package1 [package2] [...]:卸载

  list [...]:显示已经安装的所有软件包

  info [...]:查询指定包的说明信息;

  provides | whatprovides feature1 [feature2] [...]:查询指定的文件是由哪个rpm包安装生成的;

  clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]:清理缓存

  makecache:创建缓存

  groupinstall group1 [group2] [...]:安装组

  groupupdate group1 [group2] [...]:组升级

  grouplist [hidden] [groupwildcard] [...]:列出组

  groupremove group1 [group2] [...]:删除组

  groupinfo group1 [...]:查看组信息

  search string1 [string2] [...]:根据字符串查找软件包

  shell [filename]:和shell交互

  localinstall rpmfile1 [rpmfile2] [...] (maintained for legacy reasons only - use install):本地安装RPM包,但这个软件包依赖于yum仓库中的软件包,必须要指rpm安装文件

  localupdate rpmfile1 [rpmfile2] [...] (maintained for legacy reasons only - use update):本地升级

  reinstall package1 [package2] [...]:重启安装

  downgrade package1 [package2] [...]:降级

  repolist [all|enabled|disabled]:列出所有可用参数

ftp://172.16.0.1/pub/{Server,VT,Cluster,ClusterStorage }

yum配置文件:/etc/yum.conf

如何为yum定义repo文件

[Repo_ID](repo名称,不能其他repo重名,它是这个repo唯一标识符)

name=Description(repo名称)

baseurl=(repo仓库所在具体的访问路径)

  ftp:// (ftp文件路径)

  http:// (http文件路径)

  file:/// (本地文件路径,最后一个/斜杠标识本地路径根)

enabled={1|0}(当前仓库是否允许被使用,1标识使用,0标识禁用)

gpgcheck={1|0}(是否使用gpg机构来验证软件包的合法性,1代表验证,0代表不验证,如果验证需要指定gpgkey)

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-6(gpg文件验证RPM包具体路径,红帽RPM校验密钥)

yum [options] [command] [package ...]

-y: 自动回答为yes

--nogpgcheck:不通过gpg对rpm软件包做合法性校验,如果通过网上yum源安装软件,可以使用不做gpg校验,

list: 列表,列出yum仓库中所有RPM软件包

  支持glob(文件名通配符)

  all:显示所有,默认操作

  available:可用的,仓库中有但尚未安装的

  installed: 已经安装的

  updates: 可用的升级

clean: 清理缓存
  [ packages(清理rpm包) | headers(清理头部信息) | metadata(清理元数据文件) | dbcache(清理库缓存) | all(清理所有) ]

repolist: 显示repo列表及其简要信息

  all:显示所有repo列表

  enabled: 默认,显示可用的repo列表

  disabled:显示不可用的repo列表

install: 安装,可以使用glob(文件名通配)

yum install PACKAGE_NAME

update: 升级

update_to: 升级为指定版本

remove|erase:卸载

提示:卸载软件包会将软件包依赖的软件也会卸载

info: 查询指定包的说明信息;

provides| whatprovides: 查看指定的文件或特性是由哪个包安装生成的;

groupinfo:查看组信息

grouplist:列出组

groupinstall:安装组

groupremove:删除组

groupupdate:组升级

search:根据字符串查找软件包

shell:和shell交互

reinstall:重启安装

downgrade:降级

localinstall:本地安装RPM包,但这个软件包依赖于yum仓库中的软件包,必须要指rpm安装文件

光盘做yum源:

/media/cdrom/{Server,VT,Cluster,ClusterStorage}

如何创建yum仓库:

createrepo: yum仓库软件包

  -g:指定comps-rhel5-vt.xml文件,可以识别组;

http://172.16.0.1/yum/{Server,VT }

[root@Smoke /]# mkdir /media/cdrom(创建cdrom目录)
[root@Smoke /]# mount -r /dev/cdrom /media/cdrom/(-r 只读方式挂载/dev/cdrom到/media/cdrom目录)
[root@Smoke /]# cd /media/cdrom/(切换到cdrom目录)
[root@Smoke cdrom]# cd repodata/(切换到repodata元数据目录)
[root@Smoke repodata]# ls(查看当前目录文件及子目录)
0dafccfdbf892f02acca8267ade4bdcee7280a682e65dc7e29145f3341fd7a8c-primary.sqlite.bz2
495d3964f864fbab835ea1afb8a5272352cd12ded13d607205109fefaddd0ab6-primary.xml.gz
594d4bb4a79ed01d66635adbcf76c45ca4a85b30fc3e3c3c28316e64f0a83f21-filelists.sqlite.bz2
5af8199bd0ffb441c34ef946582d0d06c1ad770755e631690771e0bceb0ad222-other.xml.gz
6ac72f497df511cc2dc584eaa59779884fc572c1618e7c62dbd631ab8babf53d-filelists.xml.gz
b4e0b9342ef85d3059ff095fa7f140f654c2cb492837de689a58c581207d9632-c6-x86_64-comps.xml
ca525c73086186bfcb81ad9edd45796026dac7e4e50524e0f2daf901532aaf66-c6-x86_64-comps.xml.gz
fdd542ef36b0cde54ee0521fae90b98911db06483163aa1c049995b6d109349b-other.sqlite.bz2[root@Smoke cdrom]# cat /etc/yum.conf(查看yum.conf文件)
[main]
cachedir=/var/cache/yum/$basearch/$releasever(缓存路径)
keepcache=0(是否保存缓存中的文件)
debuglevel=2(调试级别)
logfile=/var/log/yum.log(日志文件)
exactarch=1(安装RPM包,从yum仓库中获得的版本必须要跟系统上严格匹配)
obsoletes=1(允许更新陈旧的RPM包)
gpgcheck=1(要不要检测完整性)
plugins=1(是否检查GPG,是否允许使用插件)
installonly_limit=5(允许保留多少个内核包)
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
[root@Smoke cdrom]# cd /etc/yum.repos.d/(切换到/etc/yum.repos.d目录)
CentOS-Base.repo      CentOS-Media.repo     CentOS-Vault.repo
CentOS-Debuginfo.repo  
[root@Smoke yum.repos.d]# rm -f server.repo*(-f 强制删除server.repo开头,任何字符结尾的文件)
[root@Smoke yum.repos.d]# cat CentOS-Debuginfo.rep(查看Debuginfo.rep文件内容)
[debug]
name=CentOS-6 - Debuginfo
baseurl=http://debuginfo.centos.org/6/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-6
enabled=0
[root@Smoke ~]# yum clean(清理yum缓存)
[root@Smoke ~]# yum list | less(显示yum仓库所有rpm软件包)
yum-updateonboot.noarch(平台)                     1.1.30-17.el6_5(版本和release号)                     updates(这个rpm包在那个仓库当中,如果安
装显示installed,否则显示对应仓库ID)                                
zlib.i686                                   1.2.3-29.el6                         base                                    
zlib-devel.i686                             1.2.3-29.el6                         base                                    
zlib-static.x86_64                          1.2.3-29.el6                         base                                    
zsh-html.x86_64                             4.3.10-7.el6                         base    
[root@Smoke ~]# cd /etc/yum.repos.d/(切换到/etc/yum.repos.d目录)
[root@Smoke yum.repos.d]# vim server.repo(编辑yum仓库配置文件)
[Base](repo ID)
name=RHEL 5 Server(描述名字)
baseurl=ftp://172.16.0.1/pub/Server(路径)
enabled=1(是否使用此yum仓库)
gpgcheck=0(是否通过gpg检测软件包合法性)
[root@Smoke yum.repos.d]# yum list | less(显示yum仓库所有rpm软件包)
zlib.i686                                   1.2.3-29.el6                         base                                    
zlib-devel.i686                             1.2.3-29.el6                         base                                    
zlib-static.x86_64                          1.2.3-29.el6                         base                                    
zsh-html.x86_64                             4.3.10-7.el6                         base
[root@Smoke yum.repos.d]# vim server.repo(编辑yum仓库配置文件)
[Base]
name=RHEL 5 Server
baseurl=ftp://172.16.0.1/pub/Server
enabled=1
gpgcheck=0
[VT]
name=RHEL 5 VT
baseurl=ftp://172.16.0.1/pub/VT
enabled=1
gpgcheck=0
[root@Smoke yum.repos.d]# yum clean(清理yum缓存)
[root@Smoke yum.repos.d]# yum list | less(显示yum仓库所有rpm软件包)
zlib.i686                                   1.2.3-29.el6                         base                                    
zlib-devel.i686                             1.2.3-29.el6                         base                                    
zlib-static.x86_64                          1.2.3-29.el6                         base                                    
zsh-html.x86_64                             4.3.10-7.el6                         base
[root@Smoke yum.repos.d]# yum repolist(显示repo列表及其简要信息)
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
repo id                                              repo name                                                     status
c6-media                                             CentOS-6 - Media                                              6,367
repolist: 6,367
[root@Smoke yum.repos.d]# yum repolist disable(显示禁用的repo列表及其简要信息)
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
repolist: 0
[root@Smoke yum.repos.d]# yum list all zsh*(显示yum仓库zsh开头任何字符结尾的RPM软件)
zsh.x86_64                                     4.3.10-7.el6                                installed
Available Packages
zsh-html.x86_64                                4.3.10-7.el6                                c6-media
[root@Smoke yum.repos.d]# yum list all php*(列出yum仓库中php开头任意字符结束的软件包)
php.x86_64                                         5.3.3-27.el6_5                           @updates
php-cli.x86_64                                     5.3.3-27.el6_5                           @updates
php-common.x86_64                                  5.3.3-27.el6_5                           @updates
php-mysql.x86_64                                   5.3.3-27.el6_5                           @updates
php-pdo.x86_64                                     5.3.3-27.el6_5                           @update
[root@Smoke yum.repos.d]# yum install php-mysql(安装php-mysql软件包)
[root@Smoke ~]# yum install php*(安装php开头任何字符结尾的所有软件包)
[root@Smoke ~]# yum remove php-pda(卸载php-pda软件包)
[root@Smoke ~]# yum info zsh(查看zsh软件说明信息)
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.pubyun.com
* extras: mirrors.pubyun.com
* updates: centosx4.centos.org
Installed Packages
Name        : zsh
Arch        : x86_64
Version     : 4.3.10
Release     : 7.el6
Size        : 4.8 M
Repo        : installed
Summary     : A powerful interactive shell
URL         : http://zsh.sunsite.dk/
License     : BSD
Description : The zsh shell is a command interpreter usable as an interactive login
           : shell and as a shell script command processor.  Zsh resembles the ksh
           : shell (the Korn shell), but includes many enhancements.  Zsh supports
           : command line editing, built-in spelling correction, programmable
           : command completion, shell functions (with autoloading), a history
           : mechanism, and more.
[root@Smoke ~]# yum provides /etc/inittab(查看inittab是由哪个包安装生成的)
initscripts-9.03.40-2.el6.centos.2.x86_64 : The inittab file and the /etc/init.d scripts
Repo        : updates
Matched from:
Filename    : /etc/inittab
initscripts-9.03.40-2.el6.centos.3.x86_64 : The inittab file and the /etc/init.d scripts
Repo        : updates
Matched from:
Filename    : /etc/inittab
initscripts-9.03.40-2.el6.centos.x86_64 : The inittab file and the /etc/init.d scripts
Repo        : base
Matched from:
Filename    : /etc/inittab
initscripts-9.03.40-2.el6.centos.1.x86_64 : The inittab file and the /etc/init.d scripts
Repo        : updates
Matched from:
Filename    : /etc/inittab
initscripts-9.03.40-2.el6.centos.1.x86_64 : The inittab file and the /etc/init.d scripts
Repo        : installed
Matched from:
Other       : Provides-match: /etc/inittab
[root@Smoke ~]# yum grouplist(列出当前系统上所有组)
Installed Groups:(已安装的组)
  Additional Development
  Base
  Compatibility libraries
  Console internet tools
  Debugging Tools
  Desktop
  Desktop Debugging and Performance Tools
  Desktop Platform
  Development tools
  Dial-up Networking Support
  Directory Client
  E-mail server
  Fonts
  General Purpose Desktop
  Graphical Administration Tools
  Hardware monitoring utilities
  Input Methods
  Internet Applications
  Internet Browser
  Java Platform
  Legacy UNIX compatibility
  Legacy X Window System compatibility
  MySQL Database client
  MySQL Database server
  NFS file server
  Network Infrastructure Server
  Network file system client
  Networking Tools
  Office Suite and Productivity
  PHP Support
  Performance Tools
  Perl Support
  Print Server
  Printing client
  Ruby Support
  SNMP Support
  Security Tools
  Server Platform
  System administration tools
  Web Server
  X Window System
Installed Language Groups:(已安装的语言组)
  Arabic Support [ar]
  Armenian Support [hy]
  Assamese Support [as]
  Bengali Support [bn]
  Bhutanese Support [dz]
  Chinese Support [zh]
  Ethiopic Support [am]
  Georgian Support [ka]
  Gujarati Support [gu]
  Hebrew Support [he]
  Hindi Support [hi]
  Inuktitut Support [iu]
  Japanese Support [ja]
  Kannada Support [kn]
  Khmer Support [km]
  Konkani Support [kok]
  Korean Support [ko]
  Kurdish Support [ku]
  Lao Support [lo]
  Maithili Support [mai]
  Malayalam Support [ml]
  Marathi Support [mr]
  Myanmar (Burmese) Support [my]
  Oriya Support [or]
  Punjabi Support [pa]
  Sinhala Support [si]
  Tajik Support [tg]
  Tamil Support [ta]
  Telugu Support [te]
  Thai Support [th]
  Urdu Support [ur]
  Venda Support [ve]
Available Groups:(可安装的组)
  Backup Client
  Backup Server
  CIFS file server
  Client management tools
  Desktop Platform Development
  Directory Server
  Eclipse
  Emacs
  FCoE Storage Client
  FTP server
  Graphics Creation Tools
  High Availability
  High Availability Management
  Identity Management Server
  Infiniband Support
  KDE Desktop
  Large Systems Performance
  Load Balancer
  Mainframe Access
  Messaging Client Support
  Network Storage Server
  PostgreSQL Database client
  PostgreSQL Database server
  Remote Desktop Clients
  Resilient Storage
  Scalable Filesystems
  Scientific support
  Server Platform Development
  Smart card support
  Storage Availability Tools
  System Management
  TeX support
  Technical Writing
  TurboGears application framework
  Virtualization
  Virtualization Client
  Virtualization Platform
  Virtualization Tools
  Web Servlet Engine
  Web-Based Enterprise Management
  iSCSI Storage Client
Available Language Groups:(可安装的语言组)
  Afrikaans Support [af]
  Albanian Support [sq]
  Amazigh Support [ber]
  Azerbaijani Support [az]
  Basque Support [eu]
  Belarusian Support [be]
  Brazilian Portuguese Support [pt_BR]
  Breton Support [br]
  Bulgarian Support [bg]
  Catalan Support [ca]
  Chhattisgarhi Support [hne]
  Chichewa Support [ny]
  Coptic Support [cop]
  Croatian Support [hr]
  Czech Support [cs]
  Danish Support [da]
  Dutch Support [nl]
  English (UK) Support [en_GB]
  Esperanto Support [eo]
  Estonian Support [et]
  Faroese Support [fo]
  Fijian Support [fj]
  Filipino Support [fil]
  Finnish Support [fi]
  French Support [fr]
  Frisian Support [fy]
  Friulian Support [fur]
  Gaelic Support [gd]
  Galician Support [gl]
  German Support [de]
  Greek Support [el]
  Hiligaynon Support [hil]
  Hungarian Support [hu]
  Icelandic Support [is]
  Indonesian Support [id]
  Interlingua Support [ia]
  Irish Support [ga]
  Italian Support [it]
  Kashmiri Support [ks]
  Kashubian Support [csb]
  Kazakh Support [kk]
  Kinyarwanda Support [rw]
  Latin Support [la]
  Latvian Support [lv]
  Lithuanian Support [lt]
  Low Saxon Support [nds]
  Luxembourgish Support [lb]
  Macedonian Support [mk]
  Malagasy Support [mg]
  Malay Support [ms]
  Maltese Support [mt]
  Manx Support [gv]
  Maori Support [mi]
  Mongolian Support [mn]
  Nepali Support [ne]
  Northern Sotho Support [nso]
  Norwegian Support [nb]
  Occitan Support [oc]
  Persian Support [fa]
  Polish Support [pl]
  Portuguese Support [pt]
  Romanian Support [ro]
  Russian Support [ru]
  Sanskrit Support [sa]
  Sardinian Support [sc]
  Serbian Support [sr]
  Sindhi Support [sd]
  Slovak Support [sk]
  Slovenian Support [sl]
  Somali Support [so]
  Southern Ndebele Support [nr]
  Southern Sotho Support [st]
  Spanish Support [es]
  Swahili Support [sw]
  Swati Support [ss]
  Swedish Support [sv]
  Tagalog Support [tl]
  Tetum Support [tet]
  Tibetan Support [bo]
  Tsonga Support [ts]
  Tswana Support [tn]
  Turkish Support [tr]
  Turkmen Support [tk]
  Ukrainian Support [uk]
  Upper Sorbian Support [hsb]
  Uzbek Support [uz]
  Vietnamese Support [vi]
  Walloon Support [wa]
  Welsh Support [cy]
  Xhosa Support [xh]
  Zulu Support [zu]
Done
[root@Smoke ~]# yum  groupinfo "Development tools"(查看development tools组信息)
Group: Development tools(组名称)
Description: A basic development environment.(描述信息)
Mandatory Packages:(必须安装的包)
  autoconf
  automake
  binutils
  bison
  flex
  gcc
  gcc-c++
  gettext
  libtool
  make
  patch
  pkgconfig
  redhat-rpm-config
  rpm-build
Default Packages:(默认安装的包)
  byacc
  cscope
  ctags
  cvs
  diffstat
  doxygen
  elfutils
  gcc-gfortran
  git
  indent
  intltool
  patchutils
  rcs
  subversion
  swig
  systemtap
Optional Packages:(可选安装包)
  ElectricFence
  ant
  babel
  bzr
  chrpath
  cmake
  compat-gcc-34
  compat-gcc-34-c++
  compat-gcc-34-g77
  cvs-inetd
  dejagnu
  expect
  gcc-gnat
  gcc-java
  gcc-objc
  gcc-objc++
  imake
  jpackage-utils
  kdewebdev
  ksc
  libstdc++-docs
  mercurial
  mod_dav_svn
  nasm
  perltidy
  python-docs
  rpmdevtools
  rpmlint
  systemtap-sdt-devel
  systemtap-server
[root@Smoke ~]# yum -y groupinstall "Development tools" "Development Libraries"(安装组development toos开发组工具和development libraries开发组
库,-y所有提问回答yes)
[root@Smoke ~]# lftps(连接ftp服务器)
cd ok, cwd=/pub
lftp 172.16.0.1:/pub> cd Server/(切换到Server目录)
lftp 172.16.0.1:/pub/Server> get php53-mysql-5.3.3-5.el5.i386.rpm(下载php53-mysql软件包)
lftp 172.16.0.1:/pub/Server> byte(退出)
[root@Smoke ~]# yum localinstall php-mysql-5.3.3-26.el6.x86_64.rpm(本地安装RPM包,但这个软件包依赖于yum仓库中的软件包,必须要指rpm安装文件)
[root@Smoke ~]# cd /etc/yum.repos.d/(切换到/etc/yum.repos.d目录)
[root@Smoke yum.repos.d]# vim cdrom.repo(创建yum源文件)
[Base]
name=RHEL5 CDROM Server
bashurl=file:///media/cdrom
enabled=1
gpgcheck=0
[root@Smoke yum.repos.d]# yum list all(列出所有repo中的rpm软件包)
[root@Smoke yum.repos.d]# yum install createrepo(安装yum仓库创建软件包)
[root@Smoke ~]# mkdir -pv /yum/VT(-pv 递归创建/yum/VT目录,并显示创建过程)
[root@Smoke ~]# cp /media/cdrom/Packages/*.rpm /yum/VT/(拷贝光盘中的rpm软件包到/yum/VT目录)
[root@Smoke VT]# cd /etc/yum.repos.d/(编辑yum源文件)
[Base]
name=RHEL5 CDROM Server
bashurl=file:///media/cdrom
enabled=1
gpgcheck=0
[VT]
name=VT
baseurl=file:///yum/VT
enabled=1
gpgcheck=0
[root@Smoke yum.repos.d]# yum repolist(查看可用repo列表及其简要信息)
repo id                                                   repo name                                                            status
Base                                                      RHEL5 CDROM Server                                                   0
VT                                                        VT                                                                   0
base                                                      CentOS-6 - Base                                                      0
extras                                                    CentOS-6 - Extras                                                    0
updates                                                   CentOS-6 - Updates                                                   0
repolist: 0
[root@Smoke yum.repos.d]# createrepo /yum/VT/(创建yum仓库元数据)
Spawning worker 0 with 3995 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@Smoke ~]# yum clean all(清理yum缓存)
[root@Smoke ~]# yum repolist(查看可用repo列表及其简要信息)
提示:通过这种方式创建的repo没有组的定义,如果要使用可以复制光盘中的comps-rhel5-vt.xml文件
[root@Smoke yum.repos.d]# cd /media/cdrom/repodata/(切换
0dafccfdbf892f02acca8267ade4bdcee7280a682e65dc7e29145f3341fd7a8c-primary.sqlite.bz2
495d3964f864fbab835ea1afb8a5272352cd12ded13d607205109fefaddd0ab6-primary.xml.gz
594d4bb4a79ed01d66635adbcf76c45ca4a85b30fc3e3c3c28316e64f0a83f21-filelists.sqlite.bz2
5af8199bd0ffb441c34ef946582d0d06c1ad770755e631690771e0bceb0ad222-other.xml.gz
6ac72f497df511cc2dc584eaa59779884fc572c1618e7c62dbd631ab8babf53d-filelists.xml.gz
b4e0b9342ef85d3059ff095fa7f140f654c2cb492837de689a58c581207d9632-c6-x86_64-comps.xml(红帽组的定义)
ca525c73086186bfcb81ad9edd45796026dac7e4e50524e0f2daf901532aaf66-c6-x86_64-comps.xml.gz
fdd542ef36b0cde54ee0521fae90b98911db06483163aa1c049995b6d109349b-other.sqlite.bz2
repomd.xml
TRANS.TBL
[root@Smoke repodata]# cp b4e0b9342ef85d3059ff095fa7f140f654c2cb492837de689a58c581207d9632-c6-x86_64-comps.xml /root(复制comps.xml文件到
/root目录)
[root@Smoke repodata]# createrepo -g /root/b4e0b9342ef85d3059ff095fa7f140f654c2cb492837de689a58c581207d9632-c6-x86_64-comps.xml /yum/VT
(-g 重新对/yum/VT创建repo元数据文件)

RPM安装:

  二进制格式:

  源程序-->编译-->二进制格式

    有些特性是编译选定的,如果编译未选定此特性,将无法使用;

    rpm包的版本会落后于源码包,甚至落后很多;bind-9.8.7, bind-9.7.2

定制:手动编译安装

编译环境,开发环境

开发库,开发工具

Linux: C,

GNU: C

C,C++:

gcc: GNU C Complier, C

g++:

make: 项目管理工具,

  makefile: 定义了make(gcc,g++)按何种次序去编译这些源程序文件中的源程序

automake, --> makefile.in --> makefile

autoconf, --> configure

100个可选择特性,

make install(安装)

编译安装的三步骤:

前提:准备开发环境(编译环境)

安装"Development Tools"和"Development Libraries"

RHEL 6

安装"Development Tools"和"Compatibility libraries"(兼容库)

# tar

# cd

# ./configure

--help(获取脚本使用格式)

--prefix=/path/to/somewhere(指定软件安装路径)

--sysconfdir=/PATH/TO/CONFFILE_PATH(指定配置路径及名称)

功能:1、让用户选定编译特性;2、检查编译环境;

# make

# make install

# tar xf tengine-1.4.2.tar.gz

# cd tegnine-1.4.2

# ./configure --prefix=/usr/local/tengine --conf-path=/etc/tengine/tengine.conf

# make

# make install

# /usr/local/tengine/sbin/nginx

1、修改PATH环境变量,以能够识别此程序的二进制文件路径;

  修改/etc/profile文件

  在/etc/profile.d/目录建立一个以.sh为名称后缀的文件,在里面定义export PATH=$PATH:/path/to/somewhere

  source /etc/profile:让系统重读profile文件

2、默认情况下,系统搜索库文件的路径/lib, /usr/lib; 要增添额外搜寻路径:

  在/etc/ld.so.conf.d/中创建以.conf为后缀名的文件,而后把要增添的路径直接写至此文件中;

  # ldconfig 通知系统重新搜寻库文件

    -v: 显示重新搜寻库的过程

3、头文件:输出给系统

  默认:/usr/include

  增添头文件搜寻路径,使用链接进行:

    /usr/local/tengine/include/ /usr/include/

    两种方式:

    ln -s /usr/local/tengine/include/* /usr/include/ 或

    ln -s /usr/local/tengine/include /usr/include/tengine

4、man文件路径:安装在--prefix指定的目录下的man目录;/usr/share/man

  1、man -M /PATH/TO/MAN_DIR COMMAND

  2、在/etc/man.config中添加一条MANPATH

netstat命令:

  -r: 显示路由表

  -n: 以数字方式显示


  -t: 建立的tcp连接

  -u: 显示udp连接

  -l: 显示监听状态的连接

  -p: 显示监听指定的套接字的进程的进程号及进程名

[root@Smoke ~]# lftps(连接ftp服务器)
cd ok, cwd=/pub
lftp 172.16.0.1:/pub> cd Sources/
lftp 172.16.0.1:/pub/Sources/Tengine> get tengine-1.4.2.tar.gz(下载tengine源码包)
1185902 bytes transferred
lftp 172.16.0.1:/pub/Sources/Tengine> bye(退出)
[root@Smoke ~]# tar xf tengine-v1.4.6.tar.gz(-x展开归档,-f跟归档的文件)
[root@Smoke ~]# cd tengine-1.4.6/(切换到tengine-1.4.6目录)
[root@Smoke tengine-1.4.6]# ls(查看当前目录文件及子目录)
AUTHORS.te  CHANGES     CHANGES.ru  conf       contrib  html     man     README.markdown  tests
auto        CHANGES.cn  CHANGES.te  configure  docs     LICENSE  README  src              THANKS.te
[root@Smoke tengine-1.4.6]# ./configure --help(查看支持那些选项功能)
--prefix=PATH                      set installation prefix(指定安装路径,不指定可能是/usr/local,因为是第三方软件)
--conf-path=PATH                   set nginx.conf pathname(指定配置文件路径)
--user=USER                        set non-privileged user for worker processes(关联到那个用户)
--group=GROUP                      set non-privileged group for worker processes(关联到那个组)
--with-file-aio                    enable file AIO support(启用AIO支持)
--without-syslog                   disable syslog logging(禁用系统日志)
[root@Smoke tengine-1.4.6]# ./configure --prefix=/usr/local/tengine --conf-path=/etc/tengine/tengine.conf(配置:--prefix二进制文件安装路
径,--conf-path配置文件)
./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(错误:没有安装PCRE,可以使用--without-http_rewrite_module禁
用或安装PCRE)
statically from the source with nginx by using --with-pcre=<path> option.
[root@Smoke tengine-1.4.6]# yum install pcre-devel(安装pcre)
提示:一般都依赖于其他软件的devel包
[root@Smoke tengine-1.4.6]#  ./configure --prefix=/usr/local/tengine --conf-path=/etc/tengine/tengine.conf(配置:--prefix二进制文件安装路径
,--conf-path指定配置文件)
Configuration summary
 + using system PCRE library
 + using system OpenSSL library
 + md5: using OpenSSL library
 + sha1: using OpenSSL library
 + using system zlib library
 + jemalloc library is disabled
 nginx path prefix: "/usr/local/tengine"(二进制程序)
 nginx binary file: "/usr/local/tengine/sbin/nginx"
 nginx configuration prefix: "/etc/tengine"
 nginx configuration file: "/etc/tengine/tengine.conf"(配置文件)
 nginx pid file: "/usr/local/tengine/logs/nginx.pid"
 nginx error log file: "/usr/local/tengine/logs/error.log"
 nginx http access log file: "/usr/local/tengine/logs/access.log"
 nginx http client request body temporary files: "client_body_temp"
 nginx dso module path: "/usr/local/tengine/modules/"
 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@Smoke tengine-1.4.6]# make(编译)
[root@Smoke tengine-1.4.6]# make install(安装)
[root@Smoke tengine-1.4.6]# cd /usr/local/tengine/(切换到/usr/local/tengine目录)
[root@Smoke tengine]# cd sbin/(切换到sbin目录)
[root@Smoke sbin]# ls(查看当前目录文件及子目录)
dso_tool  nginx
[root@Smoke sbin]# nginx(启动程序,不能直接运行)
-bash: nginx: command not found
[root@Smoke sbin]# pwd(显示当前工作目录)
/usr/local/tengine/sbin
提示:nginx不在path环境变量路径,要么指定全路径,要么加到path路径里面;
[root@Smoke sbin]# vim /etc/profile(编辑/etc/profile文件)
PATH=$PATH:/usr/local/tengine/sbin
[root@Smoke sbin]# source /etc/profile(让系统重读profile文件)
提示:或者通过重新登录让profile定义的路径生效
[root@Smoke sbin]# echo $PATH(显示变量PATH,有/usr/local/tenine/sbin目录)
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/tengine/sbin
[root@Smoke sbin]# nginx(启动程序)
[root@Smoke sbin]# netstat -tnlp | grep nginx(显示系统服务,-t代表tcp,-n数字显示,-l监听端口,-p显示程序名称)
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      12981/nginx  
测试:通过winodws的ie浏览器输入172.16.100.1显示nginx的页面;
Welcome to tengine!
If you see this page, the tengine web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to tengine.taobao.org.
Thank you for using tengine.
[root@Smoke sbin]# cd /usr/local/tengine/(切换到/usr/local/tengine目录)
[root@Smoke tengine]# cd html/(切换到html目录)
[root@Smoke html]# ls(查看当前目录文件及子目录)
50x.html  index.html(主页)
[root@Smoke html]# vim index.html(编辑index.html文件)
<title>Welcome to tengine! I am Xman</title>
测试:通过winodws的ie浏览器输入172.16.100.1显示nginx的页面;
Welcome to tengine! I am Xman
If you see this page, the tengine web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to tengine.taobao.org.
Thank you for using tengine.
[root@Smoke ld.so.conf.d]# ls /usr/share/man/(查看man文档目录)
bg  da  en  fr  id  ko     man1p  man2x  man3x  man5   man6x  man8   man9x  overrides  pt_BR  sk  tr         zh_CN
ca  de  es  hr  it  man0p  man1x  man3   man4   man5x  man7   man8x  mann   pl         ro     sl  uk         zh_TW
cs  el  fi  hu  ja  man1   man2   man3p  man4x  man6   man7x  man9   nl     pt         ru     sv  yntax off
[root@Smoke ld.so.conf.d]# vim /etc/man.config(编辑man配置文件)
MANPATH /usr/man(操作系统找man路径)
MANPATH /usr/share/man
MANPATH /usr/local/man
MANPATH /usr/local/share/man
MANPATH /usr/X11R6/man
[root@Smoke ~]# lftps(连接ftp服务器)
cd ok, cwd=/pub
lftp 172.16.0.1:/pub> cd Sources/LAMP/(切换到/Sources/LAMP目录)
lftp 172.16.0.1:/pub/Sources/LAMP> get httpd-2.2.16.tar.bz2(下载httpd源码包)
477545 bytes transferred
lftp 172.16.0.1:/pub/Sources/LAMP> bye(退出)
[root@Smoke ~]# tar xf httpd-2.4.10.tar.bz2(-x 展开归档,-f跟压缩文件)
[root@Smoke ~]# cd httpd-2.4.10(切换到httpd-2.4.10目录)
[root@Smoke httpd-2.4.10]# ./configure --help(查看httpd支持那些功能选项)
--prefix=PREFIX         install architecture-independent files in PREFIX [/usr/local/apache2](指定安装路径)
--sysconfdir=DIR        read-only single-machine data [PREFIX/etc](指定配置文件路径)
[root@Smoke httpd-2.4.10]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd/(配置httpd功能选项)
[root@Smoke httpd-2.4.10]# make(编译)
[root@Smoke httpd-2.4.10]# netstat -r(-r 查看本地路由表)
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.10.10.254    *               255.255.255.255 UH        0 0          0 eth1
172.16.100.0    *               255.255.255.0   U         0 0          0 eth0
192.168.226.0   *               255.255.255.0   U         0 0          0 eth1
192.168.10.0    10.10.10.254    255.255.255.0   UG        0 0          0 eth1
default         192.168.226.2   0.0.0.0         UG        0 0          0 eth1
[root@Smoke httpd-2.4.10]# netstat -rn(-r 查看本地路由表,-n以数字方式显示)
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
10.10.10.254    0.0.0.0         255.255.255.255 UH        0 0          0 eth1
172.16.100.0    0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.226.0   0.0.0.0         255.255.255.0   U         0 0          0 eth1
192.168.10.0    10.10.10.254    255.255.255.0   UG        0 0          0 eth1
0.0.0.0         192.168.226.2   0.0.0.0         UG        0 0          0 eth1                        
[root@Smoke httpd-2.4.10]# netstat -t(-t 显示当前主机处于连接状态的tcp连接)
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 www.smoke.com:ssh           172.16.100.254:8393         ESTABLISHED
tcp        0     52 www.smoke.com:ssh           172.16.100.254:dsmeter_iatc ESTABLISHED
tcp        0    260 www.smoke.com:ssh           172.16.100.254:globecast-id ESTABLISHED
[root@Smoke httpd-2.4.10]# netstat -u(-u 显示当前主机处于连接状态的udp连接)
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State  
提示:UDP显示不出来,由于UDP是无连接的;
[root@Smoke httpd-2.4.10]# netstat -tl(-tl 显示监听状态的tcp连接)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 *:rquotad                   *:*                         LISTEN      
tcp        0      0 *:sunrpc                    *:*                         LISTEN      
tcp        0      0 *:http                      *:*                         LISTEN      
tcp        0      0 *:47509                     *:*                         LISTEN      
tcp        0      0 *:ssh                       *:*                         LISTEN      
tcp        0      0 localhost:ipp               *:*                         LISTEN      
tcp        0      0 localhost:smtp              *:*                         LISTEN      
tcp        0      0 localhost:x11-ssh-offset    *:*                         LISTEN      
tcp        0      0 localhost:6011              *:*                         LISTEN      
tcp        0      0 localhost:6012              *:*                         LISTEN      
[root@Smoke httpd-2.4.10]# netstat -ul(-ul 显示监听状态的udp连接)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
udp        0      0 *:rquotad                   *:*                                    
udp        0      0 *:sunrpc                    *:*                                    
udp        0      0 *:ipp                       *:*                                    
udp        0      0 *:892                       *:*                                    
udp        0      0 *:filenet-rpc               *:*                                    
udp        0      0 *:nfs                       *:*                                                                      
[root@Smoke httpd-2.4.10]# netstat -tulnp(-ulnp 显示监听状态的tcp和udp并显示监听指定的套接字的进程的进程号及进程名)
tcp        0      0 ::1:6012                    :::*                        LISTEN      17516/sshd          
tcp        0      0 :::892                      :::*                        LISTEN      2122/rpc.mountd    
tcp        0      0 :::2049                     :::*                        LISTEN      -                  
tcp        0      0 :::5666                     :::*                        LISTEN      2622/nrpe          
tcp        0      0 :::32803                    :::*                        LISTEN      -                  
udp        0      0 0.0.0.0:875                 0.0.0.0:*                               2118/rpc.rquotad    
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               1834/rpcbind        
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               1923/cupsd          
udp        0      0 0.0.0.0:892                 0.0.0.0:*                               2122/rpc.mountd                                    
[root@Smoke httpd-2.4.10]# make install(安装)
[root@Smoke ~]# cd /usr/local/apache/(切换到/usr/local/apache目录)
[root@Smoke apache]# ls(查看当前目录文件及子目录)
bin  build  cgi-bin  error  htdocs  icons  include(头文件)  logs  man(帮助文档)  manual  modules
[root@Smoke apache]# ls bin/(查看apache的二进制程序)
ab         apxs      dbmmanage  envvars-std  htcacheclean  htdigest  httpd      logresolve
apachectl  checkgid  envvars    fcgistarter  htdbm         htpasswd  httxt2dbm  rotatelogs
[root@Smoke apache]# htpasswd(执行apahce的htpasswd二进制程序,无法执行因为没有在路径环境变量)
-bash: htpasswd: command not found
[root@Smoke apache]# vim /etc/profile.d/httpd.sh(编辑/etc/profile.d/httpd.sh文件)
export PATH=$PATH:/usr/local/apache/bin
[root@Smoke apache]# source /etc/profile(让系统重读profile文件或者重新连接)
[root@Smoke apache]# echo $PATH(显示环境变量,apache的二进制程序路径存在于PATH变量中)
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/tengine/sbin:/root/bin:/usr/local/tengine
/sbin:/usr/local/apache/bin
[root@Smoke apache]# htpasswd(可以正常执行htpasswd命令)
Usage:
       htpasswd [-cimBdpsDv] [-C cost] passwordfile username
       htpasswd -b[cmBdpsDv] [-C cost] passwordfile username password
       htpasswd -n[imBdps] [-C cost] username
       htpasswd -nb[mBdps] [-C cost] username password
-c  Create a new file.
-n  Don't update file; display results on stdout.
-b  Use the password from the command line rather than prompting for it.
-i  Read password from stdin without verification (for script usage).
-m  Force MD5 encryption of the password (default).
-B  Force bcrypt encryption of the password (very secure).
-C  Set the computing time used for the bcrypt algorithm
    (higher is more secure but slower, default: 5, valid: 4 to 31).
-d  Force CRYPT encryption of the password (8 chars max, insecure).
-s  Force SHA encryption of the password (insecure).
-p  Do not encrypt the password (plaintext, insecure).
-D  Delete the specified user.
-v  Verify password for the specified user.
[root@Smoke apache]# ldconfig -v(-v 显示系统上所有保留的库文件)
ldconfig: /etc/ld.so.conf.d/kernel-2.6.32-431.el6.x86_64.conf:6: duplicate hwcap 1 nosegneg
/usr/lib64/mysql:
       libmysqlclient.so.16 -> libmysqlclient.so.16.0.0
       libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0
/usr/lib64/qt-3.3/lib:
       libqui.so.1 -> libqui.so.1.0.0
       libqt-mt.so.3 -> libqt-mt.so.3.3.8
/usr/lib/vmware-tools/lib32/libvmGuestLib.so:
       libvmGuestLib.so -> libvmGuestLib.so
[root@Smoke apache]# ldconfig -v | grep apr(显示系统上是否保留apr库文件)
ldconfig: /etc/ld.so.conf.d/kernel-2.6.32-431.el6.x86_64.conf:6: duplicate hwcap 1 nosegneg
       libgstdataprotocol-0.10.so.0 -> libgstdataprotocol-0.10.so.0.25.0
[root@Smoke apache]# vim /etc/ld.so.conf.d/httpd.conf(编辑库文件配置文件)
/usr/local/apache/lib
[root@Smoke apache]# ldconfig -v | grep apr(显示系统上是否保留apr库文件)
ldconfig: /etc/ld.so.conf.d/kernel-2.6.32-431.el6.x86_64.conf:6: duplicate hwcap 1 nosegneg
       libgstdataprotocol-0.10.so.0 -> libgstdataprotocol-0.10.so.0.25.0
[root@Smoke apache]# ls include/(查看apache的头文件)
apache_noprobes.h   ap_mmn.h       cache_common.h     http_protocol.h  mod_dbd.h         mod_ssl.h       unixd.h         util_md5.h
ap_compat.h         ap_mpm.h       heartbeat.h        http_request.h   mod_include.h     mod_status.h    util_cfgtree.h  util_mutex.h
ap_config_auto.h    ap_provider.h  http_config.h      http_vhost.h     mod_log_config.h  mod_unixd.h     util_charset.h  util_script.h
ap_config.h         ap_regex.h     http_connection.h  mod_auth.h       mod_proxy.h       mod_watchdog.h  util_cookies.h  util_time.h
ap_config_layout.h  ap_regkey.h    http_core.h        mod_cache.h      mod_request.h     mod_xml2enc.h   util_ebcdic.h   util_varbuf.h
ap_expr.h           ap_release.h   httpd.h            mod_cgi.h        mod_rewrite.h     mpm_common.h    util_fcgi.h     util_xml.h
ap_hooks.h          ap_slotmem.h   http_log.h         mod_core.h       mod_session.h     os.h            util_filter.h
ap_listen.h         ap_socache.h   http_main.h        mod_dav.h        mod_so.h          scoreboard.h    util_ldap.h
[root@Smoke apache]# ln -sv /usr/local/apache/include/ /usr/include/httpd(-sv 将apache的头文件连接到/usr/include目录下改变目录名为httpd)
`/usr/include/httpd' -> `/usr/local/apache/include/'[root@Smoke apache]# man htpasswd(查看htpasswd的man文档,找不到)
No manual entry for htpasswd
[root@Smoke apache]# ls man(查看apache的man目录)
man1  man8
[root@Smoke apache]# ls man/man1/(在apache的man/man1目录下有htpasswd.1的man文档)
ab.1  apxs.1  dbmmanage.1  htdbm.1  htdigest.1  htpasswd.1  httxt2dbm.1  logresolve.1
[root@Smoke apache]# man -M /usr/local/apache/man htpasswd(-M 查看htpasswd的man帮会组文档)
[root@Smoke apache]# vim /etc/man.config(编辑man.conf配置文件)
MANPATH /usr/local/apache/man
[root@Smoke apache]# netstat -tnlp | grep 80(-tnlp 显示端口为80的tcp监听端口并显示套接字进程号进程名,并以数字显示主机)
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      12981/nginx
[root@Smoke apache]# kill 12981(杀死12981进程)
[root@Smoke apache]# netstat -tnlp | grep 80(-tnlp 显示端口为80的tcp监听端口并显示套接字进程号进程名,并以数字显示主机)
[root@Smoke apache]# apachectl start(启动apache)
[root@Smoke apache]# netstat -tnlp | grep 80(-tnlp 显示端口为80的tcp监听端口并显示套接字进程号进程名,并以数字显示主机)
tcp        0      0 :::80                       :::*                        LISTEN      40483/httpd  
测试:通过windows的ie浏览器输入172.16.100.1可以正常访问到apache的测试页面
It works!
[root@Smoke apache]# cd /usr/local/apache/htdocs/(切换到apache页面的目录)
[root@Smoke htdocs]# ls(查看当前目录文件及子目录)
index.html
[root@Smoke htdocs]# vim index.html(编辑主页文件)
<html><body><h1>I am an Xman</h1></body></html>
测试:通过windows的ie浏览器输入172.16.100.1可以正常访问到apache的测试页面
I am an Xman