使用场景
测试环境中存在大量的centos7服务器资源。其之间相互可访问。但无法联网。在部署或安装其他资源时,极为不便。
解决思路&方案
选择一台可上网的机器作为代理服务器,而后在其它无法上网的服务器中配置上网代理。其代理地址为所选择的可上网的机器。
具体实现
代理服务器上设定
- 相关参考文档
- 安装实施
- 安装Squid
yum install Squid -y- 修改配置文件
vim /etc/squid/squid.conf- 将文件中的
http_access deny all修改为http_access allow all - 查看Squid 的默认端口
3128是否已经被占用。如果占用修改其默认端口
netstat -tlnp | grep 3128- 启动Squid 服务
systemctl start squid
设定代理上网
- 修改配置文件
vim /etc/profile
- 配置文件中设定代理服务器信息
export http_proxy='http://ip:port'
export https_proxy='https://ip:port'
- 退出文件使得文件生效
source /etc/profile
- 验证上网代理是否配置成功
curl http://www.baidu.com
设定yum 代理上网
- 修改配置文件
vim /etc/yum.conf
- 设定代理信息
proxy=http://ip:prot
- 退出保存
- 文件改修生效
source /etc/yum.conf
配置yum镜像
- 查看当前的yum 源
yum repolist
- 查看yum的文件
#/ect 目录下
ls | grep yum*
- 进入目录
yum.repo.d - 先备份
CentOS-Base.repo
mv CentOS-Base.repo CentOS-Base.repo.bak
- 获取阿里云的镜像文件
wget -O /etc/yum.repos.d/CentOS-Base.repo <http://mirrors.aliyun.com/repo/Centos-7.repo>
6.清空yum 缓存
yum clean all
yum makecache
7.下载elpl-release库
yum install -y epel-release
# 运行后,生成文件
epel.repo