本文章只适合初学者,勿喷
实验适用于 5 .6. 7 版本
实验是在虚拟机上进行的
1.
挂载光盘
LINUX 7 启动服务 启动之后在根目录下就会有一个misc 的文件夹
systemctl status autofs
systemctl start autofs
systemctl enable autofs
2.将/etc/yum.repo.d/ 目录下的文件移动到其他文件夹
mkdir /data
mv *.repo /data
3.创建以.repo为后缀的文件并编辑
vim yum.repo
【1 [cdrom] 仓库名只能是字母和数字 不能有空格
【2 name=httpdyum 不加 是可以使用的不过会提示 Repository 'cdrom' is missing name in configuration, using id
【 3 baseurl=file:///misc/cd 仓库路径
【4 gpgcheck=0 关闭密钥检查 如果导入密钥 不用写这一行 因为默认值为1 。
linux 5 路径
baseurl=file:///misc/cd/Server/
******************************************************
yum 的路径一定是 repodata 目录的父目录
5. 测试 yum repolist
[19:55:[email protected]]#yum repolist
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
cdrom | 3.6 kB 00:00:00
(1/2): cdrom/group_gz | 166 kB 00:00:00
(2/2): cdrom/primary_db | 5.9 MB 00:00:00
repo id repo name status
cdrom httpdyum 9,911
repolist: 9,911
[19:55:[email protected]]#
.................................................................................................................................................
....................................................................................................................................................
对于初学者来说以上的配置就足够用了 如果仍然有兴趣的话往下看
基于远程的网络yum服务器搭建
1.首先 搭建 http服务
yum -y install httpd 或者
[20:37:06-root@cenos7/]#rpm -ivh /misc/cd/Packages/httpd-2.4.6-80.el7.centos.x86_64.rpm
..................................................................................................................................................
2查看可启用的服务
[20:42:00-root@cenos7/]#rpm -ql httpd | grep .*.service
/usr/lib/systemd/system/htcacheclean.service
/usr/lib/systemd/system/httpd.service
...................................................................................................................................................
3启动服务 并开机自启
systemctl start httpd.service
systemctl enable httpd.service
...........................................................................................................................................................
4.仿照yum源网站 创建目录
mkdir /var/www/html/centos/{6,7}/os/x86_64/ -pv
添加新光驱
lsblk
让系统认识新的磁盘,并能对其分区与格式化
1、在开机状态下新增磁盘
2、执行下面的命令
echo '- - -' > /sys/class/scsi_host0/host2/scan
----------------------------------------------------------------------------------------------------------------------------
[01:16:06-root@cenos7html]#echo '- - -'> /sys/class/scsi_host/host0/scan
[01:16:54-root@cenos7html]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 49G 0 part
├─centos-root 253:0 0 47G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sr0 11:0 1 8.8G 0 rom /var/www/html/centos/7/os/x86_64
sr1 11:1 1 3.7G 0 rom
[01:16:58-root@cenos7html]#
[01:16:58-root@cenos7html]#mount /dev/sr1 /var/www/html/centos/6/os/x86_64/
mount: /dev/sr1 is write-protected, mounting read-only
5.配置防火墙
初学者关闭防护墙
关闭防火墙:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
或者配置访问规则
6. 测试
7.挂载 或者将文件下载到对应目录
[21:37:14-root@cenos7html]#mount /dev/sr0 /var/www/html/centos/7/os/x86_64/
mount: /dev/sr0 is write-protected, mounting read-only
![1.png](https://upload-images.jianshu.io/upload_images/13365442-3be0f7a0c026e50f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
9. 测试
【1.测试网络连通性
【2.配置客户机
vim /etc/yum.repo.d/aa.repo
[test]
2 name=httpyum
3 baseurl=http://192.168.117.128/centos/7/os/x86_64/
4 gpgcheck=0
[3..
[15:55:[email protected]]#yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
源标识 源名称 状态
test httpyum 9,911
repolist: 9,911
...........................................................................................................................................................
yum 扩展
yum 中的变量
$releasever: 当前OS的发行版的主版本号
$arch: 平台,i386,i486,i586,x86_64等
$basearch:基础平台;i386, x86_64
例 :
test]
name=httpyum
baseurl=http://192.168.117.128/centos/$releasever/os/$arch/
gpgcheck=0
.......................................................................................................................................................
yum密钥验证方法
[test]
name=httpyum
baseurl=http://192.168.117.128/centos/$releasever/os/$arch/
gpgcheck=1
gpgkey=http://192.168.117.128/centos/$releasever/os/$arch/RPM-GPG-KEY-Cent
OS-Testing-7
..................................................................................................................................................
yum 的 配置文件
/etc/yum.conf:为所有仓库提供公共配置
/etc/yum.repos.d/*.repo:为仓库的指向提供配置
仓库指向的定义:
[repositoryID]
name=Some name for this repository
baseurl=url://path/to/repository/
enabled={1|0}
gpgcheck={1|0}
gpgkey=URL
enablegroups={1|0}
failovermethod={roundrobin|priority}
roundrobin:意为随机挑选,默认值
priority:按顺序访问
cost= 默认为1000
.......................................................................................................................................................