【Maven学习】Nexus OSS私服仓库的备份与迁移
背景
在上一篇博客 【Maven学习】Nexus OSS私服仓库的安装和配置 中,我们已经在机房搭建好了新的Nexus OSS私服仓库。下面是两个版本的Nexus OSS私服仓库的对比图。
老的Nexus OSS私服仓库
新的Nexus OSS私服仓库
明显老的Nexus OSS私服仓库的内容比新的Nexus OSS私服仓库的内容多。因此我们现在的工作就是将办公室上的老的Nexus服务器上的所有的数据迁移到机房的Nexus服务器。这一篇博客记录下整个Nexus OSS私服仓库的备份与迁移的过程。
一、老的Nexus OSS私服仓库备份
迁移中会遇到三个文件夹 , 打包、拉走 启动即可。
| 名称 | 目录名 | 重要配置文件 |
|---|---|---|
| nexus主目录 | nexus-2.6.4-02 | conf/nexus.properties里面有sonatype-work的地址 |
| sonatype-work目录 | sonatype-work | nexus/conf/nexus.xml里面有storage的地址 |
| storage目录 | storage | 里面主要是各种程序的jar包等 |
迁移流程如下
首先我们在老的Nexus OSS私服仓库的这台Linux服务器上,查看相关的目录信息。
如上图所示,在老的Nexus OSS私服仓库的这台Linux服务器上,
nexus主目录的地址为:/usr/local/nexus-2.12.1-01
在 /usr/local/nexus-2.12.1-01/config/nexus.properties 文件中,指定了sonatype-work的地址
现在我们进入 /usr/local/sonatype-work/nexus/storage目录,查看里面的目录结构
[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
将此目录结构和Nexus管理界面对比,可以一一对应,如下所示。
从上面分析来看,我们只需要将nexus主目录和sonatype-work目录都备份好即可。但是两个Linux服务器的nexus配置的java路径之类的可能不同,我就不备份nexus主目录了。
我只备份sonatype-work目录,Nexus的构件仓库都保存在sonatype-work目录中,该目录的位置由nexus/conf/nexus.properties配置文件指定。
使用 tar命令将 sonatype-work目录 打包压缩为一个 tar.gz文件,命令如下所示
[root@kf1appsvr local]# tar -zcvf sonatype-work-2017-12-14.tar.gz ./sonatype-work/
备份中,整个备份过程比较缓慢,因为两年传上去的的文件和文件夹太多了。
打包完毕
生成了 sonatype-work-2017-12-14.tar.gz 文件,占用了2770940709 字节,差不多2.6G
二、将老的Nexus OSS私服仓库的备份文件复制到新的Nexus OSS私服仓库
上一步我们将整个 sonatype-work 目录打包成一个压缩包 sonatype-work-2017-12-14.tar.gz,现在我们要将这个压缩包复制到新的Nexus OSS私服仓库的Linux服务器上。
我们是有 scp命令来进行复制操作,关于scp命令的操作可以参考之前的文章 git学习——> Gitlab如何进行备份恢复与迁移?
使用scp命令从远程服务器copy文件或者目录到本地
scp 用户名 @IP 地址 : 文件名 1 远程用户名 @IP 地址 : 文件名 2
[用户名 @IP 地址 :] 可以不输入 , 可能需要输入远程用户名所对应的密码 .
可能有用的几个参数 :
-v 和大多数 linux 命令中的 -v 意思一样 , 用来显示进度 . 可以用来查看连接 , 认证 , 或是配置错误 .
-C 使能压缩选项 .
-P 选择端口 . 注意 -p 已经被 rcp 使用 .
-4 强行使用 IPV4 地址 .
-6 强行使用 IPV6 地址 .
例如我使用如下命令,从远程服务器copy刚才的备份文件sonatype-work-2017-12-14.tar.gz到了新服务器的/usr/local 目录下
scp root@老的linux的ip地址:/usr/local/sonatype-work-2017-12-14.tar.gz /usr/local/
我们登录到新的Nexus OSS私服仓库那台linux服务器,然后执行上面的命令
敲了命令之后,需要我们确认是否connecting,我们敲一个yes,接着需要我们输入老的Nexus OSS私服仓库那台linux服务器的密码,如下所示
敲完之后,如果密码正确的话,则将刚才的备份文件copy到这台新的linux服务器。稍等一段时间之后则可以copy完毕,如下图所示:
真心尴尬,根目录 / 的磁盘空间用完了,导致复制过程终止,我们将这个复制到一半的文件删除掉。
我发现 /data2 的磁盘空间很充裕,因此我将文件复制到 /data2目录下,如下图所示
复制完毕之后,查看 /data2 目录,发现 复制过来的 sonatype-work-2017-12-14.tar.gz 文件也是 2770940709个字节,完整复制过来了。
三、解压备份文件
因为 根目录 / 下的磁盘空间不足,因此我们将刚才的压缩包解压到 /data2目录下。如下所示:
tar -zxvf sonatype-work-2017-12-14.tar.gz
解压过程
解压好后,会生成一个 sonatype-work目录。如下图所示:
四、还原仓库
因为我们新的Nexus OSS私服仓库之前制定的仓库地址为
[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]#
现在我们将老的Nexus OSS私服仓库的备份仓库 解压到了 /data2目录下,因此我们需要修改nexus/conf/nexus.properties配置文件,重新指定仓库的目录为 /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服务
[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服务器,如下所示
对比下,老的Nexus服务器
除了IP地址不一样之外,其他的都一样,迁移成功!
测试了下之前在博客 【我的Android进阶之旅】快速创建和根据不同的版本类型(Dev、Beta、Release)发布Android 开发库到Maven私服 中写的Gradle脚本上传到新的Nexus服务器也是正常的!
参考链接
- 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
作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
转载请保留原文地址:http://blog.csdn.net/ouyang_peng/article/details/78796215
本文同步发表在阿里云栖:https://yq.aliyun.com/articles/283565?spm=5176.blogshare283565.0.0.31jPfx如果觉得本文对您有所帮助,欢迎您扫码下图所示的支付宝和微信支付二维码对本文进行随意打赏。您的支持将鼓励我继续创作!
【Maven学习】Nexus OSS私服仓库的备份与迁移的更多相关文章
- Nexus OSS私服仓库的备份与迁移
背景 在上一篇博客 [Maven学习]Nexus OSS私服仓库的安装和配置 中,我们已经在机房搭建好了新的Nexus OSS私服仓库.下面是两个版本的Nexus OSS私服仓库的对比图. 老的Nex ...
- 【Maven学习】Nexus OSS私服仓库的安装和配置
背景 公司的代码依赖是通过Maven进行管理的,而Maven的私库我们使用的是Nexus,目前使用的版本是Nexus Repository Manager OSS 2.12.1. 但是由于之前我们搭建 ...
- MAVEN学习笔记之私服Nexus(2)
MAVEN学习笔记之私服Nexus(2) 私有服务器搭建 Nexus www.snatype.org下载 snatype-work 是默认nexus存储nexus a:将bin添加到环境中 Admin ...
- Maven与Nexus OSS
Maven 是一个项目管理和构建自动化工具,是Apache Fundation下的一个Java项目.常用于Java项目中依赖管理 下载直接去官网 安装Maven 已经编译的二进制包 直接解压到安装目录 ...
- 07 Maven 使用Nexus创建私服
7. Maven 使用Nexus创建私服 私服不是 Maven 的核心概念,它仅仅是一种衍生出来的特殊的 Maven 仓库.通过建立自己的私服,就可以降低中央仓库负荷.节省外网带宽.加速 Maven ...
- maven学习记录四——私服 nexus
8 私服 nexus 安装nexus 启动服务 启动失败的解决方法: 登录nexus 用户名/密码 admin/admin123 仓库类型 Virtual 虚拟仓库 Proxy 代 ...
- Maven学习(三) -- 仓库
标签(空格分隔): 学习笔记 坐标和依赖时任何一个构件在Maven世界中的逻辑表示方式:而构件的物理表示方式是文件,Maven通过仓库来同意管理这些文件. 任何一个构件都有其唯一的坐标,根据这个坐标可 ...
- Maven学习(七)仓库
* Maven仓库 在项目开发中, 项目目录下往往会有一个lib目录,用来存放第三方依赖jar文件, 如spring log4j jar等文件, Maven仓库就是放置JAR文件(WAR,ZIP,P ...
- Maven学习3(中央仓库)
Maven项目在运行的时候,会首先找本地仓库是否有需要的jar,如果没有则去调用远程仓库. 解读Maven在仓库中的存储路径: 1.基于groupId准备路径,将句点分隔符转成路径分隔符,就是将 & ...
随机推荐
- 【Java面试题】50 垃圾回收器的基本原理是什么?垃圾回收器可以马上回收内存吗?有什么办法主动通知虚拟机进行垃圾回收?
1.对于GC来说,当程序员创建对象时,GC就开始监控这个对象的地址.大小以及使用情况. 通常,GC采用有向图的方式记录和管理堆(heap)中的所有对象.通过这种方式确定哪些对象是"可达的&q ...
- Webpack vs Gulp(转载)
理想的前端开发流程 在说构建工具之前得先说说咱期望的前端开发流程是怎样的? 写业务逻辑代码(例如 es6,scss,pug 等) 处理成浏览器认识的(js,css,html) 浏览器自动刷新看到效果 ...
- 如何解决ChemDraw引起的系统崩溃
运行ChemDraw应用程序时,一般不会引起系统崩溃,但在使用CS software产品可能会引发计算机崩溃.为了方便广大用户的使用,本教程将教授大家如何解决ChemDraw运行中引起的系统崩溃. 当 ...
- Nginx伪静态配置和常用Rewrite伪静态规则集锦
伪静态是一种可以把文件后缀改成任何可能的一种方法,如果我想把php文件伪静态成html文件,这种相当简单的,下面我来介绍nginx 伪静态配置方法 nginx里使用伪静态是直接在nginx.conf ...
- Spark Streaming源码分析 – Checkpoint
PersistenceStreaming没有做特别的事情,DStream最终还是以其中的每个RDD作为job进行调度的,所以persistence就以RDD为单位按照原先Spark的方式去做就可以了, ...
- 使用CXF为webservice添加拦截器
拦截器分为Service端和Client端 拦截器是在发送soap消息包的某一个时机拦截soap消息包,对soap消息包的数据进行分析或处理.分为CXF自带的拦截器和自定义的拦截器 1.Servi ...
- mybatis由浅入深day02_2一对一查询_2.2方法一:resultType
2 一对一查询 2.1 需求(查询所有订单信息,关联查询创建订单的用户信息) 查询所有订单信息,关联查询创建订单的用户信息 注意:因为一个订单信息只会是一个人下的订单,所以从查询订单信息出发关联查询用 ...
- MySQL<数据库和表的基本操作>
数据库和表的基本操作 数据库基础知识 创建数据库 就是在数据库系统中划分一块存储数据的空间 CREATE DATABASE itcast; 查看数据库 SHOW CREATE DATABASE 数据库 ...
- Objective-C语法之KVC使用
转自:http://www.cnblogs.com/stoic/archive/2012/07/20/2601315.html 除了一般的赋值和取值的方法,我们还可以用Key-Value-Coding ...
- BI产品学习笔记
理解现在--挖掘规律--预测未来------------------------------------------------------精准营销智能风控运营优化 多维分析挖掘预测敏捷BI 分析展示 ...