内网搭建yum源
由于内网机器并不能直接连接到外网,这时安装软件可以通过自建
yum
源的方式来解决
1.实现方式
实现方式是使用
reposync
同步外网源的包到本地,然后通过createrepo
生成包的依赖关系,再通过Apache
发布,其他内网机器再配置该yum
源
2.安装所需软件
yum install httpd
yum install yum-utils
yum install createrepo
3.同步镜像
将需要需要同步的
yum
源先配置到能访问到外网机器上
配置阿里CentOS
源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
同步镜像到本地
reposync -r base -p /var/www/html/
reposync -r extras -p /var/www/html/
reposync -r updates -p /var/www/html/
4.生成依赖关系
createrepo -pdo /var/www/html/base/ /var/www/html/base/
createrepo -pdo /var/www/html/extras/ /var/www/html/extras/
createrepo -pdo /var/www/html/updates/ /var/www/html/updates/
5.内网机器配置该yum
源
# vim /etc/yum.repos.d/test.repo
[test_base]
name=test base yum
baseurl=http://搭建yum源机器的IP/base/
gpgcheck=0
enabled=1
[test_updates]
name=test updates yum
baseurl=http://搭建yum源机器的IP/updates/
gpgcheck=0
enabled=1
[test_extras]
name=test extras yum
baseurl=http://搭建yum源机器的IP/extras/
gpgcheck=0
enabled=1
6.其他
参考资料:
http://www.xiaomaidong.com/?p=793
解决方案二:代理