SRE笔记 2022.9.5&9.6
- 文件系统
-
- 定义
- 分区格式化
- 常见文件系统
- 文件系统组成
- 生产文件系统选型
- 三商
- 磁盘性能指标
-
- gzip命令
- ftp客户端工具
- Linux软件包安装管理
-
- 软件包分类
- RPM包说明
- RPM包获取
- RPM
-
- rpm格式
- 参数
- 实战nginx rpm安装
- rpm升级
- 注意事项
- rpm查询
- rpm卸载
- yum remove
- rpm校验(了解)
- rpm练习
- RPM痛点
-
- RPM总结
- yum
-
- 定义
- yum源
- 常见互联网yum源
-
- yum 实践
-
- 查询
- 安装
- 重装(了解)
- 更新(慎用)
- 删除(慎用,最好不用)
- 查看yum仓
- yum仓库查询相关(了解扩展)
- yum缓存相关(了解扩展)
- 组包相关指令
-
- 基础运维包
- 补救安装系统时落选的工具
- 环境组包安装命令 yum groupinstall
- 环境组包删除(不能用)
- yum帮助
- yum 常用参数
- yum补全
- yum本地 仓库
-
- yum局域仓
- yum同步官方源
- yum本地仓总结
文件系统
定义
- 文件系统是一种存储和组织计算机中数据文件的机制或方法,它使得对计算机内的数据的存储、访问和查找变得更容易、简单。文件系统落到计算机里其实就是一个应用软件。如ext2 ext3(centos 5) ext4(centos 6) xfs(centos 7) zfs fat nfs reiserfs 等都是常见的文件系统。
分区格式化
- 磁盘分区是在格式化前,操作系统是无法识别系统上磁盘分区格式的,也就无法存取文件目录属性和权限等内容,把分区格式化成操作系统支持的某个文件系统后,再存放数据,系统就会根据这个文件系统的格式进行存取了
常见文件系统
文件系统 |
类型 |
用途 |
Second Extended filesystem |
ext2 |
最常用的Linux文件系统 |
Three Extended filesystem |
ext3 |
ext2的升级版,带日志功能,ext4是ext3的升级版 |
VFAT filesystem |
vfat |
windows95/98采用的文件系统 |
NT filesystem |
ntfs |
windows NT采用的文件系统 |
ISO9660 |
iso9660 |
sun os所用的文件系统 |
UFS filesystem |
ufs |
sun OS 采用的文件系统 |
XFS filesystem |
xfs |
由SGI开发的先进的日志文件系统,支持超大容量文件 |
JFS filesystem |
jfs |
IBM的AIX使用的日志文件系统 |
ReiseFS filesystem |
reiserfs |
基于平衡术结构的文件系统suse |
文件系统组成
生产文件系统选型
- 默认xfs
- 大量小文件可选reiserfs(100k以内)
- 高并发的数据库业务可选xfs
- 视频下载流媒体可选xfs ext4 ext4小文件业务也是可以的
- 有些cdn公司的cache业务服务器曾经还选择ext2文件系统,、因为它没有日志功能,速度快,CDN是做网站加速服务的,对数据完整行要求不高,对速度要求高。
- btrfs对SSD做了优化,但仍处于实验阶段,生产环境谨慎使用
三商
情商EQ
智商IQ
逆商AQ
磁盘性能指标
常见性能指标
- 使用率:指磁盘处理I/O的时间百分比。过高使用率(如超80%)通常意味着I/O存在性能瓶颈
- IOPS(input/output per second):指每秒的I/O请求数(数据库服务器,随机读写)
- 吞吐量:每秒的I/O请求大小(视频大个文件)
- 相应时间:指I/O请求从发出到收到响应的间隔时间
查看命令iostat
root@aaa hd05]
Linux 3.10.0-1160.71.1.el7.x86_64 (aaa) 09/06/22 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.06 0.00 0.28 0.00 0.00 99.65
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 0.35 6.24 20.29 162442 528203
sdb 0.02 0.50 0.24 13132 6166
sdc 0.01 0.28 0.00 7168 4
sdd 0.01 0.19 0.00 5061 0
dm-0 0.26 4.91 20.21 127790 526155
dm-1 0.00 0.12 0.00 3236 0
- 参数d 仅显示设备利用率 参数x显示扩展状态 每隔1秒中刷新显示
[root@aaa hd05]
Linux 3.10.0-1160.71.1.el7.x86_64 (aaa) 09/06/22 _x86_64_ (1 CPU)
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sda 0.00 0.01 0.24 0.11 6.18 20.10 153.51 0.00 0.38 0.26 0.67 0.26 0.01
sdb 0.00 0.00 0.02 0.00 0.50 0.23 89.76 0.00 0.25 0.20 1.10 0.18 0.00
sdc 0.00 0.00 0.01 0.00 0.27 0.00 37.26 0.00 0.19 0.17 8.00 0.15 0.00
sdd 0.00 0.00 0.01 0.00 0.19 0.00 44.39 0.00 0.12 0.12 0.00 0.11 0.00
dm-0 0.00 0.00 0.14 0.11 4.86 20.02 194.11 0.00 0.49 0.35 0.68 0.31 0.01
dm-1 0.00 0.00 0.00 0.00 0.12 0.00 50.96 0.00 0.20 0.20 0.00 0.10 0.00

