【Maven学习】Nexus OSS私服仓库的备份与迁移
背景
在上一篇博客 【Maven學(xué)習(xí)】Nexus OSS私服倉(cāng)庫(kù)的安裝和配置 中,我們已經(jīng)在機(jī)房搭建好了新的Nexus OSS私服倉(cāng)庫(kù)。下面是兩個(gè)版本的Nexus OSS私服倉(cāng)庫(kù)的對(duì)比圖。
老的Nexus OSS私服倉(cāng)庫(kù)
新的Nexus OSS私服倉(cāng)庫(kù)
明顯老的Nexus OSS私服倉(cāng)庫(kù)的內(nèi)容比新的Nexus OSS私服倉(cāng)庫(kù)的內(nèi)容多。因此我們現(xiàn)在的工作就是將辦公室上的老的Nexus服務(wù)器上的所有的數(shù)據(jù)遷移到機(jī)房的Nexus服務(wù)器。這一篇博客記錄下整個(gè)Nexus OSS私服倉(cāng)庫(kù)的備份與遷移的過(guò)程。
一、老的Nexus OSS私服倉(cāng)庫(kù)備份
遷移中會(huì)遇到三個(gè)文件夾 , 打包、拉走 啟動(dòng)即可。
| nexus主目錄 | nexus-2.6.4-02 | conf/nexus.properties里面有sonatype-work的地址 |
| sonatype-work目錄 | sonatype-work | nexus/conf/nexus.xml里面有storage的地址 |
| storage目錄 | storage | 里面主要是各種程序的jar包等 |
遷移流程如下
首先我們?cè)诶系腘exus OSS私服倉(cāng)庫(kù)的這臺(tái)Linux服務(wù)器上,查看相關(guān)的目錄信息。
如上圖所示,在老的Nexus OSS私服倉(cāng)庫(kù)的這臺(tái)Linux服務(wù)器上,
nexus主目錄的地址為:/usr/local/nexus-2.12.1-01
在 /usr/local/nexus-2.12.1-01/config/nexus.properties 文件中,指定了sonatype-work的地址
現(xiàn)在我們進(jìn)入 /usr/local/sonatype-work/nexus/storage目錄,查看里面的目錄結(jié)構(gòu)
[root@kf1appsvr storage]# pwd /usr/local/sonatype-work/nexus/storage [root@kf1appsvr storage]# ll total 52 drwxr-xr-x 6 root root 4096 Dec 4 08:49 android-beta drwxr-xr-x 6 root root 4096 Dec 4 08:49 android-dev drwxr-xr-x 6 root root 4096 Dec 4 08:49 android-release drwxr-xr-x 6 root root 4096 Dec 4 08:49 android-snapshots drwxr-xr-x 10 root root 4096 Dec 4 08:49 android_public drwxr-xr-x 4 root root 4096 Dec 4 08:49 apache-snapshots drwxr-xr-x 30 root root 4096 Dec 4 08:49 central drwxr-xr-x 125 root root 4096 Nov 30 17:08 central-m1 drwxr-xr-x 6 root root 4096 Dec 4 08:49 public drwxr-xr-x 4 root root 4096 Dec 4 08:49 releases drwxr-xr-x 4 root root 4096 Dec 4 08:49 snapshots drwxr-xr-x 5 root root 4096 Dec 4 08:49 thirdparty drwxr-xr-x 2 root root 4096 Jan 11 2017 xtc_devs將此目錄結(jié)構(gòu)和Nexus管理界面對(duì)比,可以一一對(duì)應(yīng),如下所示。
從上面分析來(lái)看,我們只需要將nexus主目錄和sonatype-work目錄都備份好即可。但是兩個(gè)Linux服務(wù)器的nexus配置的java路徑之類的可能不同,我就不備份nexus主目錄了。
我只備份sonatype-work目錄,Nexus的構(gòu)件倉(cāng)庫(kù)都保存在sonatype-work目錄中,該目錄的位置由nexus/conf/nexus.properties配置文件指定。
使用 tar命令將 sonatype-work目錄 打包壓縮為一個(gè) tar.gz文件,命令如下所示
[root@kf1appsvr local]# tar -zcvf sonatype-work-2017-12-14.tar.gz ./sonatype-work/備份中,整個(gè)備份過(guò)程比較緩慢,因?yàn)閮赡陚魃先サ牡奈募臀募A太多了。
打包完畢
生成了 sonatype-work-2017-12-14.tar.gz 文件,占用了2770940709 字節(jié),差不多2.6G
二、將老的Nexus OSS私服倉(cāng)庫(kù)的備份文件復(fù)制到新的Nexus OSS私服倉(cāng)庫(kù)
上一步我們將整個(gè) sonatype-work 目錄打包成一個(gè)壓縮包 sonatype-work-2017-12-14.tar.gz,現(xiàn)在我們要將這個(gè)壓縮包復(fù)制到新的Nexus OSS私服倉(cāng)庫(kù)的Linux服務(wù)器上。
我們是有 scp命令來(lái)進(jìn)行復(fù)制操作,關(guān)于scp命令的操作可以參考之前的文章 git學(xué)習(xí)------> Gitlab如何進(jìn)行備份恢復(fù)與遷移?
使用scp命令從遠(yuǎn)程服務(wù)器copy文件或者目錄到本地
scp 用戶名 @IP 地址 : 文件名 1 遠(yuǎn)程用戶名 @IP 地址 : 文件名 2[用戶名 @IP 地址 :] 可以不輸入 , 可能需要輸入遠(yuǎn)程用戶名所對(duì)應(yīng)的密碼 .
可能有用的幾個(gè)參數(shù) :
- -v 和大多數(shù) linux 命令中的 -v 意思一樣 , 用來(lái)顯示進(jìn)度 . 可以用來(lái)查看連接 , 認(rèn)證 , 或是配置錯(cuò)誤 .
- -C 使能壓縮選項(xiàng) .
- -P 選擇端口 . 注意 -p 已經(jīng)被 rcp 使用 .
- -4 強(qiáng)行使用 IPV4 地址 .
- -6 強(qiáng)行使用 IPV6 地址 .
例如我使用如下命令,從遠(yuǎn)程服務(wù)器copy剛才的備份文件sonatype-work-2017-12-14.tar.gz到了新服務(wù)器的/usr/local 目錄下
scp root@老的linux的ip地址:/usr/local/sonatype-work-2017-12-14.tar.gz /usr/local/我們登錄到新的Nexus OSS私服倉(cāng)庫(kù)那臺(tái)linux服務(wù)器,然后執(zhí)行上面的命令
敲了命令之后,需要我們確認(rèn)是否connecting,我們敲一個(gè)yes,接著需要我們輸入老的Nexus OSS私服倉(cāng)庫(kù)那臺(tái)linux服務(wù)器的密碼,如下所示
敲完之后,如果密碼正確的話,則將剛才的備份文件copy到這臺(tái)新的linux服務(wù)器。稍等一段時(shí)間之后則可以copy完畢,如下圖所示:
真心尷尬,根目錄 / 的磁盤空間用完了,導(dǎo)致復(fù)制過(guò)程終止,我們將這個(gè)復(fù)制到一半的文件刪除掉。
我發(fā)現(xiàn) /data2 的磁盤空間很充裕,因此我將文件復(fù)制到 /data2目錄下,如下圖所示
復(fù)制完畢之后,查看 /data2 目錄,發(fā)現(xiàn) 復(fù)制過(guò)來(lái)的 sonatype-work-2017-12-14.tar.gz 文件也是 2770940709個(gè)字節(jié),完整復(fù)制過(guò)來(lái)了。
三、解壓備份文件
因?yàn)?根目錄 / 下的磁盤空間不足,因此我們將剛才的壓縮包解壓到 /data2目錄下。如下所示:
tar -zxvf sonatype-work-2017-12-14.tar.gz解壓過(guò)程
解壓好后,會(huì)生成一個(gè) sonatype-work目錄。如下圖所示:
四、還原倉(cāng)庫(kù)
因?yàn)槲覀冃碌腘exus OSS私服倉(cāng)庫(kù)之前制定的倉(cāng)庫(kù)地址為
[root@localhost local]# cd nexus-2.12.1-01/ [root@localhost nexus-2.12.1-01]# ll 總用量 40 drwxr-xr-x 3 1001 1001 4096 12月 13 16:27 bin drwxr-xr-x 2 1001 1001 4096 12月 13 18:06 conf drwxr-xr-x 2 1001 1001 4096 12月 13 16:27 lib -rw-r--r-- 1 1001 1001 11006 3月 3 2016 LICENSE.txt drwxr-xr-x 2 1001 1001 4096 12月 13 18:08 logs drwxr-xr-x 4 1001 1001 4096 12月 13 16:27 nexus -rw-r--r-- 1 1001 1001 782 3月 3 2016 NOTICE.txt drwxr-xr-x 5 1001 1001 4096 12月 13 18:08 tmp [root@localhost nexus-2.12.1-01]# pwd /usr/local/nexus-2.12.1-01 [root@localhost nexus-2.12.1-01]# cat conf/nexus.properties # # Sonatype Nexus (TM) Open Source Version # Copyright (c) 2008-present Sonatype, Inc. # All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. # # This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, # which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. # # Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks # of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the # Eclipse Foundation. All other trademarks are the property of their respective owners. ## Sonatype Nexus # ============== # This is the most basic configuration of Nexus.# Jetty section application-port=8081 application-host=0.0.0.0 nexus-webapp=${bundleBasedir}/nexus nexus-webapp-context-path=/nexus# Nexus section nexus-work=${bundleBasedir}/../sonatype-work/nexus runtime=${bundleBasedir}/nexus/WEB-INF [root@localhost nexus-2.12.1-01]#現(xiàn)在我們將老的Nexus OSS私服倉(cāng)庫(kù)的備份倉(cāng)庫(kù) 解壓到了 /data2目錄下,因此我們需要修改nexus/conf/nexus.properties配置文件,重新指定倉(cāng)庫(kù)的目錄為 /data2/sonatype-work/nexus
我們修改 /usr/local/nexus-2.12.1-01/conf/nexus.properties 文件
[root@localhost nexus]# vim /usr/local/nexus-2.12.1-01/conf/nexus.properties修改后的配置文件如下所示
# # Sonatype Nexus (TM) Open Source Version # Copyright (c) 2008-present Sonatype, Inc. # All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. # # This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, # which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. # # Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks # of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the # Eclipse Foundation. All other trademarks are the property of their respective owners. ## Sonatype Nexus # ============== # This is the most basic configuration of Nexus.# Jetty section application-port=8081 application-host=0.0.0.0 nexus-webapp=${bundleBasedir}/nexus nexus-webapp-context-path=/nexus# Nexus section #nexus-work=${bundleBasedir}/../sonatype-work/nexus #新的地址為 nexus-work=/data2/sonatype-work/nexus runtime=${bundleBasedir}/nexus/WEB-INF五、重啟Nexus
使用 /etc/init.d/nexus2 restart 命令 重啟Nexus服務(wù)
[root@localhost nexus]# /etc/init.d/nexus2 Usage: /etc/init.d/nexus2 { console | start | stop | restart | status | dump } [root@localhost nexus]# /etc/init.d/nexus2 restart **************************************** WARNING - NOT RECOMMENDED TO RUN AS ROOT **************************************** Stopping Nexus OSS... Stopped Nexus OSS. Starting Nexus OSS... Started Nexus OSS. [root@localhost nexus]#重啟完后,刷新瀏覽器查看新的Nexus服務(wù)器,如下所示
對(duì)比下,老的Nexus服務(wù)器
除了IP地址不一樣之外,其他的都一樣,遷移成功!
測(cè)試了下之前在博客 【我的Android進(jìn)階之旅】快速創(chuàng)建和根據(jù)不同的版本類型(Dev、Beta、Release)發(fā)布Android 開(kāi)發(fā)庫(kù)到Maven私服 中寫的Gradle腳本上傳到新的Nexus服務(wù)器也是正常的!
參考鏈接
- http://blog.csdn.net/ouyang_peng/article/details/78793038
- http://blog.csdn.net/vbaspdelphi/article/details/52870530
- http://blog.csdn.net/kinglyjn/article/details/53585721
- http://blog.csdn.net/north_eagle/article/details/42428219
- http://blog.csdn.net/puregold1124/article/details/45690785
- http://blog.csdn.net/ouyang_peng/article/details/56872556
作者:歐陽(yáng)鵬 歡迎轉(zhuǎn)載,與人分享是進(jìn)步的源泉!
轉(zhuǎn)載請(qǐng)保留原文地址:http://blog.csdn.net/ouyang_peng/article/details/78796215
本文同步發(fā)表在阿里云棲:https://yq.aliyun.com/articles/283565?spm=5176.blogshare283565.0.0.31jPfx
如果覺(jué)得本文對(duì)您有所幫助,歡迎您掃碼下圖所示的支付寶和微信支付二維碼對(duì)本文進(jìn)行隨意打賞。您的支持將鼓勵(lì)我繼續(xù)創(chuàng)作!
總結(jié)
以上是生活随笔為你收集整理的【Maven学习】Nexus OSS私服仓库的备份与迁移的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: POJ1741:Tree——题解+树分治
- 下一篇: Java solr 分词