部署
運(yùn)行 nexus3 容器诗芜,其默認(rèn)使用 8081 端口,可以將其轉(zhuǎn)發(fā)到其他端口暑脆,例如 443
~/go/src/etcd-io/etcd/tools/etcd-dump-db (main ?) docker run -d -p 443:8081 --name nexus sonatype/nexus3
af9b0952e35105bcd7a2e7080f5e15f0451f71b69e4df123096039f0e9d7ae83
nexus 服務(wù)的初始化大概需要 2-3 分鐘簇捍,可以通過(guò) docker logs 查看進(jìn)度
docker logs -f nexus
查詢 nexus 狀態(tài)
~/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 初始密碼,默認(rèn)用戶名為 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 進(jìn)入 nexus 容器里查看相關(guān)信息极景,如下所示察净。如果要從容器里退出驾茴,可以使用快捷鍵: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 存儲(chǔ)多種類型的數(shù)據(jù),其中主要包含兩種存儲(chǔ)需求:
Embedded data (H2, OrientDB, Elastic Search) requires very responsive, fast storage, ideally local disk
Blob storage (component binaries), which requires moderately responsive, high-capacity storage
可以通過(guò)界面操作創(chuàng)建 File/S3 blob storage
通過(guò)界面創(chuàng)建 apt repository
注意氢卡,創(chuàng)建 hosted apt repository 時(shí)需要設(shè)置 PGP signing key 和 Passphrase锈至,可以通過(guò)如下命令,設(shè)置的過(guò)程中會(huì)要求輸入密碼译秦。Blob storage 可以使用上面創(chuàng)建的 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 設(shè)置不正確击碗,上傳 deb 包時(shí)會(huì)出現(xiàn)java.lang.RuntimeException: org.bouncycastle.openpgp.PGPException: checksum mismatch at 0 of 20
錯(cuò)誤:
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