iotop

gzip命令
[root@aaa yum.repos.d]
total 44
-rw-r--r--. 1 root root 2523 Aug 16 00:36 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Nov 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Nov 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 630 Nov 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 Nov 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 314 Nov 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 616 Nov 23 2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 664 Aug 16 00:37 epel.repo
[root@aaa yum.repos.d]
[root@aaa yum.repos.d]
total 36
-rw-r--r--. 1 root root 601 Aug 16 00:36 CentOS-Base.repo.gz
-rw-r--r--. 1 root root 735 Nov 23 2020 CentOS-CR.repo.gz
-rw-r--r--. 1 root root 426 Nov 23 2020 CentOS-Debuginfo.repo.gz
-rw-r--r--. 1 root root 381 Nov 23 2020 CentOS-Media.repo.gz
-rw-r--r--. 1 root root 506 Nov 23 2020 CentOS-Sources.repo.gz
-rw-r--r--. 1 root root 813 Nov 23 2020 CentOS-Vault.repo.gz
-rw-r--r--. 1 root root 232 Nov 23 2020 CentOS-fasttrack.repo.gz
-rw-r--r--. 1 root root 272 Nov 23 2020 CentOS-x86_64-kernel.repo.gz
-rw-r--r--. 1 root root 254 Aug 16 00:37 epel.repo.gz
[root@aaa yum.repos.d]
[root@aaa yum.repos.d]
total 44
-rw-r--r--. 1 root root 2523 Aug 16 00:36 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Nov 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Nov 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 630 Nov 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 Nov 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 314 Nov 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 616 Nov 23 2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 664 Aug 16 00:37 epel.repo
ftp客户端工具
[root@aaa mirrors]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
lftp-4.4.8-12.el7_8.1.x86_64 : A sophisticated file transfer program
Repo : CentOS7-Cdrom
[root@aaa mirrors]
[root@aaa mirrors]
lftp localhost:~> ls
drwxr-xr-x 3 0 0 225280 Sep 06 16:58 mirrors
drwxr-xr-x 2 0 0 6 Jun 09 2021 pub
Linux软件包安装管理
软件包分类
软件包分类 |
安装方式 |
优缺点 |
rpm包 |
软件厂商预先编译打包,安装简单 |
软件版本可能偏低 |
源码包 |
手动编译打包,安装复杂 |
软件版本随意,可定制安装路径 |
二进制包 |
解压即可使用,安装简单 |
不能修改源码,软件包大 |
RPM包说明
- RPM包全程是RPM package manager,由红帽公司开发的用于软件的安装、卸载、升级与查询的包管理工具
[root@aaa hd05]
tree-1.6.0-10.el7.x86_64
- 软件包名 tree
- 发布版本 1.6.0
- 软件包发布次数 10
- 系统版本 el7
- 硬件平台 x86_64
RPM包获取
- centos7自带
- 特定软件官方获取
- 通过联网的方式去官方或镜像站点获取
RPM
rpm格式
- rpm 选项 软件包
- rpm -ivh (1网址 2 全路径带包名 3 包名)
参数
- i 安装软件包
- v 显示安装信息
- h 显示安装进度
实战nginx rpm安装
- http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.18.0-2.el7.ngx.x86_64.rpm
[root@aaa hd05]
[root@aaa src]
total 0
drwxr-xr-x. 2 root root 6 Apr 11 2018 debug
drwxr-xr-x. 4 root root 71 Aug 16 00:56 kernels
[root@aaa src]
--2022-09-06 05:51:48-- http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.18.0-2.el7.ngx.x86_64.rpm
Resolving nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:edb:5704::6, ...
Connecting to nginx.org (nginx.org)|3.125.197.172|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 787272 (769K) [application/x-redhat-package-manager]
Saving to: 'nginx-1.18.0-2.el7.ngx.x86_64.rpm'
100%[==================================================>] 787,272 654KB/s in 1.2s
2022-09-06 05:51:50 (654 KB/s) - 'nginx-1.18.0-2.el7.ngx.x86_64.rpm' saved [787272/787272]
[root@aaa src]
total 772
drwxr-xr-x. 2 root root 6 Apr 11 2018 debug
drwxr-xr-x. 4 root root 71 Aug 16 00:56 kernels
-rw-r--r--. 1 root root 787272 Oct 29 2020 nginx-1.18.0-2.el7.ngx.x86_64.rpm
[root@aaa src]
warning: nginx-1.18.0-2.el7.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Preparing...
Updating / installing...
1:nginx-1:1.18.0-2.el7.ngx
----------------------------------------------------------------------
Thanks for using nginx!
Please find the official documentation for nginx here:
* http://nginx.org/en/docs/
Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* http://nginx.org/en/support.html
Commercial subscriptions for nginx are available on:
* http://nginx.com/products/
----------------------------------------------------------------------
rpm升级
- U 升级 如果老版本不存在则安装新版本,存在即升级
- http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.20.2-1.el7.ngx.x86_64.rpm,下载新版本
[root@aaa src]
total 1564
drwxr-xr-x. 2 root root 6 Apr 11 2018 debug
drwxr-xr-x. 4 root root 71 Aug 16 00:56 kernels
-rw-r--r--. 1 root root 787272 Oct 29 2020 nginx-1.18.0-2.el7.ngx.x86_64.rpm
-rw-r--r--. 1 root root 808972 Nov 16 2021 nginx-1.20.2-1.el7.ngx.x86_64.rpm
[root@aaa src]
warning: nginx-1.20.2-1.el7.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Preparing...
Updating / installing...
1:nginx-1:1.20.2-1.el7.ngx
Cleaning up / removing...
2:nginx-1:1.18.0-2.el7.ngx
注意事项
rpm查询
选项 |
描述 |
rpm -q |
查看指定软件包是否安装 |
rpm -qa |
查看系统中已安装的所有rpm软件包列表******* |
rpm -qi |
查看指定软件的详细信息 |
rpm -ql |
查询指定软件包的安装目录、文件列表 *** |
rpm -qc |
查询指定软件包的配置文件 |
rpm -qf |
查询文件或目录属于哪个rpm软件 ******* |
rpm -qip |
查询未安装的rpm包详细信息 |
rpm -qp |
查询未安装的软件包hi产生哪些文件 |
[root@aaa src]
tree-1.6.0-10.el7.x86_64
[root@aaa src]
nginx-1.20.2-1.el7.ngx.x86_64
- qf参数 如果要查询的文件或者命令不存在则无法溯源
[root@aaa src]
setup-2.8.71-11.el7.noarch
[root@aaa src]
coreutils-8.22-24.el7_9.2.x86_64
rpm卸载
- -e 卸载
- –force 强制
- –nodeps 忽略依赖关系
- 强制卸载 rpm -e --force --nodeps 包名
- 手动解决依赖包
yum remove
- 卸载依赖,永远不用
-
- rpm --nodeps 忽略依赖关系,也不建议使用,依赖包可保留不启用

