解决Nexus异常OrientDB数据库变为只读
目录
注意
本文最后更新于 2024-04-30,文中内容可能已过时。
1 问题描述
- 装有
Nexus
的服务机在异常故障重启后,Nexus
可以正常读取和拉取jar包,但尝试上传时报错 - 打开
Nexus
服务器上的日志文件发现有以下错误
2023-03-10 17:03:28,884+0800 ERROR [delete-path-16-thread-1] admin org.sonatype.nexus.repository.maintenance.internal.DeleteFolderServiceImpl - Failed to delete an asset - skipping.
com.orientechnologies.orient.core.exception.OPageIsBrokenException: Following files and pages are detected to be broken ['browse_node_repository_name_parent_path_name_idx.sbt' :589;], storage is switched to 'read only' mode. Any modification operations are prohibited. To restore database and make it fully operational you may export and import database to and from JSON.
DB name="component"
at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.checkLowDiskSpaceRequestsAndReadOnlyConditions(OAbstractPaginatedStorage.java:5144)
at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.commit(OAbstractPaginatedStorage.java:1729)
at com.orientechnologies.orient.core.tx.OTransactionOptimistic.doCommit(OTransactionOptimistic.java:541)
at com.orientechnologies.orient.core.tx.OTransactionOptimistic.commit(OTransactionOptimistic.java:99)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:2908)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:2870)
at org.sonatype.nexus.repository.storage.StorageTxImpl.commit(StorageTxImpl.java:190)
at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
...
- 报错日志说明的很详细,
Nexus
使用的OrientDB
的其中一个库component
已经变成了read only
只读模式,修复数据库需要将该库导出后再导入。
2 解决步骤
停止nexus进程
./nexus stop
备份准备修复的数据库
注意出错的库名,出错的库不一定是component,具体看出错日志(Nexus的OrientDB有多个库)。
cp -rv /data/sonatype-work/nexus3/db/component /data/component.bak
到Nexus安装目录下/lib/support
下,运行nexus-orient-console.jar
cd /data/nexus3/lib/support
启动console
java -jar nexus-orient-console.jar
如果Nexus库已经很大,在执行后面的导出操作时可能会报heap OOM错误,可以在启动时调大内存
java -jar -Xms4g -Xmx4g nexus-orient-console.jar
连接出错的数据库,执行导出、备份、删除、重建、导入
重要:以下操作有删除动作,注意一定要先做好备份
连接出错的数据库(注意出错的库不见得与笔者一致,注意查看出错日志)
orientdb> connect PLOCAL:/data/sonatype-work/nexus3/db/component admin admin
导出
orientdb {db=component}> EXPORT DATABASE /data/orientdb-component.export
导出的时候如果看到
Checksum verification failed for page
,说明导出的库还是有问题的,可以再次执行导出命令,直至没有问题。
关闭连接
orientdb {db=component}> DISCONNECT
删除出问题的库
orientdb> DROP DATABASE PLOCAL:/data/sonatype-work/nexus3/db/component admin admin
重新创建出问题的库
orientdb> CREATE DATABASE PLOCAL:/data/sonatype-work/nexus3/db/component admin admin
导入
orientdb {db=component}> IMPORT DATABASE /data/orientdb-component.export.gz
关闭连接
orientdb {db=component}> DISCONNECT
退出控制台
orientdb> EXIT
启动nexus进程
./nexus start