1.rpm 软件包管理。
1.1.挂载光盘:
[
root@niejicai-linux ~]# mount /dev/cdrom1 /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only
[
root@niejicai-linux ~]# cd /mnt/
[
root@niejicai-linux mnt]# ls
CentOS_BuildTag repodata
EULA RPM-GPG-KEY-CentOS-6
GPL RPM-GPG-KEY-CentOS-Debug-6
images RPM-GPG-KEY-CentOS-Security-6
isolinux RPM-GPG-KEY-CentOS-Testing-6
Packages TRANS.TBL
RELEASE-NOTES-en-US.html
[
root@niejicai-linux mnt]# cd Packages/
[
root@niejicai-linux Packages]#ls 使用的RPM包
kbd-misc-1.15-11.el6.noarch.rpm
kcoloredit-4.3.3-2.el6.i686.rpm
kcoloredit-doc-4.3.3-2.el6.noarch.rpm
...............................
1.2.用rpm 安装一个rpm包
Preparing... #################################### ####### [100%]
1:yajl #################################### ####### [100%]
1.3.卸载一个rpm包,rpm -e +(包名)。
[
root@niejicai-linux Packages]# rpm
-e yajl-1.0.7-3.el6.i686.rpm 卸载一个rpm
查看是否卸载成功!
[
root@niejicai-linux Packages]# echo $?
0这里是0就说明,上一条命令是正确的!
[
root@niejicai-linux Packages]#
1.4.强制安装 rpm -ivh --nodeps
[
root@niejicai-linux Packages]# rpm -ivh
--nodeps xorg-x11-apps-7.6-6.e16.i686.rpm
1.5.升级一个rpm包(rpm -Uvh +(包名)
[
root@niejicai-linux Packages]# tpm -Uvh vim-enhanced-7.2.411-1.8.el6.i686.rpm
1.6.怎么去查看系统里面所有的安装过的rpm包呢?
rpm -qa vim-enhanced (rpm -qa +包名)
[
root@niejicai-linux Packages]# rpm -qa | grep vim
模糊查询
vim-common-7.4.629-5.el6.i686
vim-minimal-7.4.629-5.el6.i686
vim-enhanced-7.4.629-5.el6.i686
vim-filesystem-7.4.629-5.el6.i686
[
root@niejicai-linux Packages]#
2.总结内容如下:
1. rpm工具
rpm Redhat Package Manager, 设计理念是开放的,不仅仅是在RedHat平台上,在SUSE上也是可以使用的。
rpm包名字构成由-和.分成了若干部分,如abrt-cli-2.0.8-15.el6.centos.i686.rpm,
abrt-cli是包名,2.0.8-15是
版本号,
el6指的是redhat企业版6,centos指的是这是在centos上用的,i686指的是平台类型。有些rpm包并没有写具
体的平台而是noarch,这代表这个rpm包没有硬件平台限制。
安装一个包:
rpm -ivh /mnt/Packages/
xsettings-kde-0.11-1.el6.i686.rpm
-i 表示安装,-v 可视化,-h显示安装进度
--force : 强制安装,即使覆盖属于其他包的文件也要安装
--nodeps : 当要安装的rpm包依赖其他包时,即使其他包没有安装,也要安装这个包
升级:rpm -Uvh filename.rpm
-U 就是升级的意思
rpm的卸载:
rpm -e filename //这里的filename是通过rpm的查询功能所查询到的
rpm -qa |grep libjpeg-turbo-devel
rpm -e libjpeg-turbo-devel
查看一个包是否安装
rpm -q 包名 (不带有平台信息以及后缀名 )
查看当前系统所有安装过的rpm包
rpm -qa (all)
查看rpm包的相关信息 :
rpm -qi 包名
查看一个rpm包都安装了那些文件:
rpm -ql 包名
查看一个文件属于哪个rpm包安装的:
rpm -qf filename //这里可以结合反引号一起使用,比如
rpm -qf `which pwd`
2. yum 软件包管理
2.1.
[
root@niejicai-linux ~]# yum install -y +包名 (安装一个包)
[
root@niejicai-linux ~]# yum remove +包名 (卸载一个包)
[
root@niejicai-linux ~]# yum update +包名 (升级一个包)
[
root@niejicai-linux ~]# yum provides
"*/vim"(查找一个命令是由那个包安装的) 固定格式!
[
root@niejicai-linux ~]# yum provides "*/vim"
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.pubyun.com
* extras: mirrors.yun-idc.com
* updates: mirrors.pubyun.com
base/filelists_db | 5.2 MB 00:09
extras/filelists_db | 35 kB 00:00
updates/filelists_db | 1.7 MB 00:03
2:vim-enhanced-7.4.629-5.el6.i686 : A version of the VIM editor which
: includes recent enhancements
Repo : base
Matched from:
Filename : /usr/bin/vim
2:vim-common-7.4.629-5.el6.i686 : The common files needed by any version
: of the VIM editor
Repo : base
Matched from:
Filename : /usr/share/vim
git-1.7.1-3.el6_4.1.i686 : Fast Version Control System
Repo : base
Matched from:
Filename : /usr/share/doc/git-1.7.1/contrib/vim
cmake-2.8.12.2-4.el6.i686 : Cross-platform make system
Repo : base
Matched from:
Filename : /usr/share/cmake/editors/vim
2:vim-enhanced-7.4.629-5.el6.i686 : A version of the VIM editor which
: includes recent enhancements
Repo : installed
Matched from:
Filename : /usr/bin/vim
[root@niejicai-linux ~]# yum grouplist
查看系统的所有的套件
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Group Process
Loading mirror speeds from cached hostfile
* base: mirrors.pubyun.com
* extras: mirrors.yun-idc.com
* updates: mirrors.pubyun.com
Installed Groups:
KDE Desktop
Large Systems Performance
Load Balancer
Mainframe Access
Messaging Client Support
MySQL Database client
MySQL Database server
NFS file server
Network Storage Server
Network file system client
Office Suite and Productivity
PHP Support
PostgreSQL Database client
PostgreSQL Database server
Remote Desktop Clients
Resilient Storage
Ruby Support
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:
Irish Support [ga]
Italian Support [it]
Kannada Support [kn]
Kashmiri Support [ks]
......................................
Done
[
root@niejicai-linux ~]#
安装一个套件 (yum groupinstall )
[
root@niejicai-linux ~]#
yum groupinstall " Xhosa Support"
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Group Process
Loading mirror speeds from cached hostfile
* base: mirrors.pubyun.com
* extras: mirrors.yun-idc.com
* updates: mirrors.pubyun.com
Resolving Dependencies
--> Running transaction check
---> Package hunspell-xh.noarch 0:0.20060123-3.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================
Package Arch Version Repository
Size
=========================================================================
Installing:
hunspell-xh noarch 0.20060123-3.1.el6 base 81 k
Transaction Summary
=========================================================================
Install 1 Package(s)
Total download size: 81 k
Installed size: 208 k
Is this ok [y/N]: y
Downloading Packages:
hunspell-xh-0.20060123-3.1.el6.noarch.rpm | 81 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : hunspell-xh-0.20060123-3.1.el6.noarch 1/1
Verifying : hunspell-xh-0.20060123-3.1.el6.noarch 1/1
Installed:
hunspell-xh.noarch 0:0.20060123-3.1.el6
Complete!
[
root@niejicai-linux ~]#
卸载一个套件yum groupremove
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Group Process
Loading mirror speeds from cached hostfile
* base: mirrors.pubyun.com
* extras: mirrors.yun-idc.com
* updates: mirrors.pubyun.com
Resolving Dependencies
--> Running transaction check
---> Package hunspell-xh.noarch 0:0.20060123-3.1.el6 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================
Package Arch Version Repository Size
=========================================================================
Removing:
hunspell-xh noarch 0.20060123-3.1.el6 @base 208 k
Transaction Summary
=========================================================================
Remove 1 Package(s)
Installed size: 208 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : hunspell-xh-0.20060123-3.1.el6.noarch 1/1
Verifying : hunspell-xh-0.20060123-3.1.el6.noarch 1/1
Removed:
hunspell-xh.noarch 0:0.20060123-3.1.el6
Complete!
[
root@niejicai-linux ~]#
2.2.创建一个本地的yum源
我们这里是用光盘来弄本地yum源
我们这里是用光盘来弄本地yum源
2.2.1挂载光盘
[
root@niejicai-linux ~]# mount /dev/cdrom1 /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only
[
root@niejicai-linux ~]# cd /mnt/
[
root@niejicai-linux mnt]# ls
CentOS_BuildTag repodata
EULA RPM-GPG-KEY-CentOS-6
GPL RPM-GPG-KEY-CentOS-Debug-6
images RPM-GPG-KEY-CentOS-Security-6
isolinux RPM-GPG-KEY-CentOS-Testing-6
Packages TRANS.TBL
RELEASE-NOTES-en-US.html
[
root@niejicai-linux mnt]# cd Packages/
[
root@niejicai-linux Packages]#ls 使用的RPM包
kbd-misc-1.15-11.el6.noarch.rpm
kcoloredit-4.3.3-2.el6.i686.rpm
kcoloredit-doc-4.3.3-2.el6.noarch.rpm
...............................
2.2.2
[
root@niejicai-linux ~]# cd /etc/yum.repos.d
[
root@niejicai-linux yum.repos.d]#
[
root@niejicai-linux yum.repos.d]# ls
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-Debuginfo.repo CentOS-Media.repo
[
root@niejicai-linux yum.repos.d]#
[
root@niejicai-linux yum.repos.d]# rm -rf ./*
[
root@niejicai-linux yum.repos.d]# ls
[
root@niejicai-linux yum.repos.d]# vim dvd.repo
输入如下的内容
[dvd]
name=install dvd
baseurl=file:///mnt 本地的路径的写法
enabled=1 可用
gpgcheck=0 不检测验证
[
root@niejicai-linux yum.repos.d]# yum list | wc -l
4839
[
root@niejicai-linux yum.repos.d]# ls /mnt/Packages/ | wc -l
3137
[
root@niejicai-linux yum.repos.d]#
2.3创建一个epel 源(扩展源)
[
root@niejicai-linux etc]# ls
motd yum
mtab yum.conf
mtools.conf
yum.repos.d
my.cnf
yum.repos.dbak
nanorc
[
root@niejicai-linux ~]# cd /etc/yum.repos.d
[
root@niejicai-linux yum.repos.d]# ls
dvd.repo
[
root@niejicai-linux yum.repos.d]# cd /etc/
[
root@niejicai-linux etc]# rm -rf yum.repos.d
[
root@niejicai-linux etc]# mv yum.repos.dbak/ yum.repos.d
[
root@niejicai-linux etc]# rpm -ivh
http://www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm
Retrieving
http://www.lishiming.net/data/attachment/forum/epel-release-6- 8_32.noarch.rpm
warning: /var/tmp/rpm-tmp.Kv8hlk: Header V3 RSA/SHA256 Signature, key ID0608b895: NOKEY
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
[
root@niejicai-linux etc]#
[
root@niejicai-linux etc]# yum list
znc-modtcl.i686 1.4-1.el6 epel
zsh.i686 4.3.11-4.el6.centos.1 updates
zsh-html.i686 4.3.11-4.el6.centos.1 updates
zsh-lovers.noarch 0.9.0-1.el6 epel
zvbi.i686 0.2.33-6.el6 epel
zvbi-devel.i686 0.2.33-6.el6 epel
zvbi-fonts.noarch 0.2.33-6.el6 epel
zziplib.i686 0.13.62-1.el6 epel
zziplib-devel.i686 0.13.62-1.el6 epel
zziplib-utils.i686 0.13.62-1.el6 epel
.....................................
[
root@niejicai-linux ~]# cd /etc/yum.repos.d/
[
root@niejicai-linux yum.repos.d]# ls
CentOS-Base.repo CentOS-Media.repo epel-testing.repo
CentOS-Debuginfo.repo CentOS-Vault.repo
CentOS-fasttrack.repo
epel.repo
[
root@niejicai-linux yum.repos.d]#
[
root@niejicai-linux yum.repos.d]# yum list | grep nginx
collectd-nginx.i686 4.10.9-1.el6 epel
munin-nginx.noarch 2.0.25-2.el6 epel
nginx.i686 1.0.15-12.el6 epel
nginx-filesystem.noarch 1.0.15-12.el6 epel
owncloud-nginx.noarch 7.0.10-1.el6 epel
[
root@niejicai-linux yum.repos.d]#
2.4. 源码包安装
源码包是开源的可自行更改的程序包,大多用C语言开发,不能直接使用,需要编译成二进制的可执行文件
编译源码包的必须有gcc支持,如果没有需要安装 yum install -y gcc
通常情况编译三步曲: ./configure 配置各种编译参数; make 根据指定的编译参数进行编译;make install 安装到
指定目录
实例:
下载源码包 cd /usr/local/src/ #约定目录;
解压
tar jxvf httpd-2.2.27.tar.bz2 //查看README或者INSTALL说明文件
指定编译参数 ./configure --help
echo $? 验证是否成功
make
make install