Setup nexus3 using docker

部署

运行 nexus3 容器,其默认使用 8081 端口,可以将其转发到其他端口,例如 443

~/go/src/etcd-io/etcd/tools/etcd-dump-db (main ✔) docker run -d -p 443:8081 --name nexus sonatype/nexus3                                     
af9b0952e35105bcd7a2e7080f5e15f0451f71b69e4df123096039f0e9d7ae83

nexus 服务的初始化大概需要 2-3 分钟,可以通过 docker logs 查看进度

docker logs -f nexus

查询 nexus 状态

~/go/src/etcd-io/etcd/tools/etcd-dump-db (main ✔) curl http://localhost:443/                                                       [78/90285]

<!DOCTYPE html>                                                                                                                              
<html lang="en">                                                                                                                             
<head>                                                                                                                                       
  <title>Nexus Repository Manager</title>                                                                                                    
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>                                                                       
  <meta name="description" content="Nexus Repository Manager"/>                                                                              
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>                                                                                     

  <!--[if lt IE 9]>
    <script>(new Image).src="./static/rapture/resources/favicon.ico?_v=3.37.3-02&_e=OSS"</script>
  <![endif]-->
  <link rel="icon" type="image/png" href="./static/rapture/resources/favicon-32x32.png?_v=3.37.3-02&_e=OSS" sizes="32x32">
  <link rel="mask-icon" href="./static/rapture/resources/safari-pinned-tab.svg?_v=3.37.3-02&_e=OSS" color="#5bbad5">
  <link rel="icon" type="image/png" href="./static/rapture/resources/favicon-16x16.png?_v=3.37.3-02&_e=OSS" sizes="16x16">
  <link rel="shortcut icon" href="./static/rapture/resources/favicon.ico?_v=3.37.3-02&_e=OSS">
  <meta name="msapplication-TileImage" content="./static/rapture/resources/mstile-144x144.png?_v=3.37.3-02&_e=OSS">
  <meta name="msapplication-TileColor" content="#00a300">

      <link rel="stylesheet" type="text/css" href="./static/rapture/resources/loading-prod.css?_v=3.37.3-02&_e=OSS">
    <link rel="stylesheet" type="text/css" href="./static/rapture/resources/baseapp-prod.css?_v=3.37.3-02&_e=OSS">
    <link rel="stylesheet" type="text/css" href="./static/rapture/resources/nexus-rapture-prod.css?_v=3.37.3-02&_e=OSS">
    <link rel="stylesheet" type="text/css" href="./static/rapture/resources/nexus-proximanova-plugin-prod.css?_v=3.37.3-02&_e=OSS">
    <link rel="stylesheet" type="text/css" href="./static/rapture/resources/nexus-coreui-plugin-prod.css?_v=3.37.3-02&_e=OSS">
    <link rel="stylesheet" type="text/css" href="./static/rapture/resources/nexus-proui-plugin-prod.css?_v=3.37.3-02&_e=OSS">
    <link rel="stylesheet" type="text/css" href="./static/rapture/resources/nexus-onboarding-plugin-prod.css?_v=3.37.3-02&_e=OSS">
    <link rel="stylesheet" type="text/css" href="./static/nexus-rapture-bundle.css?_v=3.37.3-02&_e=OSS">
    <link rel="stylesheet" type="text/css" href="./static/nexus-coreui-bundle.css?_v=3.37.3-02&_e=OSS">
    <link rel="stylesheet" type="text/css" href="./static/nexus-proui-bundle.css?_v=3.37.3-02&_e=OSS">
.....

查询 nexus 初始密码,默认用户名为 admin

~/go/src/etcd-io/etcd/tools/etcd-dump-db (main ✔) docker container exec nexus cat nexus-data/admin.password
518bb908-5f68-4cb0-a17d-6496d8febc73

登录界面后需要修改密码。

使用

