基础环境要求
内外网centos 服务器
nexus服务器配置阿里yum源
sh> mkdir /etc/yum.repo.d/bak
sh> mv /etc/yum.repo.d/*.repo /etc/yum.repo.d/bak
下载阿里yum源文件
sh> wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或手动配置阿里yum源
sh> vim Centos-base.repo
粘贴以下阿里云yum源
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
sh> yum clean all sh> yum makecache
安装docker
关闭防火墙配置命令
sh> setenforce 0
sh> sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config
下载安装docker
sh> yum install -y docker
sh> systemctl start docker
sh> systemctl enable docker
docker下载安装nexus
sh> docker pull sonatype/nexus3
查看docker镜像
sh> docker images
新建nexus 数据目录
sh> mkdir /home/data/nexus-data
启动nexus 容器
sh> docker run -d --name nexus --net=bridge --ulimit nofile=65536:65536 -p 8081:8081 -p 8082:8082 -p 8083:8083 -p 8084:8084 -v /home/data/nexus-data:/nexus-data sonatype/nexus3 sonatype/nexus3
检查docker容器是否启动
sh> docker ps -a
浏览器访问nexus控制台 http://192.168.134.249:8081/
账号:admin 密码查看:
sh> cat /home/data/nexus-data/admin.password 进入控制台后,要修改密码
yum仓库搭建
账号密码登录后,进入配置,入口如下
创建存储空间
命名:yum-blo
b 类型:File
创建本地yum repository
选择yum-hosted
名称:yum-local,如图选择对应的选项,storage 选择 yum-blob
提交保存
创建代理yum repository
选择yum-proxy填写name:yum-proxy,url:http://mirrors.163.com/centos/
提交保存
创建组合 yum repository
选择yum-group填写name:yum-group,添加上面两个仓库
复制yum-group仓库地址
连接nexus 源服务器配置
sh> mkdir /etc/yum.repo.d/baksh> mv /etc/yum.repo.d/*.repo /etc/yum.repo.d/bak
sh> vim Centos-base.repo编辑以下nexus yum源,注意替换成上面的yum-group地址
[base]
name=CentOS-$releasever-base
baseurl=http://192.168.134.249:8081/repository/yum-group/$releasever/os/$basearch/
enabled=1
gpgcheck=0
[updates]
name=CentOS-$releasever-updates
baseurl=http://192.168.134.249:8081/repository/yum-group/$releasever/updates/$basearch/
enabled=1
gpgcheck=0
[extras]
name=CentOS-$releasever-extras
baseurl=http://192.168.134.249:8081/repository/yum-group/$releasever/extras/$basearch/
enabled=1
gpgcheck=0
sh> yum clean allsh> yum makecache
搭建apt代理
后台管理配置
进入后台管理,创建入口如下:
选择apt(proxy)
Name: apt-proxy
Distribution: bionic
Remote storage: https://mirrors.aliyun.com/ubuntu/
Blob store: apt-clob (说明:任意选择一个,因为代理不会存储数据,没有的选,可以自己创建一个,参考“yum 创建存储空间步骤”)点击保存完成
apt客户端配置
sh> mv /etc/apt/sources.list /etc/apt/sources.list.oldsh> vim /etc/apt/sources.list拷贝以下内容:
deb http://192.168.134.249:8081/repository/apt-proxy/ bionic main restricted universe multiverse
deb http://192.168.134.249:8081/repository/apt-proxy/ bionic-security main restricted universe multiverse
deb http://192.168.134.249:8081/repository/apt-proxy/ bionic-updates main restricted universe multiverse
deb http://192.168.134.249:8081/repository/apt-proxy/ bionic-proposed main restricted universe multiverse
deb http://192.168.134.249:8081/repository/apt-proxy/ bionic-backports main restricted universe multiverse
保存退出
更新apt配置sh> sudo apt-get updatesh> sudo apt-get upgrade