本地yum源
本地yum源,是将本地的镜像或者是将本地的某个文件夹当做自己的仓库来使用的,但是不同的是将镜像当做仓库用时,是需要挂载的。将文件当做仓库是就无须挂载:
以root目录下的CentOS-7-x86_64-DVD-1511.iso 镜像作为yum源来源,配置yum源,挂载点为/opt/centos 目录,挂载后出现mounting read-only表示挂载成功,就可以使用yum命令安装其他服务了
[root@haochou ~]# ll
total 6747408
-rw-------. 1 root root 1341 Dec 10 2019 anaconda-ks.cfg
-rw-r--r--. 1 root root 4329570304 Feb 26 2018 CentOS-7-x86_64-DVD-1511.iso
drwxr-xr-x. 3 root root 12288 Dec 10 2019 lnmp
[root@haochou ~]# cat /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[root@haochou ~]# mkdir /opt/centos
[root@haochou ~]# echo /root/CentOS-7-x86_64-DVD-1511.iso /opt/centos iso9660 defaults 0 0 >> /etc/fstab
[root@haochou ~]# mount -a
mount: /dev/sr0 is write-protected, mounting read-only
以虚拟机创建时的镜像文件作为yum源来源,配置yum源,挂载点同样为/opt/centos
[root@haochou ~]# cat /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[root@haochou ~]# mkdir /opt/centos
[root@haochou ~]# echo /dev/cdrom /opt/centos iso9660 defaults 0 0 >> /etc/fstab
[root@haochou ~]# vi /etc/fstab
[root@haochou ~]# mount -a
mount: /dev/sr0 is write-protected, mounting read-only
以本机中的lnmp文件来做yum源的来源,配置好yum源就可以使用,无需挂载。
[root@haochou ~]# ll
total 6747408
-rw-------. 1 root root 1341 Dec 10 2019 anaconda-ks.cfg
-rw-r--r--. 1 root root 4329570304 Feb 26 2018 CentOS-7-x86_64-DVD-1511.iso
drwxr-xr-x. 3 root root 12288 Dec 10 2019 lnmp
[root@haochou ~]# cat /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=file:///root/lnmp
gpgcheck=0
enabled=1
远程yum源
远程yum源又称为ftp源,就是通过vsftpd服务来是本地无镜像和包的虚拟机来远程使用有镜像的虚拟机的镜像。
虚拟机haochou的IP 为192.168.100.11 为有镜像的;虚拟机haomei的IP为192.168.100.12
[root@haomei ~]# cat /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=ftp://192.168.100.11/centos
gpgcheck=0
enabled=1
在虚拟机haochou上安装vsftpdf服务,首先要保证自己的yum源没有问题才可以。
安装完成后再进入vsftpd安装文件里设置共享目录,
[root@haochou ~]# yum install -y vsftpd
[root@haochou ~]# cat /etc/vsftpd/vsftpd.conf
# Example config file /etc/vsftpd/vsftpd.conf
anon_root=/opt/ ##添加这行
#
[root@haochou ~]# systemctl restart vsftpd
[root@haochou ~]# systemctl enable vsftpd
网络yum源
对于网络yum源,就是先安装httpd服务,然后联通外网,在网络上下载一个包,将它挂在在自己的目录下,进行挂载,确保与外网的联通。思路是这样的。