可以使用 docker exec 进入 nexus 容器里查看相关信息,如下所示。如果要从容器里退出,可以使用快捷键:ctrl+p ctrl+q

~/go/src/etcd-io/etcd/tools/etcd-dump-db (main ✔) docker ps                     
CONTAINER ID   IMAGE                     COMMAND                  CREATED          STATUS          PORTS                                     
NAMES
af9b0952e351   sonatype/nexus3           "sh -c ${SONATYPE_DI…"   29 minutes ago   Up 29 minutes   0.0.0.0:443->8081/tcp, :::443->8081/tcp   
nexus

~/go/src/etcd-io/etcd/tools/etcd-dump-db (main ✔) docker exec -ti af9b0952e351 bash

bash-4.4$ ls -al /opt/sonatype/sonatype-work/
total 0
drwxr-xr-x 2 root root 20 Dec 29  2021 .
drwxr-xr-x 1 root root 19 Dec 29  2021 ..
lrwxrwxrwx 1 root root 11 Dec 29  2021 nexus3 -> /nexus-data

bash-4.4$ ls -al /opt/sonatype/sonatype-work/nexus3/
total 24
drwxr-xr-x  15 nexus nexus  254 Aug 18 07:46 .
drwxr-xr-x   1 root  root    28 Aug 18 07:42 ..
drwxr-xr-x   3 nexus nexus   21 Aug 18 07:43 blobs
drwxr-xr-x 336 nexus nexus 8192 Aug 18 07:42 cache
drwxr-xr-x   6 nexus nexus  113 Aug 18 07:43 db
drwxr-xr-x   3 nexus nexus   19 Aug 18 07:43 elasticsearch
drwxr-xr-x   3 nexus nexus   45 Aug 18 07:42 etc
drwxr-xr-x   2 nexus nexus    6 Aug 18 07:42 generated-bundles
drwxr-xr-x   2 nexus nexus   33 Aug 18 07:42 instances
drwxr-xr-x   3 nexus nexus   19 Aug 18 07:42 javaprefs
-rw-r--r--   1 nexus nexus    1 Aug 18 07:42 karaf.pid
drwxr-xr-x   3 nexus nexus   18 Aug 18 07:42 keystores
-rw-r--r--   1 nexus nexus   14 Aug 18 07:42 lock
drwxr-xr-x   3 nexus nexus  112 Aug 18 07:43 log
drwxr-xr-x   2 nexus nexus    6 Aug 18 07:42 orient
-rw-r--r--   1 nexus nexus    5 Aug 18 07:42 port
drwxr-xr-x   2 nexus nexus    6 Aug 18 07:42 restore-from-backup
drwxr-xr-x   7 nexus nexus  242 Aug 18 07:43 tmp

Nexus Repository 存储多种类型的数据,其中主要包含两种存储需求:

  1. Embedded data (H2, OrientDB, Elastic Search) requires very responsive, fast storage, ideally local disk

  2. Blob storage (component binaries), which requires moderately responsive, high-capacity storage

可以通过界面操作创建 File/S3 blob storage

通过界面创建 apt repository

注意,创建 hosted apt repository 时需要设置 PGP signing key 和 Passphrase,可以通过如下命令,设置的过程中会要求输入密码。Blob storage 可以使用上面创建的 s3 storage。

gpg --gen-key
gpg --list-keys
gpg --export-secret-key --armor

上传 deb 包

  • curl 命令行上传
curl -u "admin:admin" -H "Content-Type: multipart/form-data" --data-binary "@./test.deb" "http://10.9.8.72:443/repository/apt-hosted/"
  • 界面上传
2023-08-21 06:24:59,260+0000 INFO  [qtp887932152-643] admin org.sonatype.nexus.repository.upload.internal.OrientUploadManagerImpl - Uploading component with parameters: repository="apt-hosted" format="apt" 
2023-08-21 06:24:59,260+0000 INFO  [qtp887932152-643] admin org.sonatype.nexus.repository.upload.internal.OrientUploadManagerImpl - Asset with parameters: file="hello-world_0.0.1-1_amd64.deb"

