HTTP方式
安装步骤
系统:CentOS 7.6
yum install -y httpd
vi /etc/httpd/conf/httpd.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
allow from all
</Directory>
1、下载yum源镜像文件
CentOS官网:https://www.centos.org/download/
点击DVD ISO,选择其中一个版本
2、将下载好的镜像通过winscp或xshell等工具传到需要部署yum源的服务器上。
3、挂载镜像
mount /home/CentOS-7-x86_64-DVD-1908.iso /home/temp
4、将挂载盘内的文件复制到本地新建目录中
mkdir -p /var/www/html/centos_iso
cp -r /home/temp/* /var/www/html/centos_iso
5、将yum源仓库里的repo文件进行备份(因为要覆盖这些文件,要养成备份的好习惯)
mkdir /etc/yum.repos.d/bak20200422
mv /etc/yum.repos.d/* /etc/yum.repos.d/bak20200422
6、重新编辑CentOS-Media.repo文件
cp /etc/yum.repos.d/bak20200422/CentOS-Media.repo /etc/yum.repos.d/
vim /etc/yum.repos.d/CentOS-Media.repo
[centos_iso]
name=centos_iso
baseurl=file:///var/www/html/centos_iso
baseurl=http://192.168.80.131/var/www/html/centos_iso
gpgcheck=1
enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
7、卸载镜像
umount /home/temp
8、此时使用yum list命令就能显示所有已经安装和可以安装的程序包
URL: http://192.168.80.131/centos_iso
9、然后验证即可
yum clean all
yum makecache
测试:
本机:yum install gawk-4.0.2-4.el7_3.1.x86_64.rpm
远程机:wget http://192.168.80.131/centos_iso/Packages/gawk-4.0.2-4.el7_3.1.x86_64.rpm
rpm -ivh xxx.rpm
FTP方式
使用centos镜像作为yum源
【挂载CentOS-7-x86_64-DVD-1810.iso】
[root@service ~]# mount -o loop /dev/sr0 /mnt/cdrom
[root@service ~]# mkdir /opt/centos
[root@service ~]# cp -rvf /mnt/* /opt/centos/
[root@service ~]# umount /mnt/
搭建service本地yum源
在/etc/yum.repos.d创建centos.repo源文件(原有文件建议删除)
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
测试service本地yum源
yum clean all
yum repolist
例如:
[root@service~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name status
centos centos 4,021
iaas iaas 1,688
repolist: 5,709
service NODE安装FTP服务
[root@service ~]# yum install vsftpd –y
[root@service ~]# vi /etc/vsftpd/vsftpd.conf
添加anon_root=/opt/
保存退出
[root@service ~]# systemctl start vsftpd
[root@service ~]# systemctl enable vsftpd
关闭service防火墙或者配置iptables
此时只介绍将防护墙关闭,为了方便
systemctl stop firewalld
systemctl disable firewalld
配置computer 节点yum源文件
在/etc/yum.repos.d创建centos.repo源文件
[centos]
name=centos
baseurl=ftp://192.168.100.10/centos
gpgcheck=0
enabled=1
测试computer node yum 源情况
yum clean all
yum list
[root@compute ~]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
centos | 3.6 kB 00:00
iaas | 2.9 kB 00:00
(1/3): centos/group_gz | 166 kB 00:00
(2/3): centos/primary_db | 3.1 MB 00:00
(3/3): iaas/primary_db | 2.3 MB 00:00
源标识 源名称 状态
centos centos 4,021
iaas iaas 1,688
repolist: 5,709