This article is published under a SIGNATURE 4.0 International (CC BY 4.0) license. Signature 4.0 International (CC BY 4.0)

Author: Su Yang

Creation time: in 2018, statistical word: October 8, 2455 – word reading time: 5 minutes to read this article links: soulteary.com/2018/10/08/…


Migrate Nexus software repository gleanings

Before National Day, I carried out a complete migration of the services running on the old equipment. However, there are a few small details that are interesting in migrating the code repository.

Start a new repository service instance

Because all of my service configuration is stored in CVS, starting the service on a new machine is a two-step process with Git Clone and Docker-compose Up.

Then point the resolution from the old device to the new device in DNSMASQ, for example:

Address=/docker.lab.com/10.11.12.232 address=/npm.lab.com/10.11.12.232 address=/nexus.lab.com/10.11.12.232Copy the code

Migrate warehouse data

Previously, I used Mount to save persistent data. The advantage of this method is that there is almost no accidental damage to useful data by docker Prune or other operations.

However, the disadvantages are also obvious, simple compression package, data migration for this scenario is not good.

Here’s a simple solution: Batch download packages previously stored in the old repository and push them back to the new repository.

Transfer the Docker image

After downloading the image to be transferred using Docker pull, use docker images command, grep and awk to quickly screen out the image name and version to be transferred.

$ docker images | grep 'docker.lab.com' | grep -v '<none>' | awk '{printf("%s:%s\n", $1, $2)}'Docker.lab.com/hugo-post-adapter:1.0.0-convert docker.lab.com/aria2:1.0.0 docker.lab.com/pushover.lab.com:0.0.1 Docker.lab.com/sonar.lab.com:7.3...Copy the code

These images are then pushed to the new repository one by one using Xargs.

$ docker images | grep 'docker.lab.com' | grep -v '<none>' | awk '{printf("%s:%s\n", $1, $2)}'| xargs -I {} docker push {} The push refers to repository [docker.lab.com/hugo-post-adapter] d48cccfd71ab: Pushed d04f8a556ca9: Pushed e58056ca81cc: Pushed 984705602673: Pushed 6a2901185647: Pushed 2d4ed44f6fa7: Pushed 35e23a957234: Pushed 894a6015dedf: Pushed 2d790067a9f7: Pushed 32b5d1364b1c: Pushed fbebd655f9aa: Pushed 90e156c66608: Pushed a5a2fa193409: Pushed bc912d07a289: Pushed 905f2907ec29: Pushed 73046094a9b8: Pushed 1.0.0 - convert: digest: sha256: fe391b4bcd2f2af0373b969f68f3f56a0ca1ac097257160c4abf135d31d39a7d size: 3668 The push refers to repository [docker.lab.com/aria2] 165e36b92662: Pushed a1da261fbc00: Pushed 5e8644249a98: PushedCopy the code

Of course, if you want to do a full backup instead of simply pushing the image back to a new repository, you can use the following script:

docker images | tail -n +2 | grep -v "<none>" | awk '{printf("%s:%s\n", $1, $2)}' | while read IMAGE; do
    echo "find image: $IMAGE"
    filename="$(echo $IMAGE| tr ':' '-' | tr '/' '-').tar"
    echo "save as $filename"
    docker save ${IMAGE} -o $filename
done
Copy the code

Transfer of NPM package

Git Checkout releaseTag, and then go back to NPM pub.

Nexus 3.3.x image permission problem

If you use a Nexus 3.3.x image and map data to an external file system, you will most likely encounter the following error.

mkdir: cannot create directory '.. /sonatype-work/nexus3/log': Permission denied

mkdir: cannot create directory '.. /sonatype-work/nexus3/tmp': Permission denied Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file .. /sonatype-work/nexus3/log/jvm.log due to No such file or directory
Copy the code

The solution is simple: run the following command on your mapped external file system to set directory ownership to 200.

sudo chown -R 200 ~/dockerVolume/nexus
Copy the code

The last

The Nexus may have a simpler management interface than some of its newer competitors, but it is excellent both in terms of resource usage and overall software stability.

During my nearly one year of use, I have accumulated nearly 5G code package (Hosted + Proxy) and image files (Hosted) on it. When migrating, I found that the disk fragment generated is only less than 100M, and it supports cluster mode, almost all the language warehouse protocols on the market, and has scheduled tasks…

If you or your team are using CI/CD for agile development, but lack a stable internal repository, this is a great software to try out.

If you are interested in learning about how to build and use the Nexus, maybe I can write a detailed article from build to use.

– EOF


I now have a small toss group, which gathered some like to toss small partners.

In the case of no advertisement, we will talk about software, HomeLab and some programming problems together, and also share some technical salon information in the group from time to time.

Like to toss small partners welcome to scan code to add friends. (Please indicate source and purpose, otherwise it will not be approved.

All this stuff about getting into groups