局域网环境搭建YUM仓库

一、搭建YUM 仓库必要性

① 企业内部服务器比较多的情况下,如果是在每台服务器上都搭建一个YUM 源的方式来使用的话增加后期的管理和维护工作.

② 如果使用的是网络YUM源, 虽然可以不用在每台服务器上都搭建YUM源, 但同样有两点问题.

    a) 网络YUM源提供的软件包一般都比较新, 新的不一定是最合适的。

    b) 考虑到安全方面,服务器一般情况下都不能上外网。


二、YUM仓库搭建

① 将光盘放入光驱,如图:

② 挂载光驱到 /mnt 目录下

[root@www ~]# mount | grep /mnt                                       # 挂载前查看
[root@www ~]# mount /dev/cdrom /mnt                                   # 光驱挂载到 /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@www ~]# 
[root@www ~]# 
[root@www ~]# mount | grep /mnt                                       # 挂载后查看
/dev/sr0 on /mnt type iso9660 (ro)

③ 创建FTP共享目录,并将光盘里的文件全部拷贝到共享目录下

[root@www ~]# mkdir  -p  /var/ftp/pub/iso/rhel6.5                # 创建 共享目录
[root@www ~]# cp -r /mnt/* /var/ftp/pub/iso/rhel6.5/             # 拷贝光盘文件到共享目录
[root@www ~]# ls /var/ftp/pub/iso/rhel6.5/                       # 查看拷贝后的共享目录
EFI      EULA_ja           isolinux                  RELEASE-NOTES-de-DE.html  RELEASE-NOTES-ja-JP.html  RELEASE-NOTES-pt-BR.html  repodata
EULA     EULA_ko           LoadBalancer              RELEASE-NOTES-en-US.html  RELEASE-NOTES-kn-IN.html  RELEASE-NOTES-ru-RU.html  ResilientStorage
EULA_de  EULA_pt           media.repo                RELEASE-NOTES-es-ES.html  RELEASE-NOTES-ko-KR.html  RELEASE-NOTES-si-LK.html  RPM-GPG-KEY-redhat-beta
EULA_en  EULA_zh           Packages                  RELEASE-NOTES-fr-FR.html  RELEASE-NOTES-ml-IN.html  RELEASE-NOTES-ta-IN.html  RPM-GPG-KEY-redhat-release
EULA_es  GPL               README                    RELEASE-NOTES-gu-IN.html  RELEASE-NOTES-mr-IN.html  RELEASE-NOTES-te-IN.html  ScalableFileSystem
EULA_fr  HighAvailability  RELEASE-NOTES-as-IN.html  RELEASE-NOTES-hi-IN.html  RELEASE-NOTES-or-IN.html  RELEASE-NOTES-zh-CN.html  Server
EULA_it  images            RELEASE-NOTES-bn-IN.html  RELEASE-NOTES-it-IT.html  RELEASE-NOTES-pa-IN.html  RELEASE-NOTES-zh-TW.html  TRANS.TBL
[root@www ~]#

④ 启动共享服务, 并将共享服务设置成开机启动

[root@www ~]# service vsftpd status                    # 查看 FTP 服务的状态
vsftpd 已停
[root@www ~]# service vsftpd start                     # 启动 FTP 服务
为 vsftpd 启动 vsftpd:                                    [确定]
[root@www ~]# chkconfig --list vsftpd                  # 查看 FTP 服务的自启
vsftpd         	0:关闭	1:关闭	2:关闭	3:关闭	4:关闭	5:关闭	6:关闭
[root@www ~]# chkconfig  vsftpd on                     # 将 FTP 服务设置成开机自启
[root@www ~]# chkconfig --list vsftpd
vsftpd         	0:关闭	1:关闭	2:启用	3:启用	4:启用	5:启用	6:关闭
[root@www ~]# 

⑤ 关闭防火墙, 并将防火墙的开机设置成关闭状态

[root@www ~]# service iptables stop                        # 关闭防火墙
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:清除防火墙规则:                                 [确定]
iptables:正在卸载模块:                                   [确定]

[root@www ~]# chkconfig --list iptables
iptables       	0:关闭	1:关闭	2:启用	3:启用	4:启用	5:启用	6:关闭
[root@www ~]# chkconfig  iptables off                      # 关闭防火墙开机自启
[root@www ~]# chkconfig --list iptables
iptables       	0:关闭	1:关闭	2:关闭	3:关闭	4:关闭	5:关闭	6:关闭
[root@www ~]# 

⑥ 打开浏览器 输入 ftp://ip地址( 这里用的是 ftp://192.168.174.151/) 来验证一下


三、配置YUM 客户端

[root@localhost ~]# cat /etc/yum.repos.d/rhel-source.repo 
[redhat-6.5]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=ftp://192.168.174.151/pub/iso/rhel6.5/                    # 指定 FTP 共享路径
enabled=1                                                         # 1表示开启 
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[root@localhost ~]# yum clean                                     # 清理 缓存
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Error: clean requires an option: headers, packages, metadata, dbcache, plugins, expire-cache, rpmdb, all
[root@localhost ~]# yum repolist                                  # 查看当前可用的仓库
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id                                                                 repo name                                                                                                        status
redhat-6.5                                                              Red Hat Enterprise Linux 6Server - x86_64 - Source                                                               3,690
repolist: 3,690                                                   # 软件包数量
[root@localhost ~]# 

猜你喜欢

转载自blog.csdn.net/u010559460/article/details/87918823