rpm校验(了解)
参数 |
描述 |
S |
文件的容量大小是否被改变 |
M |
文件的类型或文件的属性是否被修改 |
5 |
MD5 这一种指纹加密的内容意境不同 |
L |
路径已经被改变 |
U |
文件的所属主已被修改 |
G |
文件的所属组已被修改 |
T |
文件的创建时间已被修改 |
rpm练习
[root@aaa src]
net-tools-2.0-0.25.20131004git.el7.x86_64
[root@aaa src]
[root@aaa src]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
openssh-server-7.4p1-21.el7.x86_64 : An open source SSH server daemon
Repo : base
Matched from:
Filename : /etc/ssh/sshd_config
openssh-server-7.4p1-22.el7_9.x86_64 : An open source SSH server daemon
Repo : updates
Matched from:
Filename : /etc/ssh/sshd_config
openssh-server-7.4p1-22.el7_9.x86_64 : An open source SSH server daemon
Repo : @updates
Matched from:
Filename : /etc/ssh/sshd_config
RPM痛点
7.9镜像挂载

[root@aaa ~]
mount: /dev/sr0 is write-protected, mounting read-only
[root@aaa ~]
4071
安装samba
[root@aaa ~]
error: Failed dependencies:
libCHARSET3-samba4.so()(64bit) is needed by samba-0:4.10.16-5.el7.x86_64
libCHARSET3-samba4.so(SAMBA_4.10.16)(64bit) is needed by samba-0:4.10.16-5.el7.x86_64
libMESSAGING-SEND-samba4.so()(64bit) is needed by samba-0:4.10.16-5.el7.x86_64
libaddns-samba4.so()(64bit) is needed by samba-0:4.10.16-5.el7.x86_64
libads-samba4.so()(64bit) is needed by samba-0:4.10.16-5.el7.x86_64
libaesni-intel-samba4.so()(64bit) is needed by samba-0:4.10.16-5.el7.x86_64
libasn1util-samba4.so()(64bit) is needed by samba-0:4.10.16-5.el7.x86_64
......
RPM总结
- rpm命令经常用于查询,尽量不用其安装
- rpm无法解决依赖问题。
yum
定义
yum是redhat以及centos中的软件包管理器,能够通过互联网下载.rpm包且安装,并可自动处理依赖关系。是生产常用工具。
yum源
- rpm包存放的地址
- 互联网yum源
- 局域网yum源(http,ftp)(1 速度快,2 自己编译,制作的rpm放到本地yum)
- 服务器本地yum源(系统iso镜像)
常见互联网yum源
官方yum源
- 很多软件集合的在线仓库,也成为了base基础源
- epel源 :拓展源,拥有很多base源没有的软件
- 阿里源:http://mirrors.aliyun.com/repo/
- 系统安装完毕首先修改更新源
curl -s -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或 参数q静默下载
wget -q -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
curl -s -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
或
wget -q -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
或
yum install -y epel-release
- yum update -y 或 yum upgrade
第三方源
- 比如ngingx,zabbix,Docker等软件开发方开源软件的官方仓库(第三方软件无法归档至base、epel源,故自己建立源,但是只有自己的一部分软件)
- http://nginx.org/en/linux_packages.html#RHEL-CentOS
yum 实践
查询
[root@aaa ~]
[root@aaa ~]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Installed Packages
tree.x86_64 1.6.0-10.el7 @base
[root@aaa ~]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Installed Packages
Name : tree
Arch : x86_64
Version : 1.6.0
Release : 10.el7
Size : 87 k
Repo : installed
From repo : base
Summary : File system tree viewer
URL : http://mama.indstate.edu/users/ice/tree/
License : GPLv2+
Description : The tree utility recursively displays the contents of directories in a
: tree-like format. Tree is basically a UNIX port of the DOS tree
: utility.
安装
[root@aaa ~]
[root@aaa ~]
- 安装本地的rpm包,如果有依赖关系,会自动从互联网软件仓库中下载所需依赖
[root@aaa ~]
[root@aaa ~]
重装(了解)
[root@aaa ~]
[root@aaa ~]
[root@aaa ~]
更新(慎用)
- 对比系统中已安装的软件和yum仓库中的软件,有哪些需要升级
root@aaa ~]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
kernel.x86_64 3.10.0-1160.76.1.el7 updates
kernel-devel.x86_64 3.10.0-1160.76.1.el7 updates
kernel-headers.x86_64 3.10.0-1160.76.1.el7 updates
kernel-tools.x86_64 3.10.0-1160.76.1.el7 updates
kernel-tools-libs.x86_64 3.10.0-1160.76.1.el7 updates
microcode_ctl.x86_64 2:2.1-73.14.el7_9 updates
python-perf.x86_64 3.10.0-1160.76.1.el7 updates
rsync.x86_64 3.1.2-11.el7_9 updates
systemd.x86_64 219-78.el7_9.7 updates
systemd-libs.x86_64 219-78.el7_9.7 updates
systemd-python.x86_64 219-78.el7_9.7 updates
systemd-sysv.x86_64 219-78.el7_9.7 updates
tzdata.noarch 2022c-1.el7 updates
[root@aaa ~]
-更新某一个软件,升级后可能依赖不能用
[root@aaa ~]
- 更新命令生产慎用,最好不用
- 安装系统后,业务上线前
删除(慎用,最好不用)
[root@aaa ~]
查看yum仓
[root@aaa ~]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
repo id repo name status
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10072
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13755
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 516
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 4156
yum仓库查询相关(了解扩展)
[root@aaa yum.repos.d]
[root@aaa yum.repos.d]
[root@aaa yum.repos.d]
[root@aaa yum.repos.d]
yum缓存相关(了解扩展)
- 为什么要缓存:配置yum仓库,rpm来源;rpm更新快,无法找到旧包;yum安装之后默认软件包删除
- 缓存rpm包方式1,修改yum全局配置文件
[root@aaa yum.repos.d]
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
[root@aaa yum.repos.d]
[root@aaa yum.repos.d]
keepcache=1
[root@aaa yum.repos.d]
yum.conf yum.conf.bak yum.repos.d/
[root@aaa yum.repos.d]
[root@aaa yum.repos.d]
[root@aaa yum.repos.d]
[root@aaa yum.repos.d]
组包相关指令
基础运维包
软件 |
包含的核心命令 |
tree |
以树形结构显示文件和目录 |
nmap |
namp扫描端口的工具 |
dos2unix |
转换脚本格式的工具 |
lrzsz |
上传下载 |
nc |
文件传输 端口检查 |
lsof |
反查端口进程,以及服务开发文件工具 |
wget |
下载工具 |
tcpdump |
抓包,监听等重要拍错 |
htop |
系统进程相关信息查看工具 |
iftop |
查看主机网卡带宽工具 |
sysstat |
含有sar,iostat等重要系统性能查看工具 |
nethogs |
显示进程的网络流量 |
psmisc |
含有killall、pstree命令 |
net-tools |
含有netstat、ifconfig、route、arp等命令 |
vim-enhanced |
vim编辑器工具包 |
bash-completion、bash-complation-extras |
tab补全工具包 |
补救安装系统时落选的工具
- 安装系统时选择的工具包左侧为环境组包,右侧为组包内可用的小包
[root@aaa yum.repos.d]
[root@aaa yum.repos.d]
Available Environment Groups:
Minimal Install
Compute Node
Infrastructure Server
File and Print Server
Cinnamon Desktop
MATE Desktop
Basic Web Server
Virtualization Host
Server with GUI
GNOME Desktop
KDE Plasma Workspaces
Development and Creative Workstation
Installed Groups:
Compatibility Libraries
Development Tools
Milkymist
Security Tools
System Administration Tools
Available Groups:
Cinnamon
Console Internet Tools
Educational Software
Electronic Lab
Fedora Packager
General Purpose Desktop
Graphical Administration Tools
Haskell
LXQt Desktop
Legacy UNIX Compatibility
MATE
Scientific Support
Smart Card Support
System Management
TurboGears application framework
Xfce
Done
环境组包安装命令 yum groupinstall
[root@aaa yum.repos.d]
[root@aaa yum.repos.d]
[root@aaa yum.repos.d]
环境组包删除(不能用)
[root@aaa yum.repos.d]
yum帮助
[root@aaa yum.repos.d]
Loaded plugins: fastestmirror
Usage: yum [options] COMMAND
List of Commands:
check Check for problems in the rpmdb
check-update Check for available package updates
clean Remove cached data
deplist List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade downgrade a package
erase Remove a package or packages from your system
fs Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot Creates filesystem snapshots, or lists/deletes current snapshots.
groups Display, or use, the groups information
help Display a helpful usage message
history Display, or use, the transaction history
info Display details about a package or group of packages
install Install a package or packages on your system
list List a package or groups of packages
load-transaction load a saved transaction from filename
makecache Generate the metadata cache
provides Find what package provides the given value
reinstall reinstall a package
repo-pkgs Treat a repo. as a group of packages, so we can install/remove all of them
repolist Display the configured software repositories
search Search package details for the given string
shell Run an interactive yum shell
swap Simple way to swap packages, instead of using shell
update Update a package or packages on your system
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo Acts on repository update information
upgrade Update packages taking obsoletes into account
version Display a version for the machine and/or available repos.
yum 常用参数
参数 |
描述 |
install |
安装1个或多个软件包 |
clean |
删除缓存数据 |
groups |
显示或使用、组信息 |
list |
列出一个或一组软件包 |
makecache |
创建元数据缓存 |
repolist |
显示已配置的源 |
search |
在软件包详细信息中搜索指定字符串 |
update |
更新系统中的一个或多个软件包 |
upgrade |
更新软件包同时考虑软件包取代关系 |
yum补全
[root@aaa yum.repos.d]
check downgrade install reinstall update
check-update groups list remove upgrade
clean help load-transaction repolist version
deplist history makecache search
distro-sync info provides shell
[root@aaa yum.repos.d]
check downgrade install reinstall update
check-update groups list remove upgrade
clean help load-transaction repolist version
deplist history makecache search
distro-sync info provides shell
yum本地 仓库
本地光盘镜像库
[root@aaa mnt]
total 696
-rw-r--r--. 3 root root 14 Oct 30 2020 CentOS_BuildTag
drwxr-xr-x. 3 root root 2048 Oct 27 2020 EFI
-rw-rw-r--. 21 root root 227 Aug 30 2017 EULA
-rw-rw-r--. 21 root root 18009 Dec 10 2015 GPL
drwxr-xr-x. 2 root root 2048 Oct 27 2020 LiveOS
drwxr-xr-x. 2 root root 673792 Nov 4 2020 Packages
-rw-rw-r--. 21 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 21 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2883 Nov 4 2020 TRANS.TBL
drwxr-xr-x. 3 root root 2048 Oct 27 2020 images
drwxr-xr-x. 2 root root 2048 Nov 3 2020 isolinux
drwxr-xr-x. 2 root root 4096 Nov 4 2020 repodata
[root@aaa mnt]
Filesystem Size Used Avail Use% Mounted on
devtmpfs 899M 0 899M 0% /dev
tmpfs 910M 0 910M 0% /dev/shm
tmpfs 910M 9.6M 901M 2% /run
tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/mapper/centos-root 17G 2.7G 15G 16% /
/dev/sda1 1014M 195M 820M 20% /boot
tmpfs 182M 0 182M 0% /run/user/0
/dev/sr0 4.4G 4.4G 0 100% /mnt
[root@aaa mnt]
CentOS-Base.repo CentOS-Media.repo CentOS-fasttrack.repo
CentOS-CR.repo CentOS-Sources.repo CentOS-x86_64-kernel.repo
CentOS-Debuginfo.repo CentOS-Vault.repo epel.repo
[root@aaa mnt]
[root@aaa mnt]
total 36
-rw-r--r--. 1 root root 601 Aug 16 00:36 CentOS-Base.repo.gz
-rw-r--r--. 1 root root 735 Nov 23 2020 CentOS-CR.repo.gz
-rw-r--r--. 1 root root 426 Nov 23 2020 CentOS-Debuginfo.repo.gz
-rw-r--r--. 1 root root 381 Nov 23 2020 CentOS-Media.repo.gz
-rw-r--r--. 1 root root 506 Nov 23 2020 CentOS-Sources.repo.gz
-rw-r--r--. 1 root root 813 Nov 23 2020 CentOS-Vault.repo.gz
-rw-r--r--. 1 root root 232 Nov 23 2020 CentOS-fasttrack.repo.gz
-rw-r--r--. 1 root root 272 Nov 23 2020 CentOS-x86_64-kernel.repo.gz
-rw-r--r--. 1 root root 254 Aug 16 00:37 epel.repo.gz
[root@aaa mnt]
[CentOS7-Cdrom]
name=local yum
baseurl=file:///mnt
enabled=1
gpgcheck=0
[root@aaa mnt]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
CentOS7-Cdrom | 3.6 kB 00:00:00
(1/4): CentOS7-Cdrom/group_gz | 153 kB 00:00:00
(2/4): CentOS7-Cdrom/filelists_db | 3.3 MB 00:00:00
(3/4): CentOS7-Cdrom/primary_db | 3.3 MB 00:00:00
(4/4): CentOS7-Cdrom/other_db | 1.3 MB 00:00:00
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.6.0-10.el7 will be installed
--> Finished Dependency Resolution
......
https://segmentfault.com/a/1190000016214318
yum局域仓
[root@aaa mnt]
[root@aaa mnt]
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/syst`在这里插入代码片`em/dbus-org.fedoraproject.FirewallD1.service.
[root@aaa mnt]
Enforcing
[root@aaa mnt]
[root@aaa mnt]
Permissive
[root@aaa mnt]
SELINUX=enforcing
SELINUXTYPE=targeted
[root@aaa mnt]
[root@aaa mnt]
SELINUX=disable
SELINUXTYPE=targeted
[root@aaa mnt]
[root@aaa mnt]
[root@aaa mnt]
[root@aaa mnt]
[root@aaa mnt]
tcp6 0 0 :::21 :::* LISTEN 3488/vsftp
- 浏览器测试
- ftp://10.0.0.128
- 开启yum 缓存功能
[root@aaa mnt]
keepcache=1
[root@aaa mnt]
Loaded plugins: fastestmirror
Cleaning repos: CentOS7-Cdrom
Cleaning up list of fastest mirrors
Other repos take up 189 M of disk space (use --verbose for details)
- 创建yum本地目录,并创建元数据提供基础base软件包
[root@aaa mnt]
[root@aaa mnt]
[root@aaa mirrors]
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@aaa mirrors]
total 4
drwxr-xr-x. 2 root root 4096 Sep 7 00:56 repodata
[root@aaa mirrors]
- 当yum仓库的软件包内容发生变动时,需要更新,即生成新索引
[root@aaa mirrors]
[root@aaa mirrors]
- windows测试ftp服务可用

