AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
参考: https://cloud.tencent.com/developer/article/1147232 # ubuntu20.04 nexus 安装 ``` apt install openjdk-8-jre-headless useradd -M -d /data/nexus -s /bin/bash -r nexus mkdir /data cd /data/ sudo wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz tar zxf latest-unix.tar.gz chown -R nexus.nexus nexus-3.37.3-02/ chown -R nexus.nexus sonatype-work/ cat nexus-3.37.3-02/bin/nexus.rc run_as_user="nexus" cat nexus-3.37.3-02/bin/nexus.vmoptions 看情况修改启动参数 cat /etc/systemd/system/nexus.service [Unit] Description=nexus service After=network.target [Service] Type=forking LimitNOFILE=65536 ExecStart=/data/nexus-3.37.3-02/bin/nexus start ExecStop=/data/nexus-3.37.3-02/bin/nexus stop User=nexus Restart=on-abort [Install] WantedBy=multi-user.target ---------------------------------------------- sudo systemctl daemon-reload sudo systemctl start nexus sudo systemctl enable nexus ss -unplt cat sonatype-work/nexus3/admin.password http://192.168.60.231:8081 ``` 如果非admin用户,需要在Nexus中对相应的帐号设置密码 打开安全设置:http://localhost:8081/nexus/#security-users 选择相应的用户-->右键-->reset password/set password-->进行密码设置 相应的仓库允许重新发布(Repositories-->选择相应的仓库-->Configuration-->Deployment Policy下拉选项中选择“Allow Redeploy”),如果不允许重新发布,重新发布时会出现401等异常情况。 # Nexus的仓库 ### **对于Release版本的项目**: 当项目中添加了一个正式版的version为x的依赖时,构建工具在构建项目时会从远程仓库中下载这个version为x的依赖到本地仓库缓存起来,下次再构建项目时,构建工具会从本地仓库中查找是否存在这个version为x的依赖,存在就不会在去远程仓库中拉取。这种特性会导致在团队开发中,如果你发布一个正式版的项目时,仍然使用的是同一个version,就可能出现其他使用这个version项目的成员根本接收不到项目的最新变更,这是糟糕的,为了生命安全,大家尽量不要这么做。所以,在每次发布正式版项目时,必须更新version。 ### **对于Snapshot版本的项目**: 当项目中添加了一个快照版的version为x的依赖时,不管本地仓库中是否存在这个version为x的依赖,构建工具都会尝试从远程仓库中查看这个version为x的依赖是否最新。这样就能保证团队开发时,所有使用这个version为x的依赖的项目都能获取到依赖最新的变更,而且不用不停的迭代依赖的version。最后一还有一点,Snapshot版项目发布时的version一定要以-SNAPSHOT结尾,英文字母必须大写。 ### **hosted(宿主仓库) :** 专门存放无法从远程仓库中下载的构件或者公司内部自主开发的一些构件。当hosted仓库找不到目标构件时,并不能从远程仓库下载。并且想要将内部开发构件上传到maven仓库,三种仓库中只能使用hosted。 ### **proxy(代理仓库) :** 当用户向proxy请求一个资源时,proxy会先在本地仓库中寻找是否有该资源,没有的话会从远程仓库下载,然后返回给用户;同时会缓存在本地,下次用户再请求相同资源时,就可以直接在本地中找到并返回给用户。proxy起到一层缓存与中转的作用。 proxy代理的远程仓库可以配置,这里我选择阿里云的maven仓库(http://maven.aliyun.com/nexus/content/groups/public/,因为在国内比中央仓库快很多) ### **group(仓库组) :** 多个仓库的聚合体,将你在nexus中想要使用的maven仓库聚合在一起,对用户暴露统一的地址,这样用户就不需在项目中配置多个maven地址了。 我们可以将以上仓库都集成在group仓库组中,一定要将阿里云放在其他国外maven仓库的上面,因为访问仓库时的顺序是从上往下访问的,这样就既有了国内仓库的速度,又可以在国内仓库没有资源时,去国外仓库获取到资源。 # nexus使用外部nginx ``` upstream nexus-workhorse { server 192.168.60.11:8081; #web } upstream nexus { server 192.168.60.11:5000; #docker仓库 } server { listen 80; server_name nexus.firstgold.com; server_tokens off; ## Don't show the nginx version number, a security best practice access_log /var/log/nginx/nexus_access.log gitlab_access; error_log /var/log/nginx/nexus_error.log; location ^~ /v2 { proxy_read_timeout 3600; proxy_connect_timeout 300; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto http; proxy_pass http://nexus; } location / { proxy_read_timeout 3600; proxy_connect_timeout 300; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto http; proxy_pass http://nexus-workhorse; } error_page 404 /404.html; error_page 422 /422.html; error_page 500 /500.html; error_page 502 /502.html; location ~ ^/(404|422|500|502)(-custom)?\.html$ { root /opt/gitlab/embedded/service/gitlab-rails/public; internal; } } ```