标签:configure hub other war x86_64 version use clean 重载
说明:Nexus是Sonatype提供的仓库管理平台,Nuexus Repository OSS3能够支持Maven、npm、Docker、YUM、Helm等格式数据的存储和发布。
1)安装JDK
yum install -y java-1.8.0-openjdk*
2)配置环境
vim /etc/profile # set java environment export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64 export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
3)重载
source /etc/profile echo "source /etc/profile" >> /etc/bashrc java -version
mkdir -p /opt/nexus && cd /opt/nexus wget https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.18.1-01-unix.tar.gz tar -zxvf nexus-3.18.1-01-unix.tar.gz mv nexus-3.18.1-01 nexus3.18
vim /opt/data/nexus/nexus3.18/bin/nexus
INSTALL4J_JAVA_PREFIX="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64"
vim /opt/data/nexus/nexus3.18/bin/nexus.rc run_as_user="root"
vim /opt/data/nexus/nexus3.18/bin/nexus.vmoptions -XX:LogFile=/opt/data/blob-stores/others/sonatype-work/nexus3/log/jvm.log -Dkaraf.data=/opt/data/blob-stores/others/sonatype-work/nexus3 -Djava.io.tmpdir=/opt/data/blob-stores/others/sonatype-work/nexus3/tmp
cat /opt/data/nexus/nexus3.18/etc/nexus-default.properties |grep application-port
vim /usr/lib/systemd/system/nexus.service [Unit] Description=nexus service [Service] Type=forking LimitNOFILE=65536 ExecStart=/opt/nexus/nexus3.18/bin/nexus start ExecReload=/opt/nexus/nexus3.18/bin/nexus restart ExecStop=/opt/nexus/nexus3.18/bin/nexus stop Restart=on-failure [Install] WantedBy=multi-user.target
将服务加入开机启动
systemctl daemon-reload
systemctl enable nexus
systemctl start nexus
yum install -y nginx
申请ssl证书,并存放在 /etc/nginx/cert 目录下
mkdir /etc/nginx/cert
vim /etc/nginx/nginx.conf #注释server,添加如下: upstream nexusserver{ server 172.16.2.158:8081; } upstream mirrornexus{ server 172.16.2.158:6001; } upstream nexusdocker{ server 172.16.2.158:6000; }
说明:
1)8081 为 nexus server 的端口,nexus本身服务程序;
2)6001 为 docker proxy 的端口,作为中央仓库的代理;
3)6000 为 docker hosted 的端口,推送拉取镜像
4)6001 和 6000 需登入后台进行相应的配置生成端口,这里是提前设置好nginx。
vim /etc/nginx/conf.d/nexusserver.conf server { listen 443; server_name nexus.wmq.com; ssl on; ssl_certificate cert/1566822_nexus.wmq.com.pem; ssl_certificate_key cert/1566822_nexus.wmq.com.key; client_max_body_size 0; index index.html; location / { proxy_pass http://nexusserver; #proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto "https"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 80; server_name nexus.wmq.com; client_max_body_size 0; index index.html; location / { return 301 https://$server_name$request_uri; } }
vim /etc/nginx/conf.d/mirrornexus.conf server { listen 443; server_name mirror.nexus.wmq.com; ssl on; ssl_certificate cert/mirror.nexus.wmq.com.pem; ssl_certificate_key cert/mirror.nexus.wmq.com.key; client_max_body_size 0; index index.html; location / { proxy_pass http://mirrornexus; #proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto "https"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 80; server_name mirror.nexus.wmq.com; client_max_body_size 0; index index.html; location / { return 301 https://$server_name$request_uri; } }
vim /etc/nginx/conf.d/nexusdocker.conf server { listen 443; server_name reg.nexus.wmq.com; ssl on; ssl_certificate cert/reg.nexus.wmq.pem; ssl_certificate_key cert/reg.nexus.wmqhealth.key; client_max_body_size 0; index index.html; location / { proxy_pass http://nexusdocker; #proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto "https"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 80; server_name reg.nexus.wmq.com; client_max_body_size 0; index index.html; location / { return 301 https://$server_name$request_uri; } }
nginx -t
systemctl enable nginx
systemctl start nginx
nexus.wmq.com、mirror.nexus.wmq.com、reg.nexus.wmq.com 三个域名都解析到 nexus 主机内网地址
github地址:https://github.com/mlabouardy/nexus-cli
mkdir /opt/nexus/clean-docker-images && cd /opt/nexus/clean-docker-images wget https://s3.eu-west-2.amazonaws.com/nexus-cli/1.0.0-beta/linux/nexus-cli chmod +x nexus-cli
./nexus-cli configure Enter Nexus Host: http://127.0.0.1:8081 Enter Nexus Repository Name: docker-wmqe Enter Nexus Username: admin Enter Nexus Password: *******
会在当前目录生成 .credentials 文件,该文件记录了上面输入的信息。
vim clean-docker-images.sh #! /bin/sh CLI_HOME=/opt/nexus/clean-docker-images KEEP_VERSION_NUM=10 IMAGES=$($CLI_HOME/nexus-cli image ls|grep -v Total) clean_images() { cd $CLI_HOME for imgs in $(echo $IMAGES); do echo "清理$imgs"; ./nexus-cli image delete -name $imgs -keep $KEEP_VERSION_NUM done } clean_images
crontab -e 0 1 * * * sh /opt/nexus/clean-docker-images/clean-docker-images.sh > /opt/nexus/clean-docker-images/clean-docker-images.log 2>&1
标签:configure hub other war x86_64 version use clean 重载
原文地址:https://www.cnblogs.com/weavepub/p/11419139.html