需求: 局域网搭建一个 管理 yum 源的服务器,这样局域网的电脑不要联网就可以直接yum install
步骤
第一部分:nexus 服务端配置
第1步: 安装 nexus
nexus安装(linux安装 nexus) : 连接
第2步: 界面配置 nexus
10.0.0.202:8081 admin admin123
(1) 选择 create repository
(2) 选择 yum (proxy)
(3)配置阿里云镜像站
http://mirrors.aliyun.com/centos/
然后点击下边的 的创建
这样配置 本地没有可以取阿里云镜像站拉取
(4) 新建 yum 公共仓库组
下边的配置要用到这个2个名字
(5)Nexus 开启匿名访问
第二部分:局域网 其他机器的配置
(1)下载 阿里云yum源配置文件
http://mirrors.aliyun.com/repo/Centos-7.repo
先备份本地的
cd /etc/yum.repos.d
mkdir bak
mv CentOS-* bak/
下载:
wget http://mirrors.aliyun.com/repo/Centos-7.repo
修改这里边的文件, 把相关的URL 改成我们自己 nexus 服务器的地址
这里我已经修改了,大家把名字成 CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://10.0.0.202:8081/repository/baimeidashu-public/$releasever/os/$basearch/
gpgcheck=0
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://10.0.0.202:8081/repository/baimeidashu-public/$releasever/updates/$basearch/
gpgcheck=0
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://10.0.0.202:8081/repository/baimeidashu-public/$releasever/extras/$basearch/
gpgcheck=0
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://10.0.0.202:8081/repository/baimeidashu-public/$releasever/centosplus/$basearch/
gpgcheck=0
enabled=0
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://10.0.0.202:8081/repository/baimeidashu-public/$releasever/contrib/$basearch/
gpgcheck=0
enabled=0
然后 放入到:
我已经把 文件给上传到云盘了,需要的朋友可以下载:
nexus: https://url69.ctfile.com/d/253469-56163475-117455?p=2206 (访问密码: 2206)
mv CentOS-Base.repo.nexus_yum CentOS-Base.repo
这样本地的 yum仓库 就配置好了,接下来再配置一下nexus 的权限
(2) 测试
我们先 执行一下命令:
yum clean all && yum makecache
我们来尝试安装 以下
安装前看看 中央仓库里
yum install tree -y
再回到 nexus 界面看看
到此为止,我们的本地的中央 Yum 仓库已经下载完了
如果有相关的依赖,也会自动的下载完成的。