Nexus Docker下宕机后修复方式

1. 背景

以Docker启动的nexus仓库服务器在突发断电后重启时提示文件异常如下:

com.orientechnologies.orient.core.exception.OPageIsBrokenException: Following files and pages are detected to be broken ['asset.pcl' :34;], 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.

此问题的解决方案就在错误提醒给出的信息中:To restore database and make it fully operational you may export and import database to and from JSON

问题的原因是nexus所用的orientdb文件损坏,如何修复则需要根据部署情况处理,一般以官方镜像启动的nexus的数据库路径为/nexus-data/db/component(非docker安装可能在不同的位置)

2. 修复

假设数据库路径为/nexus-data/db/component,并且确定 /nexus-data 的目录权限在用户nexus上;
找到orient-console的jar文件,一般在 /opt/sonatype/nexus/lib/support/nexus-orient-console.jar;
/nexus-data 目录下执行 java -jar /opt/sonatype/nexus/lib/support/nexus-orient-console.jar,然后控制台执行如下内容:

OrientDB console v.2.2.36 (build d3beb772c02098ceaea89779a7afd4b7305d3788, branch 2.2.x) https://www.orientdb.com
Type 'help' to display all the supported commands.
orientdb> CONNECT plocal:/nexus-data/db/component admin admin
Connecting to database [plocal:/nexus-data/db/component] with user 'admin'...
......
orientdb {db=component}> export database component-export

......
Database export completed in 5551ms

orientdb {db=component}> drop database

Database 'component' deleted successfully

orientdb> create database plocal:/nexus-data/db/component

Creating database [plocal:/nexus-data/db/component] using the storage type [plocal]...
Database created successfully.

Current database is: plocal:/nexus-data/db/component
orientdb {db=component}> import database component-export.json.gz

Importing database database component-export.json.gz..
......
Database import completed in 28394 ms

执行导出导入操作后,重启服务即可。

你可能感兴趣的:(docker,nexus,异常修复)