nexus 代理 yum 源

环境说明

服务 ip 端口 备注
nexus 192.168.80.129 (内网) 8081 内网地址无法访问外网
nginx

192.168.80.128 (内网)

192.168.174.126 (外网)

19000 192.168.174.126 地址可以访问外网

创建 Blob Stores

创建 Repositories

nginx 配置

server {
    listen       19000;
    server_name  localhost;

    # 设置代理访问日志
    access_log  logs/yum.access.log ;
    error_log  logs/yum.error.log ;

    location /centos {
        proxy_pass https://mirrors.aliyun.com;
    }
}

CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
baseurl=http://192.168.80.129:8081/repository/aliyun-yum-repo/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
baseurl=http://192.168.80.129:8081/repository/aliyun-yum-repo/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://192.168.80.129:8081/repository/aliyun-yum-repo/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://192.168.80.129:8081/repository/aliyun-yum-repo/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

构建 yum 缓存

yum clean all && yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                                                                                                                                    | 2.2 kB  00:00:00     
extras                                                                                                                                                  | 1.5 kB  00:00:00     
updates                                                                                                                                                 | 1.5 kB  00:00:00     
Metadata Cache Created

安装软件

yum -y install lrzsz
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 0:0.12.20-36.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================
 Package                                Arch                                    Version                                            Repository                             Size
===============================================================================================================================================================================
Installing:
 lrzsz                                  x86_64                                  0.12.20-36.el7                                     base                                   78 k

Transaction Summary
===============================================================================================================================================================================
Install  1 Package

Total download size: 78 k
Installed size: 181 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/lrzsz-0.12.20-36.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY       ]  0.0 B/s |    0 B  --:--:-- ETA 
Public key for lrzsz-0.12.20-36.el7.x86_64.rpm is not installed
lrzsz-0.12.20-36.el7.x86_64.rpm                                                                                                                         |  78 kB  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-9.2009.1.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : lrzsz-0.12.20-36.el7.x86_64                                                                                                                                 1/1 
  Verifying  : lrzsz-0.12.20-36.el7.x86_64                                                                                                                                 1/1 

Installed:
  lrzsz.x86_64 0:0.12.20-36.el7                                                                                                                                                

Complete!

查看 Repositories 状态

查看 Browse

参考文档

https://help.sonatype.com/en/yum-repositories.html#proxying-yum-repositories

posted @ 2024-03-28 08:32  小吉猫  阅读(245)  评论(0编辑  收藏  举报