Linux软件包管理(yum在线管理)

相对于rpm的命令管理,不需要管理依赖性。
使用yum在线管理,不仅会安装你要安装的包,还会安装相应的依赖包。
yum在线管理的话,并不是一定要在线,可以做本地yum·源。
没有yum包这个说法,yum在线管理的还是RPM包。


ifconfig配置的IP地址,是临时生效的,一旦重启,会恢复原样。用这种方式只能配置IP和子网掩码。如果想要上网还需要网关和DNS。如果在内网访问,只要IP和子网掩码就可以了。但是如果想要访问公网,就需要网关和DNS。使用ifconfig就做不到这样的功能。

配置IP有很多种方法,我们可以选择一个比较简单的setup方法。setup是redhat系列专有的命令,setup配置IP相对简单。

图片.png

按tab键可以切换。

图片.png

网络yum源:

图片.png
图片.png

CentOS-Base.repo: 网路yum源。
CentOS-Media.repo: 本地光盘yum源。

CentOS-Base.repo里面的配置:

  1 # CentOS-Base.repo
  2 #
  3 # The mirror system uses the connecting IP address of the client and the
  4 # update status of each mirror to pick mirrors that are updated to and
  5 # geographically close to the client.  You should use this for CentOS update    s
  6 # unless you are manually picking other mirrors.
  7 #
  8 # If the mirrorlist= does not work for you, as a fall back you can try the 
  9 # remarked out baseurl= line instead.
 10 #
 11 #
 12 
 13 [base]
 14 name=CentOS-$releasever - Base
 15 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&    repo=os&infra=$infra
 16 #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
 17 gpgcheck=1
 18 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 19 
 20 #released updates 
 21 [updates]
 22 name=CentOS-$releasever - Updates
 23 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&    repo=updates&infra=$infra
 24 #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
 25 gpgcheck=1
 26 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 27 
 28 #additional packages that may be useful
 29 [extras]
 30 name=CentOS-$releasever - Extras
 31 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&    repo=extras&infra=$infra
 32 #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
 33 gpgcheck=1
 34 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 35 
 36 #additional packages that extend functionality of existing packages
 37 [centosplus]
 38 name=CentOS-$releasever - Plus
 39 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&    repo=centosplus&infra=$infra
 40 #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
 41 gpgcheck=1
 42 enabled=0
 43 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 44 

从上面可以看出:
[base]与[updates]是一样的格式,定义的相同的内容。
里面有:[base],[updates],[extras],[centosplus]这么几个软件池,默认是第一个软件池([base])生效。

结合上面的图片来查看这个配置。


常用的yum命令:

yum list

列出所有可用的软件包 。

图片.png

yum列出的包:

图片.png

分为:包名, 版本, 容器的名称

yum的库存:

$ cd /etc/yum.repos.d/

yum search 关键字来搜索服务器上的所有和关键字相关的包。

图片.png

eg:yum -y install gcc

图片.png

如果:yum -y update不跟包名,那么就是更新所有软件包,包括Linux内核都会升级。内核如果升级之后,那么需要在本地做一些配置才能,所以远程执行了这个命令,那么服务器就不能开机了,谨慎使用。

图片.png

软件组管理:

图片.png

光盘yum源搭建

也就是本地yum源搭建。
对服务器来说考虑的最主要的是稳定和安全,本地yum光盘可能不是最新的,这个无所谓。
做本地Yum源,需要做一定的配置。

图片.png

让yum源失效的办法就是修改掉.repo的后缀。

图片.png
图片.png
图片.png

改掉名字之后,本地yum源修改配置:

图片.png

这样本地yum源就配置好了。

管道符号(|)
Linux所提供的管道符“|”将两个命令隔开,管道符左边命令的输出就会作为管道符右边命令的输入。

grep "main"  test.c

用来搜索test.c里是否包含字串 main

注意:在baseurl=file:///mnt/cdrom
后面不能加任何空格或者tab,也不能写注释这些,严格的要求。

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 137,421评论 19赞 139
  • 各大Linux发行版软件包管理参考(http://www.freeoa.net/osuport/botinstal...
    IRONYT阅读 7,650评论 0赞 12
  • 第2章 软件包管理简介 一、源码包 //脚本安装包;❶源码包优点:①开源,如果有足够的能力,可以修改源代码;②...
    seven1010阅读 542评论 0赞 0
  • linux资料总章2.1 1.0写的不好抱歉 但是2.0已经改了很多 但是错误还是无法避免 以后资料会慢慢更新 大...
    数据革命阅读 13,830评论 2赞 33
  • 一次偶然的机会读到这本书,吉田医生,四个孩子的妈妈,带着全家来到波士顿,一边安抚小孩,一边煮饭擦地洗碗,顺利拿到...
    我们的简单生活阅读 255评论 0赞 0

友情链接更多精彩内容