1、软件安装: yum -y install yum-utils createrepo plugin-priorities
yum-utils:reposync同步工具
createrepo:编辑yum库工具
plugin-priorities:控制yum源更新优先级工具,这个工具可以用来控制进行yum源检索的先后顺序,建议可以用在client端。
2、安装nginx:yum –y install Nginx
3、修改nginx配置文件:/etc/nginx/nginx.conf
4、先把yum库移走先: mkdir /repo && mv /etc/yum.repos.d/* /repo
5、建议aliyun yum库:
wget -O /etc/yum.repos.d/CentOS-Base.repo http:
//mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/CentOS-epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
6、刷新缓存
yum clean all
yum makecache
7、yum repolist
[root@localhost yum.repos.d]# yum repolist
已加载插件:fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
仓库标识仓库名称状态
baseCentOS-6 - Base - mirrors.aliyun.com6,706
extras CentOS-6 - Extras - mirrors.aliyun.com 46
updates CentOS-6 - Updates - mirrors.aliyun.com 826
repolist: 7,778
8、
nginx的html目录:/usr/share/nginx/html/
9、建立rpm库存放目录:mkdir -p /usr/share/nginx/html/Aliyun/CentOS/7/64bit/{base,extras,updates}
10、开始同步下载rpm包:reposync -p /usr/share/nginx/html/Aliyun/CentOS/7/64bit
11、建库:cd /usr/share/nginx/html/Aliyun/CentOS/7/
cd base && createrepo -p ./ && cd -
cd extras && createrepo -p ./ && cd -
cd updates && createrepo -p ./ && cd -
12、其他服务器连接YUM仓库:
vim /etc/yum.repos.d/test.repo
[base]
name=CentOS-Base(GDS)
baseurl=http://10.63.215.7/Aliyun/CentOS/7/64bit/base
path=/
enabled=1
gpgcheck=0
[updates]
name=CentOS-Updates(GDS)
baseurl=http://10.63.215.7/Aliyun/CentOS/7/64bit/updates
path=/
enabled=1
gpgcheck=0
[extras]
name=CentOS-Extras(GDS)
baseurl=http://10.63.215.7/Aliyun/CentOS/7/64bit/extras
path=/
enabled=1
gpgcheck=0
13、建立定时同步,每周一的3点同步:
crontab -e
0 3 * * 1
/usr/bin/reposync -np /usr/share/nginx/html/Aliyun/CentOS/7/64bit
资料信息取之于:https://www.cnblogs.com/juandx/p/6136621.html
https://blog.csdn.net/u012402276/article/details/53158682
https://www.cnblogs.com/music378/p/7993318.html