如果 pgp 设置不正确,上传 deb 包时会出现java.lang.RuntimeException: org.bouncycastle.openpgp.PGPException: checksum mismatch at 0 of 20错误:

2023-08-18 11:18:40,679+0000 ERROR [qtp887932152-648] admin org.sonatype.nexus.coreui.UploadResource - Unable to perform upload to repository apt-hosted                                                                                                                                  java.lang.RuntimeException: org.bouncycastle.openpgp.PGPException: checksum mismatch at 0 of 20                                              
        at org.sonatype.nexus.repository.security.GpgUtils.signInline(GpgUtils.java:195)                                                             at org.sonatype.nexus.repository.apt.internal.gpg.AptSigningFacet.signInline(AptSigningFacet.java:96)                                
        at org.sonatype.nexus.repository.apt.orient.internal.hosted.OrientAptHostedFacet.rebuildIndexes(OrientAptHostedFacet.java:183)               at org.sonatype.nexus.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:49)                                      
        at org.sonatype.nexus.repository.apt.orient.internal.hosted.OrientAptHostedFacet.ingestAsset(OrientAptHostedFacet.java:139)                  at org.sonatype.nexus.transaction.TransactionalWrapper.proceedWithTransaction(TransactionalWrapper.java:58)                                  at org.sonatype.nexus.transaction.TransactionInterceptor.proceedWithTransaction(TransactionInterceptor.java:66)                      
        at org.sonatype.nexus.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:55)                                              at org.sonatype.nexus.repository.apt.orient.internal.hosted.OrientAptHostedFacet.ingestAsset(OrientAptHostedFacet.java:107)          
        at org.sonatype.nexus.repository.apt.orient.OrientAptUploadHandler.handle(OrientAptUploadHandler.java:69)                                    at org.sonatype.nexus.repository.upload.internal.OrientUploadManagerImpl.handle(OrientUploadManagerImpl.java:109)                    
        at org.sonatype.nexus.coreui.internal.UploadService.upload(UploadService.java:78)                                                    
        at org.sonatype.nexus.coreui.UploadResource.postComponent(UploadResource.java:86)                                                    
        at com.palominolabs.metrics.guice.ExceptionMeteredInterceptor.invoke(ExceptionMeteredInterceptor.java:23)                            
        at com.palominolabs.metrics.guice.TimedInterceptor.invoke(TimedInterceptor.java:26)                                                  
        at org.sonatype.nexus.validation.internal.ValidationInterceptor.invoke(ValidationInterceptor.java:53)
        at org.apache.shiro.guice.aop.AopAllianceMethodInvocationAdapter.proceed(AopAllianceMethodInvocationAdapter.java:49)
        at org.apache.shiro.authz.aop.AuthorizingAnnotationMethodInterceptor.invoke(AuthorizingAnnotationMethodInterceptor.java:68)
        at org.apache.shiro.guice.aop.AopAllianceMethodInterceptorAdapter.invoke(AopAllianceMethodInterceptorAdapter.java:36)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)

参考链接

https://github.com/sonatype/docker-nexus3
Sonatype Nexus Repository System Requirements
Apt Repositories
https://ahgh.medium.com/how-to-setup-sonatype-nexus-3-repository-manager-using-docker-7ff89bc311ce
https://gist.github.com/marcelmaatkamp/123e8793e07a72a382d8d0e8d66bbd8f
https://www.digitalocean.com/community/tutorials/install-maven-linux-ubuntu

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,684评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,143评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,214评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,788评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,796评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,665评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,027评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,679评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 41,346评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,664评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,766评论 1 331
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,412评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,015评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,974评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,203评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,073评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,501评论 2 343

推荐阅读更多精彩内容