- 至此yum局域网源搭建完成,如果还想增添其他软件,可将相关rpm包下载至该目录,或者找到源码,编译成rpm包,移动至此。如sl 跑火车
- 将客户端指向服务端

yum同步官方源
http://mirrors.ustc.edu.cn/status/
- 官方要求,只能通过rsync协议进行异地同步
- centos源:rsync://mirrors.ustc.edu.cn/centos/
- epel源:rsync://mirrors.ustc.edu.cn/epel/
- 创建本地目录 mkdir /mirrors/repodata/{os,extras,updates,epel}-
- 同步源命令即远程复制
- rsync -av rsync://mirrors.ustc.edu.cn/centos/7/os/x86_64/ /mirror/repodata/os/
- rsync -av rsync://mirrors.ustc.edu.cn/centos/7/extras/x86_64/ /mirror/repodata/extras/
- rsync -av rsync://mirrors.ustc.edu.cn/centos/7/updates/x86_64/ /mirror/repodata/updates/
- rsync -av --exclude=dubug rsync://mirrors.ustc.edu.cn/epe;/6/x86_64 mirror/repodata/epel/
- 定时任务同步官方
yum本地仓总结
- 绝大部分中小企业不会搭建自己yum源,都会使用阿里源等,epel源,或者软件官方源
- 本地yum仓可能是有自己的rpm包,使用习惯,备份