当前位置: 移动技术网 > 科技>操作系统>Linux > centos 下创建本地镜像源,结合 nginx

centos 下创建本地镜像源,结合 nginx

2019年06月30日  | 移动技术网科技  | 我要评论

1. 创建同步文件

参考清华的centos源,配置同步文件。 

[root@localhost centos]# cat centos-repo.conf
[base]
name=centos-$releasever - base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7

#released updates
[updates]
name=centos-$releasever - updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7

#additional packages that may be useful
[extras]
name=centos-$releasever - extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7

#additional packages that extend functionality of existing packages
[centosplus]
name=centos-$releasever - plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=0
enabled=0
#gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7

2. 同步源到本地文件夹(此文件夹需要结合nginx 配置成网络可访问的文件服务器:)

[root@localhost centos]# reposync -c centos-repo.conf 

3. 创建 repo 

cd $i && createrepo .

4. 定时同步

crontab -e
1 2 * * * /usr/bin/reposync -np /home/centos

5. 重新配置镜像地址

本方法的一个例子,可以参考

参考链接:

 

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网