一、yum远程仓库的部署
- yum(Yellow dog Updater modified)最初是由TSS公司(Terra Soft Solutions,INNC)使用Python语言开发而成。
- 借助于YUM软件仓库,可以完成安装、卸载、自动升级rpm包等任务,能够自动查找并解决rpm包之间的依赖关系,无需逐个、手工的去安装每一个rpm包。
1.1 准备网络安装源
- 使用YUM机制来更新系统和软件,需要有一个包含各种rpm包文件的软件仓库,提供软件仓库的也被叫做“源”服务器。
- yum仓库三种构建方式
FTP服务:ftp://…………
HTTP服务:http://…………
本地目录:file://………… - RPM软件包的来源
CentOS发布的RPM包集合
第三方组织发布的RPM包集合
用户自定义的RPM包集合 - 配置软件仓库位置(客户机端):
配置文件:/etc/yum.repo.d/*.repo
直接以CentOS 7光盘作软件仓库,将CentOS7光盘放入光驱
指定仓库位置,URL地址为file:///media/cdrom
1.2 实验过程
1.2.1 挂载光盘
[root@text01 ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@text01 ~]# 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/sr0 iso9660 4.3G 4.3G 0 100% /mnt
/dev/sda1 xfs 1014M 179M 836M 18% /boot
tmpfs tmpfs 378M 8.0K 378M 1% /run/user/42
tmpfs tmpfs 378M 52K 378M 1% /run/user/0
1.2.2 进入服务器站点,将镜像复制到文件夹
[root@text01 var]# ls ## 发现var里面没有ftp服务
account cache db games kerberos local log nis preserve spool tmp
adm crash empty gopher lib lock mail opt run target yp
[root@text01 var]# yum -y install vsftpd ## 安装vsftpd服务
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* extras: mirrors.ustc.edu.cn
* updates: mirrors.ustc.edu.cn
[root@text01 var]# ls ## 发现FTP站点
account cache db ftp gopher lib lock mail opt run target yp
adm crash empty games kerberos local log nis preserve spool tmp
[root@text01 var]# cd ftp/
[root@text01 ftp]# ls
pub
[root@text01 ftp]# mkdir centos7.6
[root@text01 ftp]# cp -rf /mnt/* centos7.6/ & ## 在后台复制
[1] 10510
[root@text01 ftp]# jobs
[1]+ 运行中 cp -i -rf /mnt/* centos7.6/ &
[root@text01 ftp]# mkdir other ## 创建扩展服务文件夹
[root@text01 ftp]# createrepo -g /mnt/repodata/repomd.xml other/ ## 以现有的repodata目录为样板,创建repodata数据文件(用于用户搜集非光盘自带的其他软件包,必须包括存在依赖关系的所有安装文件)
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@text01 other]# ls repodata/
01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2
12bbefc88e08f473cf860b4c150a9a8627f68eb256c9d54b80940e5dc224e85c-repomd.xml.gz
401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz
5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2
6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz
7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2
cdcb85c0e4daf1675d1ab6c42b0cacc6f9460d938296f7bf52678514a86a0554-repomd.xml
dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz
repomd.xml
1.2.3 开启vsftpd服务
[root@text01 other]# systemctl start vsftpd ## 开启服务
[root@text01 other]# netstat -natp | grep 21 ## 21端口负责连接服务器
tcp6 0 0 :::21 :::* LISTEN 10668/vsftpd
[root@text01 other]# netstat -natp | grep 20 ## 20端口负责上传和下载 ,未进行上传和下载,所以看不到服务
[root@text01 other]# systemctl stop firewalld.service ## 关闭防火墙
[root@text01 other]# setenforce 0 ## 关闭核心防护
1.2.4 客户端安装ftp
[root@text02 ~]# yum -y install ftp
[root@text02 ~]# ftp 192.168.233.200 ## ftp 登录
Connected to 192.168.233.200 (192.168.233.200).
220 (vsFTPd 3.0.2)
Name (192.168.233.200:root): ftp ## 匿名登录 随便输入
331 Please specify the password.
Password: ## 匿名服务,没有密码直接回车
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
1.2.5 客户端yum配置文件全部存入bak中
[root@text02 ~]# cd /etc/yum.repos.d/
[root@text02 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@text02 yum.repos.d]# mkdir bak
[root@text02 yum.repos.d]# mv *.repo bak
1.2.6 客户端清空缓存,自己写一个repo文件,并将秘钥复制到其中
[root@text01 centos7.6]# ls ##服务端查看密钥 RPM-GPG-KEY-CentOS-7 便是密钥
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
[root@text02 yum.repos.d]# vim centos7.6.repo ## 创建 centos7.6.repo 进入编辑
[base]
name=centos7.6.Packages
baseurl=ftp://192.168.233.200/centos7.6
enabled=1
gpgcheck=1
gpgkey=ftp://192.168.233.200/centos7.6/RPM-GPG-KEY-CentOS-7
[other]
name=other.Packages
baseurl=ftp://192.168.233.200/other
enabled=1
gpgcheck=0
[root@text02 yum.repos.d]# yum clean all ## 编辑完成后wq保存退出 清除yum缓存
[root@text02 yum.repos.d]# yum list ## 重新获取yum 此时已经可以正常使用了
- yum update 更新软件包,连内核一起更新
- yum upgrade 只更新软件包,但不更新内核
二、NFS网络文件系统
- 依赖于RPC(远端过程调用)
- 需安装nfs-utils、rpcbind软件包
- 系统服务:nfs、rpcbind(远程过程调用)
- 共享配置文件:/etc/exports
2.1 实验过程
服务端配置
[localhost ~]# fdisk /dev/sdb # 划分磁盘 全部默认就行
[localhost ~]# mkfs.xfs -t /dev/sdb ## 格式化并修改格式为xfs
[localhost ~]# mount /dev/sdb /mnt/ ## 挂载到/mnt目录上
yum intasll nfs-utils、rpcbind -y
[localhost ~]vim /etc/exports
/mnt 192.168.233.0/24(rw,sync,no_root_squash) ## rw可读写,sync同步功能,no_root_squash远程使用不会降低权限,默认会降级)
systemctl stop firewalld.service ## 关闭防火墙
setenforce 0 ## 关闭核心防护
systemctl start rpcbind ## 启动rpcbind服务
systemctl start nfs ## 启动nfs服务
[root@localhost ~]# showmount -e ## 查看共享的情况
Export list for localhost.localdomain:
/mnt 192.168.233.0/24
客户端配置
yum intasll nfs-utils、rpcbind -y
- 关闭防火墙 核心防护 永久启动rpcbind、nfs服务
systemctl stop firewalld.service ## 关闭防火墙
setenforce 0 ## 关闭核心防护
systemctl enable nfs
systemctl enable rpcbind
[root@localhost centos7]# showmount -e 192.168.233.200
Export list for 192.168.233.200:
/mnt 192.168.233.0/24
[root@localhost centos7]# vim /etc/fstab
192.168.233.200:/mnt /var/www/html nfs defaults,_netdev 0 0 ##自动挂载
mount 192.168.233.200:/mnt /var/www/html ##手动挂载
yum -y httpd install
[root@localhost centos7]# cd /var/www/html/
[root@localhost html]# vim index.html
<h1>this is wangliwei</h1>
systemctl restart httpd ## 启动服务
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200713104121388.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NzIxOTcyNQ==,size_16,color_FFFFFF,t_70)
[root@localhost ~]# ls /mnt
index.html ## 发现客户端创建的index.html 文件