Synology DS218 + do maven private server (nexus3)

background

I am a Java engineer. Desktops, laptops, and virtual machines may be used to compile and build maven projects when I am at home. When I have a maven private server at home, the effect of building speed is obvious;

Tangled

After preparing a computer to deploy the private server, is it 24 hours to boot? It seems a bit wasteful, so turn it on when you use it, and turn it off when you are done? Slightly troublesome (Do you want to scold me for being lazy? You scolded right ...)

Synology DS218 +

There is a Synology DS218 + at home. For a long time, it has been turned on for 24 hours to serve the whole family. If you can bring private clothing here, it seems that the previous tangle is gone;

  1. The picture below is what DS218 + just bought. Two NAS hard drives have been in stable service:
    Insert picture description here
  2. The following picture is a memory stick purchased online. Now a total of 2 + 8 = 10G memory, sufficient memory is the guts to dare toss:
    Insert picture description here

Ideas

In fact, the operation is very simple: Synology has a docker service, you can use docker to deploy nexus, so this article is actually the basic operation record of Synology docker, the following are the points to note:

  1. Container port
  2. Container data volume
  3. File Permissions
  4. Login container operation

Environmental information

  1. Synology System: DSM 6.2.2-24922 Update 4
  2. Resources of Synology before deploying nexus:
    Insert picture description here
  3. Open Docker, search for nexus on the registry page , find sonatype / nexus3 , select the label 3.19.1 , as shown below:
    Insert picture description here
  4. After the image is downloaded, select the image on the image page and click the start button:
    Insert picture description here
  5. Click Advanced Settings on the startup page :
    Insert picture description here
  6. Allow the container to restart automatically and create a desktop shortcut:
    Insert picture description here
  7. For data volume mapping, create a new folder named nexus3 on the host machine according to the following diagram :
    Insert picture description here
  8. Then map the container's / nexus-data directory to the host's nexus3, so that all the data of the container can be saved:
    Insert picture description here
  9. Port mapping, if the 8081 port of the host is not occupied, map it directly to 8081, otherwise change to an unoccupied one:
    Insert picture description here
  10. After the setting is completed, run the container after checking the wizard , and then click Apply to create the nexus3 container:
    Insert picture description here
  11. I thought it was done like this, but I didn't expect many error messages to pop up:
    Insert picture description here
  12. As shown below, view the container log:
    Insert picture description here
  13. I quickly found the problem: the host mapped to the container's directory, and the container process failed to write due to permissions:
    Insert picture description here
  14. Think about it too. For security reasons, the host's nexus3 directory and containers cannot be manipulated at will. Here we will let go of the write permission of this directory, as shown in the following figure, use File Station to set this directory:
    Insert picture description here
  15. Increase write permissions:
    Insert picture description here
  16. After the above operation is completed, it starts to wait, because the container will automatically restart after each unexpected exit, and finally, I see the log of the successful startup:
    Insert picture description here

Operation nexus3

  1. My intranet IP of Synology is 192.168.50.42 , so the browser access address: http://192.168.50.42:8081, the familiar page comes out:
    Insert picture description here
  2. The next question to face is how to obtain the login password. The default password of nexus is stored in the /nexus-data/admin.password file of the container, so there are two methods to obtain it.
  3. The / nexus-data directory of the container has been mapped to the docker / nexus3 directory of the host machine , so use File Statiion to open the directory, download the admin.password file, and then open it with a text editor:
    Insert picture description here
  4. Another method is to enter the container to view the file, the operation is as follows, select the container to add a command:
    Insert picture description here
  5. Enter / bin / bash in the input box that pops up , so that a new bash process is created under the container's namespace. This process can see all files under the same namespace, including /nexus-data/admin.password, and then use the cat command Just check the contents of the file:
    Insert picture description here
  6. After getting the password, you can log in to nexus on the page, the account is admin :
    Insert picture description here
  7. After successful login, follow the prompts to set a new password:
    Insert picture description here
  8. Next is the normal operation of nexus. I wo n’t say more here. Let ’s focus on it. Create a new account bolingcavalry with administrator rights and set the password to 123456 :
    Insert picture description here
  9. Obtain the address of the central warehouse of the private server:
    Insert picture description here
  10. At this point, the deployment is successful. Next, verify whether the private server is easy to use.

Prepare two computers to verify Nexus service

The following figure is the architecture diagram after deploying the private server:
Insert picture description here
prepare two computers, computer A and computer B, to verify that the newly deployed Nexus3 can cache the jar package of the central warehouse (you can also create two computers with a virtual machine);

  1. Both computers A and B have JDK8 and Maven3 installed;
  2. The conf / settings.xml files in the maven directory on both computers A and B must be modified as follows;
  3. Find the servers node and add the following:
<server>
  <id>maven-central</id>
  <username>bolingcavalry</username>
  <password>123456</password>
</server>
  1. Find the mirrors node and add the following content, where the content of the url is the maven-central warehouse address obtained earlier :
<mirror>
  <id>maven-central</id>
  <mirrorOf>*</mirrorOf>
  <url>http://192.168.50.42:8081/repository/maven-central/</url>
</mirror>

Compile the build project on computer A (should be slow)

Compile the open source project spring-cloud-alibaba on the A computer. At this time, there is no jar package cached on the Nexus, so the compilation speed will be very slow, because all dependent jars must be downloaded from the central warehouse, let's try:

  1. Log in to computer A and download the 2.1.1.RELEASE archive package of spring-cloud-alibaba:
wget https://github.com/alibaba/spring-cloud-alibaba/archive/v2.1.1.RELEASE.tar.gz
  1. Unzip the downloaded file:
tar -zxvf v2.1.1.RELEASE.tar.gz
  1. Enter the unzipped directory:
cd spring-cloud-alibaba-2.1.1.RELEASE/
  1. Compile:
mvn clean compile -U -DskipTests
  1. Compilation is complete, as shown in the red box below, this compilation takes 7 minutes and 32 seconds :
    Insert picture description here
  2. Take a look on the Nexus webpage, as shown below, at this time, a lot of jars have been cached:
    Insert picture description here

Compile the build project on B computer (should be soon)

  1. Do the same operation on the B computer. At this time, the jar package required for compilation has been cached on the Nexus. The compilation process is significantly faster. The final operation result is as shown in the figure below, which takes only 1 minute and 8 seconds :
    Insert picture description here
  2. Looking at the resources occupied by the nexus service, a lot of memory is used. If no memory stick is added, it is estimated that the use of its own 2G memory will drag down the entire Synology. Although the container can limit the memory, it will also cause frequent GC of the nexus process. It's still very card, so it is necessary to ensure sufficient memory: So
    Insert picture description here
    far, the actual combat of deploying maven private server for Synology DS218 + is completed. From now on, the code at home can be regarded as a stable private server, no need to care, and it is available at any time.

Welcome to pay attention to my public number: programmer Xinchen

Insert picture description here

Published 376 original articles · praised 986 · 1.28 million views

Guess you like

Origin blog.csdn.net/boling_cavalry/article/details/105458466