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