Setup nexus3 using docker

部署

運(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ǔ)需求:

  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

可以通過(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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市们拙,隨后出現(xiàn)的幾起案子稍途,更是在濱河造成了極大的恐慌,老刑警劉巖砚婆,帶你破解...
    沈念sama閱讀 211,042評(píng)論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件械拍,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡装盯,警方通過(guò)查閱死者的電腦和手機(jī)坷虑,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 89,996評(píng)論 2 384
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)埂奈,“玉大人迄损,你說(shuō)我怎么就攤上這事≌嘶牵” “怎么了芹敌?”我有些...
    開(kāi)封第一講書(shū)人閱讀 156,674評(píng)論 0 345
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)绑谣。 經(jīng)常有香客問(wèn)我党窜,道長(zhǎng),這世上最難降的妖魔是什么借宵? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,340評(píng)論 1 283
  • 正文 為了忘掉前任幌衣,我火速辦了婚禮,結(jié)果婚禮上壤玫,老公的妹妹穿的比我還像新娘豁护。我一直安慰自己,他們只是感情好欲间,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,404評(píng)論 5 384
  • 文/花漫 我一把揭開(kāi)白布楚里。 她就那樣靜靜地躺著,像睡著了一般猎贴。 火紅的嫁衣襯著肌膚如雪班缎。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 49,749評(píng)論 1 289
  • 那天她渴,我揣著相機(jī)與錄音达址,去河邊找鬼。 笑死趁耗,一個(gè)胖子當(dāng)著我的面吹牛沉唠,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播苛败,決...
    沈念sama閱讀 38,902評(píng)論 3 405
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼满葛,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼径簿!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起嘀韧,我...
    開(kāi)封第一講書(shū)人閱讀 37,662評(píng)論 0 266
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤篇亭,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后锄贷,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體暗赶,經(jīng)...
    沈念sama閱讀 44,110評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,451評(píng)論 2 325
  • 正文 我和宋清朗相戀三年肃叶,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了蹂随。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,577評(píng)論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡因惭,死狀恐怖岳锁,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情蹦魔,我是刑警寧澤激率,帶...
    沈念sama閱讀 34,258評(píng)論 4 328
  • 正文 年R本政府宣布,位于F島的核電站勿决,受9級(jí)特大地震影響乒躺,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜低缩,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,848評(píng)論 3 312
  • 文/蒙蒙 一嘉冒、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧咆繁,春花似錦讳推、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,726評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至坏为,卻和暖如春究驴,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背匀伏。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 31,952評(píng)論 1 264
  • 我被黑心中介騙來(lái)泰國(guó)打工洒忧, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人帘撰。 一個(gè)月前我還...
    沈念sama閱讀 46,271評(píng)論 2 360
  • 正文 我出身青樓跑慕,卻偏偏與公主長(zhǎng)得像万皿,于是被迫代替她去往敵國(guó)和親摧找。 傳聞我的和親對(duì)象是個(gè)殘疾皇子核行,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,452評(píng)論 2 348

推薦閱讀更多精彩內(nèi)容