@
1. yum常用命令
1.1 安装卸载服务
- 安装
- 升级
- 卸载
谨慎使用,因为依赖会被卸载。一般使用以下命令卸载:
- 清空缓存
- 只下载不安装
# yum install -y xxx --downloadonly --downloaddir=/usr/local/src
1.2 查看
- 查看yum库
- 列出所有包
- 查看包信息
- 查看文件所在包
# yum provides /usr/bin/scp
1.3 包组的使用
和包的使用基本相同:
# yum grouplist
# yum groupinstall xxx
2. 指定yum源
示例如下:
# vim /etc/yum.repos.d/test.repo
[test]
name=test
enabled=1
gpgcheck=0
# baseurl=file:///data/ftp/yum_data
# baseurl=ftp://172.16.8.100/centos6u6
baseurl=http://yumcto.xxx.com.cn/ #http的yum源示例
说明:
[test]
:仓库ID,有唯一性,根据需求自定义
name=test
: 仓库名
enabled=1
: 1,激活该仓库
gpgcheck=0
: 0,不检查软件包签名
3. 常用yum源
1)epel源
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
2)163源
# curl -o /etc/yum.repos.d/CentOS-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
# wget -O /etc/yum.repos.d/CentOS-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
3)阿里源
# wget -O /etc/yum.repos.d/CentOS-Base-ali.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# curl -o /etc/yum.repos.d/CentOS-Base-ali.repo http://mirrors.aliyun.com/repo/Centos-7.repo
4)清华源
# CentOS-Base.repo
#
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# remarked out baseurl= line instead.
#
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever &arch =$basearch &repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever &arch =$basearch &repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever &arch =$basearch &repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever &arch =$basearch &repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
4. yum的一些操作
4.1 yum缓存的配置
[main]
cachedir=/var/cache/yum #yum下载的RPM包的缓存目录
keepcache=0 #缓存是否保存,1保存,0不保存。
debuglevel=2 #调试级别(0-10),默认为2(并不知道具体作用)。
logfile=/var/log/yum.log #yum的日志文件所在的位置
exactarch=1 #在更新的时候,是否允许更新不同版本的RPM包,比如是否在i386上更新i686的RPM包。
obsoletes=1 #相当于upgrade,允许更新陈旧的RPM包。
gpgcheck=1 #是否检查GPG(GNU Private Guard),一种密钥方式签名。
plugins=1 #是否允许使用插件,默认是0不允许,但是我们一般会用yum-fastestmirror这个插件。
installonly_limit=3 #允许保留多少个内核包。
exclude=selinux* #屏蔽不想更新的RPM包,可用通配符,多个RPM包之间使用空格分离
metadata_expire=90m #设定保存时长
4.2 yum设置代理
# vim /etc/yum.conf
proxy=http://代理服务器ip:port
5.FAQ
1)Transaction check error
Transaction check error:
file /usr/bin/docker from install of docker-ce-18.06.0.ce-3.el7.x86_64 conflicts with file from package docker-ce-cli-1:19.03.8-3.el7.x86_64
file /usr/share/bash-completion/completions/docker from install of docker-ce-18.06.0.ce-3.el7.x86_64 conflicts with file from package docker-ce-cli-1:19.03.8-3.el7.x86_64
rpm -e docker-ce-cli-1:19.03.8-3.el7.x86_64
yum install docker-ce-18.06.0.ce-3.el7.x86_64
2)关于镜像不可用
root@node-02:[/root]yum install docker-ce -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#56 - "Proxy CONNECT aborted"
正在尝试其它镜像。
.............
failure: repodata/repomd.xml from docker-ce-stable: [Errno 256] No more mirrors to try.
https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#56 - "Proxy CONNECT aborted"
安装的时候会提示没有密钥,选择YES密钥会自动被安装。
从 https://mirrors.aliyun.com/docker-ce/linux/centos/gpg 检索密钥
导入 GPG key 0x621E9F35:
用户ID : "Docker Release (CE rpm) <docker@docker.com>"
指纹 : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
来自 : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
是否继续?[y/N]:y
从 http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
指纹 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
来自 : http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-7
是否继续?[y/N]:y
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2021-11-17 01-函数简单使用