Nexus非正常关闭导致数据库异常,二方包无法上传问题

本文详细描述了如何解决Nexus私服上传二方包失败的问题,涉及日志分析、OrientDB数据库读写权限切换、备份与恢复操作,以及重启服务的过程。

安装的nexus私服突然上传不了二方包,排查步骤如下:

1、cd  /apps/data/sonatype-work/nexus3/log/  ,tail -500f nexus.log,错误信息如下:

test_repositories org.sonatype.nexus.repository.httpbridge.internal.ViewServlet - Failure servicing: PUT /repository/testRepositories-snapshot/com/midea/testp/1.0.7-SNAPSHOT/testp-1.0.7-20210720.031426-1.pom
com.orientechnologies.orient.core.exception.OPageIsBrokenException: Following files and pages are detected to be broken ['browse_node_3.cpm' :50;'browse_node_1.cpm' :51;'browse_node.cpm' :53;'asset_bucket_name_idx.sbt' :1053;'browse_node_2.cpm' :52;], storage is switched to 'read only' mode. Any modification operations are prohibited. Typically it means hardware error, before filling a bug please check your hardware. To restore database and make it fully operational you may export and import database to and from JSON.

2、通过错误日志,我们看到:storage is switched to 'read only' mode,很明显nexus库component已经变成了read only只读模式,需要重新创建component仓库,步骤如下:

3、进入nexus安装目录,停止nexus服务,比如我本地安装目录是:/usr/local/nexus-3.7.1-02,cd /usr/local/nexus-3.7.1-02/bin,执行 ./nexus stop

4、查看数据文件存储位置,vim /usr/local/nexus-3.7.1-02/bin/

5、备份数据文件,cd /apps/data/sonatype-work/nexus3/db,执行 cp -rv component /nexus_db_backup/

6、cd /usr/local/nexus-3.7.1-02/lib/support,执行 nexus-orient-console.jar,启动console,命令如:java -jar nexus-orient-console.jar

(注意:如果component仓库数据量比较大,会报java heap OOM错误,可以在启动时调大内存,比如我的启动命令:java -jar -Xms45g -Xmx45g nexus-orient-console.jar)

7、控制台操作步骤如下:

#连接数据库
orientdb> connect PLOCAL:/apps/data/sonatype-work/nexus3/db/component admin admin

#导出数据库
orientdb {db=component}> EXPORT DATABASE /nexus_db_backup/orientdb-component.export

#关闭数据库连接
orientdb {db=component}> DISCONNECT

#删除有问题的数据库
orientdb> DROP DATABASE PLOCAL:/apps/data/sonatype-work/nexus3/db/component admin admin

#重新创建有问题的数据库
orientdb> CREATE DATABASE PLOCAL:/apps/data/sonatype-work/nexus3/db/component admin admin

#导入数据库
orientdb {db=component}> IMPORT DATABASE /nexus_db_backup/orientdb-component.export.gz

#关闭数据库连接
orientdb {db=component}> DISCONNECT

#退出控制台
orientdb> EXIT

8、启动nexus服务,cd /usr/local/nexus-3.7.1-02/bin 执行 ./nexus start

注:如果nexus仓库服务文件比较大,启动nexus服务的时间可能会比较长,大约需要3-5分钟左右

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

luckywei80

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值