本篇主要寫了怎麼搭建自定義的 YUM 源,在一個擁有大量本地網路的主機環境中,可以減少對外網的依賴。 ...
本篇主要寫了怎麼搭建自定義的YUM
源,在一個擁有大量本地網路的主機環境中,可以減少對外網的依賴。
Server
安裝 vsftp 包
[root@server ~]# yum install vsftpd -y
添加相關資源包
- 創建需要存放的目錄
[root@server ~]# mkdir /var/ftp/centos7 /var/ftp/others
[root@server ~]# ls /var/ftp/
centos7 others pub
- 拷貝鏡像文件內容至相關目錄
[root@server ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@server ~]# cp -r /mnt/* /var/ftp/centos7/
- 給
others
目錄創建repodata
[root@server ~]# createrepo -g /var/ftp/centos7/repodata/repomd.xml /var/ftp/others/
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
- 檢查文件是否齊全
[root@server ~]# ls /var/ftp/centos7/
CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packages repodata RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-CentOS-Testing-7 TRANS.TBL
[root@server ~]# ls /var/ftp/others/
repodata
開啟服務
[root@server ~]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
[root@server ~]# systemctl start vsftpd
[root@server ~]# netstat -ntuap | grep vsftpd
tcp6 0 0 :::21 :::* LISTEN 35971/vsftpd
關閉防火牆
[root@server ~]# systemctl stop firewalld
[root@server ~]# setenforce 0
Client
安裝 ftp 包
[root@client ~]# yum install ftp -y
匿名登錄查看
[root@client ~]# ftp 192.168.28.128
Connected to 192.168.28.128 (192.168.28.128).
220 (vsFTPd 3.0.2)
Name (192.168.28.128:root): ftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,28,128,255,56).
150 Here comes the directory listing.
drwxr-xr-x 8 0 0 2048 Sep 05 2017 centos7
drwxr-xr-x 3 0 0 22 Sep 16 19:42 others
drwxr-xr-x 2 0 0 6 Oct 30 2018 pub
226 Directory send OK.
ftp> bye
221 Goodbye.
編輯 YUM 源配置文件
- 備份已有
yum
源
[root@client ~]# cd /etc/yum.repos.d/
[root@client yum.repos.d]# mkdir bak
[root@client yum.repos.d]# mv *.repo bak/
- 編輯自定義
yum
源
[root@client yum.repos.d]# vim ftp.repo
[base]
name=centos7.Packages
baseurl=ftp://192.168.28.128/centos7/
enabled=1
gpgcheck=1
gpgkey=ftp://192.168.28.128/centos7/RPM-GPG-KEY-CentOS-7
[others]
name=others.Packages
baseurl=ftp://192.168.28.128/others/
enabled=1
gpgcheck=0
查看結果
[root@client ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base others
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@client ~]# yum list