情景: 为内网主机搭建 yum 源,且 yum 源同步 外网的源服务器。
同步 yum
源
同步本地 yum
源有三种方式
1、 wget
方式
2、 reposync
方式
3、 raync
方式 (源站点需要支持 rsync)
# yum 源的同步站点
# http://centos.ustc.edu.cn/centos/
# 查看源列表
[root@WJ110 yum]# rsync --list-only rsync://rsync.mirrors.ustc.edu.cn/centos/6/os/x86_64/
_______________________________________________________________
| University of Science and Technology of China |
| Open Source Mirror (mirrors.ustc.edu.cn) |
|===============================================================|
| |
| Debian primary mirror in China mainland (ftp.cn.debian.org), |
| also mirroring a great many OSS projects & Linux distros. |
| |
| Currently we don\'t limit speed. To prevent overload, Each IP |
| is only allowed to start upto 2 concurrent rsync connections. |
| |
| This site also provides http/https/ftp access. |
| |
| Supported by USTC Network Information Center |
| and USTC Linux User Group (http://lug.ustc.edu.cn/). |
| |
| Sync Status: https://mirrors.ustc.edu.cn/status/ |
| News: https://servers.ustclug.org/ |
| Contact: lug@ustc.edu.cn |
| |
|_______________________________________________________________|
drwxrwxr-x 536 2017/09/20 01:35:53 .
-rw-r--r-- 33 2017/03/29 02:19:52 .discinfo
-rw-r--r-- 364 2017/03/29 02:19:49 .treeinfo
-rw-r--r-- 14 2017/03/29 02:05:42 CentOS_BuildTag
-rw-rw-r-- 212 2013/11/27 17:36:04 EULA
-rw-rw-r-- 18009 2013/11/27 17:36:04 GPL
-rw-rw-r-- 1359 2017/03/28 23:53:39 RELEASE-NOTES-en-US.html
-rw-rw-r-- 1706 2013/11/27 17:36:04 RPM-GPG-KEY-CentOS-6
-rw-rw-r-- 1730 2013/11/27 17:36:04 RPM-GPG-KEY-CentOS-Debug-6
-rw-rw-r-- 1730 2013/11/27 17:36:04 RPM-GPG-KEY-CentOS-Security-6
-rw-rw-r-- 1734 2013/11/27 17:36:04 RPM-GPG-KEY-CentOS-Testing-6
drwxr-xr-x 72 2017/03/29 02:19:05 EFI
drwxr-xr-x 383320 2017/09/20 01:40:29 Packages
drwxr-xr-x 192 2017/04/03 18:30:12 images
drwxr-xr-x 312 2017/04/03 18:30:13 isolinux
drwxr-xr-x 928 2017/04/06 01:02:54 repodata
# 同步到本地
[root@WJ110 yum]# rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/os/x86_64/ /data/yum/centos/6/os/x86_64/
[root@WJ110 yum]# rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/extras/x86_64/ /data/yum/centos/6/extras/x86_64/
[root@WJ110 yum]# rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/centos/6/updates/x86_64/ /data/yum/centos/6/updates/x86_64/
[root@WJ110 yum]# rsync -avrt rsync://rsync.mirrors.ustc.edu.cn/epel/6/x86_64/ /data/yum/epel/6/x86_64/
...
...
配置 nginx
注: 打开目录浏览功能
server {
listen 80;
server_name localhost;
location / {
root /data/yum;
autoindex on; # 打开目录浏览功能
autoindex_exact_size off; # 显示出文件的大概大小,单位是kB或者MB或者GB
autoindex_localtime on; # 显示的文件时间为文件的服务器时间
}
}
重启 nginx
,访问地址,可以访问到 /data/yum/
下的目录列表
修改 yum.repo
文件
只需修改地址部分即可,如下:
[base]
name=CentOS-6 - Base - local.com
baseurl=http://172.18.50.110/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://172.18.50.110/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6 - Updates - local.com
baseurl=http://172.18.50.110/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://172.18.50.110/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - local.com
baseurl=http://172.18.50.110/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://172.18.50.110/centos/RPM-GPG-KEY-CentOS-6
...
...
...
网友评论