服务端配置
操作系统redhat 8.8
bash
yum install -y java-11-openjdk java-11-openjdk-devel
useradd nexus
passwd nexus
su - nexus
tar -xvf nexus-3.54.1-01-unix.tar.gz
# 编辑 Nexus 的运行用户
vim /home/nexus/nexus-3.54.1-01/bin/nexus.rc
run_as_user="nexus"
exit
# 创建 systemd 服务文件
vim /etc/systemd/system/nexus.service
[Unit]
Description=Nexus Repository Manager
After=network.target
[Service]
Type=forking
LimitNOFILE=65536
User=nexus
Group=nexus
ExecStart=/home/nexus/nexus-3.54.1-01/bin/nexus start
ExecStop=/home/nexus/nexus-3.54.1-01/bin/nexus stop
Restart=on-abort
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start nexus
systemctl enable nexus
访问 http://ip:8081,admin初始密码在/home/nexus/sonatype-work/nexus3,disbale anonymous browsing

创建仓库:选择相应apt、yum等类型。
- hosted为离线储存模式
- proxy为在线代理模式
- group为组模式,用于整合仓库资源
hosted型

repodata depth:指定目录在仓库中的深度,一般设置为0,即所有软件包及元数据都在仓库根目录,便于管理、兼容;
layout policy:控制仓库中包的存放结构是否强制遵守规范;
strict content type validation:只允许符合仓库类型的文件;
deployment policy:Disable redeploy,允许上传,但禁止同名文件/包被覆盖;

proxy型
distribution:发行版
url:云厂商源
客户端配置
yum源-7
bash
cat /etc/yum.repos.d/CentOS-Base.repo
[base]
name=base
baseurl=http://ip:8081/repository/tsinghua-yum/$releasever/os/$basearch/
enabled=1
gpgcheck=0
[updates]
name=updates
baseurl=http://ip:8081/repository/tsinghua-yum/$releasever/updates/$basearch/
enabled=1
gpgcheck=0
[extras]
name=extras
baseurl=http://ip:8081/repository/tsinghua-yum/$releasever/extras/$basearch/
enabled=1
gpgcheck=0
[plus]
name=plus
baseurl=http://ip:8081/repository/tsinghua-yum/$releasever/centosplus/$basearch/
enabled=1
gpgcheck=0
apt源
bash
cat /etc/apt/sources.list
deb http://ip:8081/repository/tsinghua-ubuntu/ bionic main restricted universe multiverse
deb http://ip:8081/repository/tsinghua-ubuntu/ bionic-updates main restricted universe multiverse
deb http://ip:8081/repository/tsinghua-ubuntu/ bionic-backports main restricted universe multiverse
deb http://ip:8081/repository/tsinghua-ubuntu/ bionic-security main restricted universe multiverse
epel源
bash
cat /etc/yum.repos.d/CentOS-Base.repo
[epel]
name=epel
baseurl=http://ip:8081/repository/ali-epel/7/$basearch
enabled=1
gpgcheck=0
[epel-debuginfo]
name=epel-debuginfo
baseurl=http://ip:8081/repository/ali-epel/7/$basearch/debug
enabled=0
gpgcheck=0
[epel-source]
name=epel-source
baseurl=http://ip:8081/repository/ali-epel/7/SRPMS
enabled=0
gpgcheck=0
yum源-6
bash
cat /etc/yum.repos.d/CentOS-Base.repo
[base]
name=Base
failovermethod=priority
baseurl=http://172.29.8.103:8081/repository/vault-yum/os/$basearch/
gpgcheck=0
[updates]
name=Updates
failovermethod=priority
baseurl=http://172.29.8.103:8081/repository/vault-yum/updates/$basearch/
gpgcheck=0
[extras]
name=Extras
failovermethod=priority
baseurl=http://172.29.8.103:8081/repository/vault-yum/extras/$basearch/
gpgcheck=0
[centosplus]
name=Plus
failovermethod=priority
baseurl=http://172.29.8.103:8081/repository/vault-yum/centosplus/$basearch/
gpgcheck=0
enabled=0
[contrib]
name= Contrib
failovermethod=priority
baseurl=http://172.29.8.103:8081/repository/vault-yum/contrib/$basearch/
gpgcheck=0
enabled=0