Linux环境Nexus 3私服仓库安装脚本

小柒博客 Shell评论70.9K2字数 1629阅读5分25秒阅读模式

此脚本是Linux一键部署Nexus 3私服仓库自动化脚本,有需要朋友可以参考,脚本内容如下:

环境准备:

操作系统:CentOS Linux release 7.8.2003

软件版本:

Docker:docker-ce-19.03.12

[root@localhost ~]# vim install_nexus3.sh

#!/bin/bash
#Date:2020-8-21 10:26:28
#Author Blog:
#	https://www.yangxingzhen.com
#	https://www.yangxingzhen.cn
#Author WeChat:
#	微信公众号:小柒博客
#Author mirrors site:
#	https://mirrors.yangxingzhen.com
#About the Author
#	BY:YangXingZhen
#	Mail:xingzhen.yang@yangxingzhen.com
#	QQ:675583110
#Auto Install Docker-ce And Nexus 3

IPADDR=$(hostname -I |awk '{print $1}')

# 安装Docker-ce
rpm -qa |grep "docker-ce" >/dev/null 2>&1
if [ $? -ne 0 ];then
	#curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
	yum -y install yum-utils device-mapper-persistent-data lvm2 >/dev/null
	yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
	yum -y install docker-ce-19.03.12 docker-ce-cli-19.03.12 containerd.io >/dev/null
fi

# 配置镜像加速器
mkdir -p /etc/docker
cat >/etc/docker/daemon.json <<EOF
{
	"registry-mirrors": [
	"https://hub-mirror.c.163.com",
	"https://reg-mirror.qiniu.com",
	"https://registry.docker-cn.com",
	"https://lhbk6z9b.mirror.aliyuncs.com"
	]
}
EOF

# 开启TCP管理端口
sed -i 's#/usr/bin/dockerd#& -H tcp://0.0.0.0:2375#' /usr/lib/systemd/system/docker.service

# 启动Docker
systemctl daemon-reload
systemctl enable docker
systemctl start docker

# 安装Nexus 3
# 拉取Nexus 3镜像
docker pull sonatype/nexus3 

# 创建持久化数据目录
mkdir -p /data/nexus-data && chown -R 200 /data/nexus-data

# 启动Nexus 3
docker run -d -p 80:8081 --name nexus -v /data/nexus-data:/nexus-data sonatype/nexus3

#等待45秒,Nexus 3启动成功,生成密码文件
sleep 45

# 获取密码
User="admin"
Passwd=$(cat /data/nexus-data/admin.password)

echo -e "\033[32mNexus 3访问地址:http://${IPADDR}\n用户名:${User}\n密码:${Passwd}\033[0m"

脚本执行方式:

[root@localhost ~]# sh install_nexus3.sh

脚本执行过程截图如下

Linux环境Nexus 3私服仓库安装脚本-图片1

Linux环境Nexus 3私服仓库安装脚本-图片2

若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!

继续阅读
Wechat
微信扫一扫,加我!
weinxin
微信公众号
微信扫一扫,关注我!
weinxin
Shell最后更新:2024-1-24
小柒博客
  • 本文由 小柒博客 发表于 2020年11月18日10:32:12
  • 声明:本站所有文章,如无特殊说明或标注,本站文章均为原创。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。转载请务必保留本文链接:https://www.yangxingzhen.com/7607.html
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

拖动滑块以完成验证