大佬教程收集整理的这篇文章主要介绍了搭建CentOS在线yum源镜像服务器,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
说明:
操作系统:CentOS 6.7
rsync版本:3.0.6
IP地址和端口:192.168.3.100:8080
目标:同步CentOS镜像站点的内容到此服务器,通过配置http服务器,提供yum服务
一、准备:
1).安装http服务器
请参照Nginx 安装
2).Nginx配置
#vi/usr/local/Nginx/conf/Nginx.conf
server {
listen 8080;
server_name localhost;
root /var/repos/;
autoindexon;
autoindex_exact_size off;
autoindex_localtime on;
}
}
#serviceNginxreload
3).系统目录规划
Centos的Base源目录: /var/repos/centos
Centos的Base源目录: /var/repos/extras
Centos的Base源目录: /var/repos/updates
Centos的epel源目录: /var/repos/epel
4).基础软件包安装
#yum-yinstallcreaterepo #yum-yinstallrsync
二、安装:
1).创建镜像文件存放目录
#mkdir-p/var/repos/centos #mkdir-p/var/repos/extras #mkdir-p/var/repos/updates #mkdir-p/var/repos/epel
2).确定以上yum源上游源同步镜像地址
参考官方源:
CentOS官方标准源:
http://mirror.centos.org/centos/6.7/
中科大yum源:
rsync://mirrorS.Ustc.edu.cn/centos/6.7/os/x86_64/Packages/
rsync://mirrorS.Ustc.edu.cn/centos/6.7/updates/
rsync://mirrorS.Ustc.edu.cn/centos/6.7/extras/x86_64/Packages/
epel源:
http://mirrors.fedoraproject.org/publiclist/EPEL/
rsync://mirrors.kernel.org/fedora-epel
中科大epel源:
rsync://mirrorS.Ustc.edu.cn/epel/6/x86_64/
备注:上游yum源必须要支持rsync协议,否则不能使用rsync进行同步(国内的源很多不支持,这里选用中科大yum源)。
列出各个源下面的软件包
#rsync--list-onlyrsync://rsync.mirrorS.Ustc.edu.cn/centos/6.7/os/x86_64/Packages/ #rsync--list-onlyrsync://rsync.mirrorS.Ustc.edu.cn/centos/6.7/updates/x86_64/Packages/ #rsync--list-onlyrsync://rsync.mirrorS.Ustc.edu.cn/centos/6.7/extras/x86_64/Packages/ #rsync--list-onlyrsync://rsync.mirrorS.Ustc.edu.cn/epel/6/x86_64/
3).创建以上yum源同步脚本,并且设定脚本自动执行
备注:运行此脚本前,先要创建好同步目录及不需要同步的目录列表文件
#cd/var/repos
上传同步脚本到该目录下
#chmod+xrsync_yum.sh
4).添加脚本定时执行任务
#vi/etc/crontab
0 1 * * * root /home/crontab/yum_rsync.sh
#servicecrondrestart
三、测试:
2).执行同步脚本
#sh/home/crontab/yum_rsync.sh
注意:等待脚本执行完毕,首次同步,耗费的时间比较长!
3).安装createrepo工具,创建yum源的repo配置文件
#yum-yinstallcreaterepo #cd/etc/yum.repos.d/#进入目录 #mv/etc/yum.repos.d/CentOS-Base.repoCentOS-Base.repo-bak #vi/etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-Base(GDS)
baseurl=http://192.168.3.100/centos
path=/
enabled=0
[updates]
name=CentOS-updates(GDS)
baseurl=http://192.168.3.100/updates
path=/
enabled=1
[extras]
name=CentOS-Extras(GDS)
baseurl=http://192.168.3.100/extras
path=/
enabled=1
#vi/etc/yum.repos.d/epel.repo
[epel]
name=EPEL(GDS)
baseurl=http://192.168.3.100/epel
path=/
enabled=1
4).测试yum源是否配置正确
a).清除当前yum缓存
#yumcleanall
@L_801_22@
列出yum源中可用的软件包
#yumrepolist
b).使用yum命令安装软件
测试CentOS-Base源
#yuminstallPHP
测试epel源
#yuminstallNginx
至此,搭建CentOS在线yum源镜像服务器完成!
以上是大佬教程为你收集整理的搭建CentOS在线yum源镜像服务器全部内容,希望文章能够帮你解决搭建CentOS在线yum源镜像服务器所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。