百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术文章 > 正文

Linux Centos7 yum 配置解读与理解

nanshan 2024-10-23 11:55 27 浏览 0 评论

系统: CentOS Linux release 7.2.1511 (Core)

配置目录:

/etc/yum/ # 未知
/etc/yum.conf # 使用 yum 安装软件的时候,都会读取这个配置文件
/etc/yum.repos.d/ # 其它与yum相关的子配置文件

换源,使用国内源:

163源: http://mirrors.163.com/
阿里云源: http://mirrors.aliyun.com/
备份: mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载: 对应版本repo文件, 放入/etc/yum.repos.d/
生成缓存: yum clean all ; yum makecache

常用命令:

1. yum --version # 版本信息
2. yum install software_name # 安装包
3. yum search software_name # 搜索软件包
4. yum list # 列出本地安装的软件包
5. yum makecache fast # 生成本地缓存数据,在过期的时候会提示更新
6. yum remove software_name # 删除软件包

下载镜像说明,如图:http://mirrors.163.com/centos/7.5.1804/isos/x86_64/

CentOS各镜像说明

1. CentOS-7-x86_64-Everything-1804.iso 包含所有软件包

2. CentOS-7-x86_64-LiveGNOME-1804.iso 体验镜像

3. CentOS-7-x86_64-Minimal-1804.iso 最小化镜像

4. CentOS-7-x86_64-NetInstall-1804.iso 网络安装方式

没有网络的时候,还想用 yum 方式安装软件包,则需要下载 Everything 镜像;

在安装的时候只能安装此镜像中的软件包;以下是让yum使用本地镜像的方法:

 1、查看默认的光盘源配置 vi /etc/yum.repo.d/CentOS-Media.repo 此文件中的baseurl和源名字,需要记下
 Tips: 如果有多个光盘源,可以在此文件中如下配置:
 [c7-media] # 在安装的时候,需要用到这个名字
 name=CentOS-$releasever - Media
 baseurl=file:///media/CentOS/ # 镜像挂载的路径
 file:///media/cdrom/
 file:///media/cdrecorder/
 gpgcheck=1
 enabled=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 # 如果不需要gpgcheck,可让gpgcheck=0,然后注释掉最后一行即可。
 2、放入光盘,一般会在 /dev/cdrom 中,挂载光盘到第一步中看到的baseurl下:
 mount /dev/cdrom /media/cdrom
 3、如果需要做证书验证,则使用如下命令安装光盘源中的证书:
 rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #安装证书
 rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-beta
 4、清理、安装:
 yum clean all
 # 关闭其它所有库,根据名字启用指定的库
 yum --disablerepo=\* --enablerepo=c7-media install mysql

配置第三方源,格式如下,如果没有文件,则创建,注意保存文件的目录:

 vi /etc/yum.repo.d/nginx.repo
 # 安装这个源是使用到的名称
 [nginx]
 # 源的名称
 name=nginx repo
 # 源地址
 baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
 # 关闭证书验证
 gpgcheck=0
 # 启用此源
 enabled=1
 yum install nginx

help 参数说明:

yum --help
# 显示帮助信息
# 语法
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 Creates filesystem snapshots, or lists/deletes current snapshots.
# 创建文件系统快照 或者列出、删除当前快照
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
# 运行一个交互式的 yum shell
swap Simple way to swap packages, instead of using shell
# 使用交换包的简单方式来替换 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.
Options:
 -h, --help show this help message and exit
 -t, --tolerant be tolerant of errors
 # 出错继续
 -C, --cacheonly run entirely from system cache, don't update cache
 # 从系统缓存但不更新缓存运行命令
 -c [config file], --config=[config file] config file location
 # 指定配置文件
 -R [minutes], --randomwait=[minutes] maximum command wait time
 # 最大的等待时间
 -d [debug level], --debuglevel=[debug level] debugging output level
 # DEBUG输出等级
 --showduplicates show duplicates, in repos, in list/search commands
 # 在库、列表、搜索的时候显示重复结果
 -e [error level], --errorlevel=[error level] error output level
 # 错误输出
 --rpmverbosity=[debug level name] debugging output level for rpm
 # rpm 的DEBUG输出
 -q, --quiet quiet operation
 # 退出操作
 -v, --verbose verbose operation
 # 操作详情
 -y, --assumeyes answer yes for all questions
 # 为所有请求都回复 yes
 --assumeno answer no for all questions
 # 为所有请求都回复 no
 --version show Yum version and exit
 # 显示 yum 版本并退出
 --installroot=[path] set install root
 # 设置安装根目录
 --enablerepo=[repo] enable one or more repositories (wildcards allowed)
 # 开启库
 --disablerepo=[repo] disable one or more repositories (wildcards allowed)
 # 关闭库
 -x [package], --exclude=[package] exclude package(s) by name or glob
 # 通过名排除软件包
 --disableexcludes=[repo] disable exclude from main, for a repo or for everything
 # 关闭排除
 --disableincludes=[repo] disable includepkgs for a repo or for everything
 # 关闭包含的包
 --obsoletes enable obsoletes processing during updates #
 --noplugins disable Yum plugins
 # 关闭插件
 --nogpgcheck disable gpg signature checking
 # 不检查签名
 --disableplugin=[plugin] disable plugins by name
 # 通过名字关闭插件
 --enableplugin=[plugin] enable plugins by name
 # 通过名字启用插件
 --skip-broken skip packages with depsolving problems
 # 为解决问题跳过包
 --color=COLOR control whether color is used
 # 控制颜色输出
 --releasever=RELEASEVER set value of $releasever in yum config and repo files #
 --downloadonly don't update, just download
 # 只下载,不升级
 --downloaddir=DLDIR specifies an alternate directory to store packages
 # 指定安装包的下载目录
 --setopt=SETOPTS set arbitrary config and repo options #
 --bugfix Include bugfix relevant packages, in updates
 # 升级时,包含BUG修复包
 --security Include security relevant packages, in updates
 # 升级时,包含安装相关的包
 --advisory=ADVS, --advisories=ADVS Include packages needed to fix the given advisory, in updates #
 --bzs=BZS Include packages needed to fix the given BZ, in updates
 --cves=CVES Include packages needed to fix the given CVE, in updates
 --sec-severity=SEVS, --secseverity=SEVS Include security relevant packages matching the severity, in updates

