Sonatype Nexus 从内置 OrientDB 迁移到独立容器中的 PostgreSQL

注意: 本文主要只是我尝试过的命令集合。我不是 100% 确定正确的做法是什么,但最终这对我有效。在尝试之前确保备份你的数据!

基于官方 Sonatype 迁移说明和我们的 5 分钟 Nexus 配置,但针对 Docker 进行了调整。

确保 Nexus 运行在 3.70.0 版本,并在 docker-compose.yml 中的 Nexus 服务添加 depends_on

nexus_postgres_migration.yml
nexus:
    image: sonatype/nexus3:3.70.0
    # ...
    depends_on:
      - postgres

将 Postgres 配置添加到 .env

nexus_postgres.env
POSTGRES_DB=nexus
POSTGRES_USER=nexus
POSTGRES_PASSWORD=ahyath1thaem4Aedaemeoph5Aadohb

将数据存储配置添加到 nexus_data/etc/nexus.properties

nexus.properties
nexus.datastore.enabled=true

将 PostgreSQL 连接字符串添加到 nexus_data/etc/fabric/nexus-store.properties

nexus-store.properties
username=nexus
password=ahyath1thaem4Aedaemeoph5Aadohb
jdbcUrl=jdbc\:postgresql\://postgres\:5432/nexus

添加 PostgreSQL 容器

docker-compose-nexus-postgres.yml
services:
  postgres:
    image: postgres
    restart: unless-stopped
    volumes:
      - ./pg_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
      - POSTGRES_USER=${POSTGRES_USER}

将迁移工具下载到映射的数据目录中

download_nexus_migrator.sh
cd nexus_data
wget https://download.sonatype.com/nexus/nxrm3-migrator/nexus-db-migrator-3.72.0-01.jar
cd ..

运行迁移工具

run_nexus_migrator.sh
docker-compose run nexus /bin/bash -c 'java -Xmx16G -Xms16G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M -jar /nexus-data/nexus-db-migrator-* --migration_type=postgres --db_url="jdbc:postgresql://postgres:5432/nexus?user=nexus&password=ahyath1thaem4Aedaemeoph5Aadohb"'

Check out similar posts by category: Docker