YUM Linux systems

02 YUM RPM package management tools

1.YUM Warehouse Management Software

yumIs based RPMpackage management, yumthe biggest advantage is that network to download the required rpmpackages can also be downloaded from the specified server RPMpackage is installed, and can automatically handle dependencies, and install all packages depending on, again and again without cumbersome downloads, installation.
yumProvides query, install, remove one, or all of a set of packages command, and command Introduction good memory. yumInstallation is the real production best practices

1. United ⽹ acquisition software
2. Management based RPM
movable automatically resolve dependencies 3.
4. easy to remember command
5. Best Practices yield ⽣

1.1YUM Global Configuration

#vim /etc/yum.conf
cachedir=/var/cache/yum/$basearch/$releasever  #缓存目录
keepcache=0     #缓存软件包,1 启动 0 关闭
debuglevel=2    #调试级别
logfile=/var/log/yum.log #日志记录位置
exactarch=1     #检查平台是否兼容
obsoletes=1     #检查包是否废弃
gpgcheck=1      #检查来源是否合法,需要有制作者的公钥信息
plugins=1       #是否启动查询
installonly_limit=5
bugtracker_url
distroverpkg=centos-release

1.2 Local drive source configuration YUM

Sometimes your linux system is not linked ⽹, of course, not very convenient with ⽹ Use the yum source, and this time you will need will benefit Using Your Own linux system CD production ⼀ a yum source. Specific steps are as follows:

1. mount the mirror

mount /dev/cdrom  /mnt/

2. Back up the original warehouse

cp -r /etc/yum.repos.d /etc/yum.repos.d.bak

3. Delete all of the source warehouse

