文章目录
一、yum概述
yum是一个基于RPM包构建的软件更新机制,能够自动解决软件包之间的依赖关系。
1.yum
基于RPM包构建的软件更新机制
可以自动解决依赖关系
所有软件包由集中的YUM软件仓提供
2.yum工具管理软件包
CentOS发布的RPM包集合
第三方组织发布的RPM包集合
用户自定义的RPM包集合
3.软件仓库的提供方式
网络源
FTP服务: ftp://…
HTTP服务: http://…
本地源
本地目录: file://…
二、yum配置文件及命令
1.主配置文件
/etc/yum.conf
2.仓库设置文件
/etc/yum.repos.d/ *.repo
3.日志文件
cat /var/log/yum.log
三.yum命令详解
1.查询软件包
yum list [软件名]
yum info [软件名]
yum search <关键字>
yum whatprovides <关键字>
2.查询软件包组
yum grouplist [包组名]
yum groupinfo <包组名>
3.安装软件
yum install [软件名]
yum groupinstall <包组名>
4.升级软件
yum updae
yum groupupdate
5.卸载软件
yum remove 软件名
yum groupremove <包组名>
四.搭建仓库
1.搭建本地yum仓库
[root@localhost ~]# mount /dev/sr0 /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 50G 4.8G 46G 10% /
devtmpfs devtmpfs 897M 0 897M 0% /dev
tmpfs tmpfs 912M 0 912M 0% /dev/shm
tmpfs tmpfs 912M 9.0M 903M 1% /run
tmpfs tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/mapper/centos-home xfs 47G 33M 47G 1% /home
/dev/sda1 xfs 1014M 179M 836M 18% /boot
tmpfs tmpfs 183M 8.0K 183M 1% /run/user/42
tmpfs tmpfs 183M 0 183M 0% /run/user/0
/dev/sr0 iso9660 4.3G 4.3G 0 100% /mnt
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo
CentOS-Debuginfo.repo CentOS-Sources.repo
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv *.repo bak/
[root@localhost yum.repos.d]# ls
bak
[root@localhost yum.repos.d]# vim ttt.repo
[centos]
name=ttt
baseurl=file:///mnt
enabled=1
gpgcheck=0
[root@localhost yum.repos.d]# yum -y install --downloadonly --downloaddir=/data/bind bind
vim ttt.repo
2.搭建阿里云仓库
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv *.repo bak/
[root@localhost yum.repos.d]# ls
bak
[root@localhost yum.repos.d]# vim ali.repo
[ali]
name=aliyun
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=0
[epel]
name=epel
baseurl=https://mirrors.aliyun.com/centos/7/extras/x86_64/
gpgcheck=0
[update]
name=update
baseurl=https://mirrors.aliyun.com/centos/7/updates/x86_64/
gpgcheck=0
3.ftp方式搭建云仓库
服务端:192.168.68.30
客户端:192.168.68.105
[root@localhost ~]# yum install -y vsftpd.x86_64
[root@localhost ~]# cd /var/ftp/
[root@localhost ftp]# ls
pub
[root@localhost ftp]# mkdir centos7 other
[root@localhost ftp]# ls
centos7 other pub
[root@localhost ftp]# mount /dev/sr0 /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ftp]# cp -rf /mnt/* ./centos7/ &
[1] 2031
[root@localhost ftp]# cd centos7/
[root@localhost centos7]# ls
CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packages
[root@localhost centos7]# cd /var/ftp/other/
[1]+ 完成 cp -i -rf /mnt/* ./centos7/(工作目录:/var/ftp)
(当前工作目录:/var/ftp/other)
[root@localhost other]# createrepo -g /mnt/repodata/repomd.xml ./
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl start vsftpd
[root@localhost ~]# netstat -ntap |grep ftp
tcp6 0 0 :::21 :::* LISTEN 2850/vsftpd
服务端
客户端
[root@localhost yum.repos.d]# setenforce 0
[root@localhost yum.repos.d]# systemctl stop firewalld.service
[root@localhost yum.repos.d]# yum install -y ftp
[root@localhost yum.repos.d]# ftp 192.168.187.150
Connected to 192.168.68.30 (192.168.187.150).
220 (vsFTPd 3.0.2)
Name (192.168.187.150:root): ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,68,30,168,125).
150 Here comes the directory listing.
drwxr-xr-x 8 0 0 220 Oct 04 09:42 centos7
drwxr-xr-x 3 0 0 22 Oct 04 09:43 other
drwxr-xr-x 2 0 0 6 Jun 09 16:15 pub
226 Directory send OK.
ftp> cd centos7
250 Directory successfully changed.
ftp> ls
227 Entering Passive Mode (192,168,68,30,37,56).
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 14 Oct 04 09:41 CentOS_BuildTag
drwxr-xr-x 3 0 0 35 Oct 04 09:41 EFI
-rw-r--r-- 1 0 0 227 Oct 04 09:41 EULA
-rw-r--r-- 1 0 0 18009 Oct 04 09:41 GPL
drwxr-xr-x 2 0 0 43 Oct 04 09:41 LiveOS
drwxr-xr-x 2 0 0 217088 Oct 04 09:42 Packages
-rw-r--r-- 1 0 0 1690 Oct 04 09:42 RPM-GPG-KEY-CentOS-7
-rw-r--r-- 1 0 0 1690 Oct 04 09:42 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r-- 1 0 0 2883 Oct 04 09:42 TRANS.TBL
drwxr-xr-x 3 0 0 57 Oct 04 09:41 images
drwxr-xr-x 2 0 0 198 Oct 04 09:41 isolinux
drwxr-xr-x 2 0 0 4096 Oct 04 09:42 repodata
226 Directory send OK.
[root@localhost yum.repos.d]# vim centos7.repo
[centos7]
name=centos7
baseurl=ftp://192.168.187.150/centos7
enabled=1
gpgcheck=0
[other]
name=other
baseurl=ftp://192.168.187.150/other
enabled=1
gpgcheck=0
[root@localhost yum.repos.d]# yum clean all
[root@localhost yum.repos.d]# yum repolist
[root@localhost yum.repos.d]# yum install -y dhcp
[root@localhost yum.repos.d]# vim centos7.repo