用来访问yum仓库,查询,下载及安装卸载软件包
Yum update 既更新软件包,同时更新系统内核
Yum upgrade 只更新软件包
Yum install 软件包 —安装
Yum remove 软件包 —卸载
Yum list —查看软件列表
Yum clean all —清理缓存
Yum info 软件包 —查看软件包详细信息
Yum whatprovides 文件或目录 ----查看文件或者目录归属于哪个软件包安装的
yum grouplist 包组名
yum groupinfo 包组名
挂载光盘
[root@localhost yum.repos.d]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 296G 4.0G 292G 2% /
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 1.9G 13M 1.9G 1% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 973M 179M 795M 19% /boot
tmpfs tmpfs 378M 4.0K 378M 1% /run/user/42
tmpfs tmpfs 378M 24K 378M 1% /run/user/0
/dev/sr0 iso9660 4.3G 4.3G 0 100% /mnt ##光盘挂载
移走原来的yum源
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@localhost yum.repos.d]# mkdir aa
[root@localhost yum.repos.d]# mv *.repo aa
[root@localhost yum.repos.d]# ls
aa
[root@localhost yum.repos.d]# yum -y install httpd
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
To enable Red Hat Subscription Management repositories:
subscription-manager repos --enable
To enable custom repositories:
yum-config-manager --enable ##yum仓库没了,安装不了软件包
重新写入本地yum仓库
vim new.repo
[base]
name=base
baseurl=file:///mnt
enabled=1
gpgcheck=0
yum clean all
yum list
[root@localhost yum.repos.d]# yum -y install httpd #测试可以安装
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-88.el7.centos 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-88.el7.centos,它被软件包 httpd-2.4.6-88.el7.centos.x86_64 需要
--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-88.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 httpd-tools.x86_64.0.2.4.6-88.el7.centos 将被 安装
---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=============================================================================================
Package 架构 版本 源 大小
=============================================================================================
正在安装:
httpd x86_64 2.4.6-88.el7.centos base 2.7 M
为依赖而安装:
httpd-tools x86_64 2.4.6-88.el7.centos base 90 k
mailcap noarch 2.1.41-2.el7 base 31 k
事务概要
=============================================================================================
安装 1 软件包 (+2 依赖软件包)
总下载量:2.8 M
安装大小:9.6 M
Downloading packages:
---------------------------------------------------------------------------------------------
总计 81 MB/s | 2.8 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : mailcap-2.1.41-2.el7.noarch 1/3
正在安装 : httpd-tools-2.4.6-88.el7.centos.x86_64 2/3
正在安装 : httpd-2.4.6-88.el7.centos.x86_64 3/3
验证中 : httpd-tools-2.4.6-88.el7.centos.x86_64 1/3
验证中 : mailcap-2.1.41-2.el7.noarch 2/3
验证中 : httpd-2.4.6-88.el7.centos.x86_64 3/3
已安装:
httpd.x86_64 0:2.4.6-88.el7.centos
作为依赖被安装:
httpd-tools.x86_64 0:2.4.6-88.el7.centos mailcap.noarch 0:2.1.41-2.el7
完毕!
[root@localhost ~]# mount /dev/sr0 /mnt
[root@localhost /]# yum -y install vsftp* ##安装vsftp包
[root@localhost /]# cd /var
[root@localhost var]# ls
account cache db ftp gopher lib lock mail opt run target www
adm crash empty games kerberos local log nis preserve spool tmp yp
[root@localhost var]# cd ftp
[root@localhost ftp]# ls
pub
[root@localhost ftp]# mkdir centos7 ##创建一个放仓库的文件夹
[root@localhost ftp]# cp -rf /mnt/* /var/ftp/centos7/ & #复制软件包到ftp仓库
[root@localhost ftp]# mkdir other
[root@localhost ftp]# createrepo -g /mnt/repodata/repomd.xml other/ #建立yum索引环境
[root@localhost ftp]# systemctl start vsftpd #开启ftp服务
客户端配置
[root@localhost ~]# yum -y install ftp #测试访问ftp服务
[root@localhost ~]#ftp 192.168.100.20
[root@localhost ~]#vim abc.repo #配置repo仓库文件
[base]
name=centos7
baseurl=ftp://192.168.100.20/centos7
enabled=1
gpgcheck=1
gpgkey=ftp://192.168.100.20/centos7/RPM-GPG-KEY-CentOS-7
[other]
name=other.Packages
baseurl=ftp://192.168.200.20/other
enabled=1
gpgcheck=0
[root@localhost yum.repos.d]# yum -y install httpd #测试可以安装
[root@localhost opt]# mkdir wwwroot
[root@localhost opt]# vim /etc/exports
/opt/wwwroot 192.168.197.171(rw,sync,no_root_squash)
[root@localhost opt]# vim /etc/fstab
192.168.197.171:/opt/wwwroot /var/www/html nfs defaults,_netdev 0 0
服务端:
[root@localhost ~]# df -Th ##添加一块硬盘作共享
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 295G 4.1G 291G 2% /
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 1.9G 13M 1.9G 1% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 179M 836M 18% /boot
tmpfs tmpfs 378M 4.0K 378M 1% /run/user/42
tmpfs tmpfs 378M 24K 378M 1% /run/user/0
/dev/sr0 iso9660 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64
/dev/sdb1 xfs 20G 33M 20G 1% /mnt
[root@localhost /]# setenforce 0
[root@localhost /]# iptables -F ## 关闭防火墙
[root@localhost /]# yum -y install rpcbind nfs-utils ##安装两个相关的软件包
[root@localhost /]# vim /etc/exports ##写入共享配置文文件
/mnt 192.168.20.0/24(rw,sync,no_root_squash) ##允许哪个网段可以查看共享的空间
[root@localhost /]# systemctl start nfs-utils ##开启两个服务
[root@localhost /]# systemctl start rpcbind
[root@localhost /]# systemctl enable nfs-utils
[root@localhost /]# systemctl enable rpcbind
[root@localhost /]# showmount -e ##查看提供的服务
Export list for localhost.localdomain:
/mnt 192.168.20.0/24
客户端:
[root@localhost ~]#yum -y install httpd #安装一个apache服务做实验
[root@localhost ~]# setenforce 0 ##关闭防火墙
[root@localhost ~]# iptables -F
[root@localhost ~]# mount 192.168.20.20:/mnt /var/www/html ##将共享空间挂载到要用的服务目录里面(也就是做实验的apache文件) 手动挂载
[root@localhost ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 295G 4.1G 291G 2% /
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 1.9G 13M 1.9G 1% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 179M 836M 18% /boot
tmpfs tmpfs 378M 36K 378M 1% /run/user/0
/dev/sr0 iso9660 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64
192.168.20.20:/mnt nfs4 20G 32M 20G 1% /var/www/html ##查看,已经挂载
[root@localhost www]# vim /etc/fstab
/dev/mapper/centos-root / xfs defaults 0 0
UUID=451ccd23-f0c9-4858-9910-bdb53cff4e48 /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
192.168.20.20:/mnt /var/www/html nfs defaults,_netdev 0 0 ##自动挂载
[root@localhost www]# mount -a
[root@localhost www]# cd /var/www/html #写一个网页验证
[root@localhost html]# ls
[root@localhost html]# vim index.html
text01...web
[root@localhost html]# systemctl start httpd ##开启httpd服务
[root@localhost /]# cd /mnt ##回到服务端 查看客户端写的一个网页文件
[root@localhost mnt]# ls
index.html
[root@localhost mnt]# cat index.html
text01...web
用浏览器打开客户端写的网页即可看到网页