rm -rf /etc/yum.repos.d/*

4. Create a new file repository, and add the following

# vim /etc/yum.repos.d/cdrom.repo
[repo_dev]
name=Local_centos
baseurl=file:#/mnt
enabled=1
gpgcheck=0

[]          #仓库名称 
name        #仓库描述信息
baseurl     #YUM源url地址 ,可以是file:# ftp:# http:# 
enabled     #是否激活该YUM源(0代表禁⽤,1代表激活,默认为激活) 
gpgcheck    #安装软件时是否检查签名(0代表禁⽤,1代表激活)

5. Refresh repos⽣ into buffer

yum makecache

1.3 Network Configuration source YUM

Open networks YUM official ⽅ source configuration
Ali mirror sites, Portal

The basic source: Base
extended source: epel
official source: nginx, zabbix ...

Base Basic source

// Base/Extras/Updates: 系统默认国外官⽅源 
[root@xmh ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo \
xmhhttp:#mirrors.aliyun.com/repo/Centos-7.repo

EPEL extended source

//国外epel源 
[root@xmh ~]# yum -y install epel-release

//阿⾥云epel源 
[root@xmh ~]# wget -O /etc/yum.repos.d/epel.repo \ 
http:#mirrors.aliyun.com/repo/epel-7.repo

Official sources
1. Edit the file to add repo Nginxrepo source

//所有源的查找⽅式基本⼀致,zabbix,mysql,saltstack,openstack
[root@xmh ~]# vim /etc/yum.repos.d/nginx.repo 
[nginx] 
name=nginx repo 
baseurl=http:#nginx.org/packages/centos/7/$basearch/ 
gpgcheck=0 
enabled=1

2. Use rpm installed Zabbixrepo source

https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

//使用rpm安装会自动将安装包中的已打包好的zabbix的repo文件进行安装

Red Hat warehouse configuration Centos 1.4

Open networks Red Hat source Redhat7 Alternatively Centos7

//1.卸载红帽yum源 
rpm -e $(rpm -qa|grep yum) --nodeps

//2.删除所有repo相关⽂件 
rm -rf /etc/yum.conf 
rm -rf /etc/yum.repos.d/ 
rm -rf /var/cache/yum

//3.下载centos相关yum组件
wget https:#mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget https:#mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm 
wget https:#mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
wget https:#mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-50.el7.noarch.rpm
wget https:#mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm

#如果没有wget命令则使⽤curl命令
curl -o yum-3.4.3-161.el7.centos.noarch.rpm https:#mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
curl -o yum-metadata-parser-1.1.4-10.el7.x86_64.rpm  https:#mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm 
curl -o yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm https:#mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
curl -o yum-updateonboot-1.1.31-50.el7.noarch.rpm https:#mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-50.el7.noarch.rpm
curl -o yum-utils-1.1.31-50.el7.noarch.rpm https:#mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm

3.安装所有相关组件
[root@xmh ~]# rpm -ivh *.rpm

4.下载base和epel仓库 
//base源,来自阿里云
wget -O /etc/yum.repos.d/CentOS-Base.repo http:#mirrors.aliyun.com/repo/Centos-7.repo 
sed -i 's#\$releasever#7#g' /etc/yum.repos.d/CentOS-Base.repo

//epel源,来自阿里云
wget -O /etc/yum.repos.d/epel.repo http:#mirrors.aliyun.com/repo/epel-7.repo

5.刷新repos⽣成缓存
yum makecache

2.YUM order management software

2.1 Search Package Instruction

//列出软件仓库中可⽤的软件 
[root@xmh ~]# yum list

//进⾏模糊查找 
[root@xmh ~]# yum list|grep ftp

//列出软件包详情 
[root@xmh ~]# yum info ftp 

2.2 installation package instructions

//安装软件只需要给出软件名称 
[root@xmh ~]# yum install traceroute

//安装过程中分析依赖关系后,直接安装,⽆需交互 
[root@xmh ~]# yum install php -y

//安装本地的rpm包, 如果有依赖关系, 会⾃动从软件仓库中下载所需依赖(⾮来⾃.repo定义的软件仓库) 
[root@xmh ~]# yum localinstall /mnt/Packages/bind-9.9.4-50.el7.x86_64.rpm

//安装⽹络上rpm包 
[root@xmh ~]# yum install http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

2.3 reinstall the package instructions

//检查软件是否存在 
[root@xmh ~]# rpm -q vsftpd 
vsftpd-2.2.2-24.el6.x86_64

//检查vsftpd软件配置⽂件 
[root@xmh ~]# rpm -qc vsftpd 
/etc/logrotate.d/vsftpd 
/etc/pam.d/vsftpd 
/etc/vsftpd/ftpusers 
/etc/vsftpd/user_list 
/etc/vsftpd/vsftpd.conf

//不⼩⼼删除vsftpd配置⽂件 
[root@xmh ~]# rm -f /etc/vsftpd/vsftpd.conf

//重新安装软件 
[root@xmh ~]# yum reinstall vsftpd

//再次检查 
[root@xmh ~]# rpm -qc vsftpd 
/etc/logrotate.d/vsftpd 
/etc/pam.d/vsftpd 
/etc/vsftpd/ftpusers 
/etc/vsftpd/user_list 
/etc/vsftpd/vsftpd.conf

2.4 update package instructions

//对⽐Linux已安装的软件和yum仓库中的软件, 有哪些需要升级 
[root@xmh ~]# yum check-update

//更新软件(不建议) 
[root@xmh ~]#yum update acl -y

2.5 remove the package instructions

//先安装⼀个samba软件 
[root@xmh ~]# yum install samba -y

//删除该软件包, 不会删除依赖, 但是我们尽可能不要使⽤删除软件操作 
[root@xmh ~]# yum erase samba -y 
[root@xmh ~]# yum remove samba -y

2.6 warehouse related instructions

//列出yum源可⽤的软件仓库 
[root@xmh ~]# yum repolist

//列出全部yum源可⽤和禁⽤的仓库 
[root@xmh ~]# yum repolist all

//查看这个⽂件或命令属于哪个包 yum provides
/etc/my.cnf yum provides cd

2.7 cache-related instruction

//缓存yum源软件仓库, xml元数据⽂件 
[root@xmh ~]# yum makecache

//缓存软件包, 修改yum全局配置⽂件 
[root@xmh ~]# vim /etc/yum.conf 
[main] 
cachedir=/var/cache/yum/$basearch/$releasever 
keepcache=1 #启动缓存 

//查看缓存的xml⽂件 
[root@xmh ~]# ls /var/cache/yum/x86_64/7/base/ 

//查看缓存软件包路径 
[root@xmh ~]# /var/cache/yum/x86_64/7/

//另⼀种缓存rpm包⽅式 

//1.安装插件⽀持只下载软件包不安装 
[root@xmh ~]# yum install -y yum-plugin-downloadonly 

//2.将软件下载⾄指定⽬录 (系统已安装的包则无法下载)
[root@xmh ~]# yum install httpd -y --downloadonly --downloaddir=/tmp

//清除所有yum缓存 
[root@xmh ~]# yum clean all 

//只清除缓存的软件包 
[root@xmh ~]# yum clean packages

2.8 Related command packet group

//列出已经安装和所有可使⽤的软件组 
[root@xmh ~]# yum groups list

//安装⼀整个组的软件 
[root@xmh ~]# yum groups install Development tools \ 
Compatibility libraries \ 
Base Debugging Tools

//yum删除包组
[root@xmh ~]# yum groups remove-y Base

2.9 History command

//查看历史执⾏yum命令 
[root@xmh ~]# yum history

//查询历史执⾏yum命令ID详细信息 
[root@xmh ~]# yum history info N

//撤销历史执⾏过的yum命令 
[root@xmh ~]# yum history undo N

3. Build yum warehouse

Local CD-ROM provide basic packages Base
yum caches provide updatepackages
yum caches provide frequently-used software packages: nginx, zabbix, docker,saltstack

Preparing the Environment

system IP Roles CPU name
centos7.4 10.0.0.171 yum repository server yum_server_171
centos7.4 10.0.0.172 yum repository server yum_client_172

Server configuration
1. basic environment ready

//关闭防⽕墙
[root@yum_server_171 ~]# systemctl stop firewalld

//临时关闭selinux
[root@yum_server_171 ~]# setenforce 0

//安装ftp服务,启动并加⼊开机启动
[root@yum_server_171 ~]# yum  install vsftpd -y
[root@yum_server_171 ~]# systemctl start vsftpd
[root@yum_server_171 ~]# systemctl enable vsftpd

//开启yum缓存功能
[root@yum_server_171 ~]# vim /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1
debuglevel=2

[root@yum_server_171 ~]# yum clean all

2. Provide basic basesource

//创建一个用于存放基础base的rpm包目录
[root@yum_server_171 ~]# mkdir /var/ftp/{centos69,centos74} -p

//挂载IOS镜像并拷贝该镜像中的rpm包至存放目录
[root@yum_server_171 ~]# mount /dev/cdrom /mnt 
[root@yum_server_171 ~]# cp -rp /mnt/Packages/*.rpm /var/ftp/centos74/

3. Provide third ⽅ source

//创建一个用于存放第三放源的rom包目录
[root@yum_server_171 ~]# mkdir /var/ftp/ops 

//下载第三方rpm包
[root@yum_server_171 ~]# yum -y install nginx docker zabbix-agent  zabbix-server-mysql salt-mastet salt-minion 

//复制已缓存的 Nginx docker 及依赖包等,到⾃定义 YUM 仓库⽬录中 
[root@yum_server_171 ~]# find /var/cache/yum/x86_64/7/ -iname "*.rpm" -exec cp -rf {} /var/ftp/ops/ \;

4. Install createrepoand create a repowarehouse

//安装createrepo 
[root@yum_server_171 ~]# yum -y install createrepo 

//⽣成仓库信息 
[root@yum_server_171 ~]# createrepo /var/ftp/ops
[root@yum_server_171 ~]# createrepo /var/ftp/centos74

注意: 如果此仓库每次新增软件包则需要重新⽣成⼀次

5. In the browser input ftp://10.0.0.171/, the ftp access to the content (subject to the actual address)

Using yum client source
1. Back up the original warehouse

[root@yum_client_172 ~]# gzip /etc/yum.repos.d/*

Configuration and use a basebase source

[root@yum_client_172 ~]# vim /etc/yum.repos.d/centos7.repo
[centos74] 
name=centos74_base 
baseurl=ftp://10.0.0.171/centos74 
gpgcheck=0

3. The client points to a local opssource

[root@yum_client_172 ~]# vim /etc/yum.repos.d/ops.repo
[ops]
name=ops_repo
baseurl=ftp://10.0.0.171/ops
gpgcheck=0

4. Client Installation yum

[root@yum_client_172 ~]# yum install salt-minion -y

Guess you like

Origin www.cnblogs.com/jasonminghao/p/12310392.html