相关推荐

0722-6.2.0-如何在RedHat7.2使用rpm安装CDH(无CM)

文档编写目的在前面的文档中,介绍了在有CM和无CM两种情况下使用rpm方式安装CDH5.10.0,本文档将介绍如何在无CM的情况下使用rpm方式安装CDH6.2.0,与之前安装C5进行对比。环境介绍:...

ARM64 平台基于 openEuler + iSula 环境部署 Kubernetes

为什么要在arm64平台上部署Kubernetes,而且还是鲲鹏920的架构。说来话长。。。此处省略5000字。介绍下系统信息;o架构:鲲鹏920(Kunpeng920)oOS:ope...

生产环境starrocks 3.1存算一体集群部署

集群规划FE:节点主要负责元数据管理、客户端连接管理、查询计划和查询调度。>3节点。BE:节点负责数据存储和SQL执行。>3节点。CN:无存储功能能的BE。环境准备CPU检查JDK...

在CentOS上添加swap虚拟内存并设置优先级

现如今很多云服务器都会自己配置好虚拟内存,当然也有很多没有配置虚拟内存的,虚拟内存可以让我们的低配服务器使用更多的内存,可以减少很多硬件成本,比如我们运行很多服务的时候,内存常常会满,当配置了虚拟内存...

国产深度(deepin)操作系统优化指南

1.升级内核随着deepin版本的更新,会自动升级系统内核,但是我们依旧可以通过命令行手动升级内核,以获取更好的性能和更多的硬件支持。具体操作:-添加PPAs使用以下命令添加PPAs:```...

postgresql-15.4 多节点主从(读写分离)

1、下载软件[root@TX-CN-PostgreSQL01-252software]#wgethttps://ftp.postgresql.org/pub/source/v15.4/postg...

Docker 容器 Java 服务内存与 GC 优化实施方案

一、设置Docker容器内存限制(生产环境建议)1.查看宿主机可用内存bashfree-h#示例输出(假设宿主机剩余16GB可用内存)#Mem:64G...

虚拟内存设置、解决linux内存不够问题

虚拟内存设置(解决linux内存不够情况)背景介绍  Memory指机器物理内存,读写速度低于CPU一个量级,但是高于磁盘不止一个量级。所以,程序和数据如果在内存的话,会有非常快的读写速度。但是,内存...

Elasticsearch性能调优(5):服务器配置选择

在选择elasticsearch服务器时,要尽可能地选择与当前业务量相匹配的服务器。如果服务器配置太低,则意味着需要更多的节点来满足需求,一个集群的节点太多时会增加集群管理的成本。如果服务器配置太高,...

Es如何落地

一、配置准备节点类型CPU内存硬盘网络机器数操作系统data节点16C64G2000G本地SSD所有es同一可用区3(ecs)Centos7master节点2C8G200G云SSD所有es同一可用区...

针对Linux内存管理知识学习总结

现在的服务器大部分都是运行在Linux上面的,所以,作为一个程序员有必要简单地了解一下系统是如何运行的。对于内存部分需要知道:地址映射内存管理的方式缺页异常先来看一些基本的知识,在进程看来,内存分为内...

MySQL进阶之性能优化

概述MySQL的性能优化,包括了服务器硬件优化、操作系统的优化、MySQL数据库配置优化、数据库表设计的优化、SQL语句优化等5个方面的优化。在进行优化之前,需要先掌握性能分析的思路和方法,找出问题,...

Linux Cgroups(Control Groups)原理

LinuxCgroups(ControlGroups)是内核提供的资源分配、限制和监控机制,通过层级化进程分组实现资源的精细化控制。以下从核心原理、操作示例和版本演进三方面详细分析:一、核心原理与...

linux 常用性能优化参数及理解

1.优化内核相关参数配置文件/etc/sysctl.conf配置方法直接将参数添加进文件每条一行.sysctl-a可以查看默认配置sysctl-p执行并检测是否有错误例如设置错了参数:[roo...

如何在 Linux 中使用 Sysctl 命令?

sysctl是一个用于配置和查询Linux内核参数的命令行工具。它通过与/proc/sys虚拟文件系统交互,允许用户在运行时动态修改内核参数。这些参数控制着系统的各种行为,包括网络设置、文件...

取消回复欢迎 发表评论: