Overview
theory
If you are not interested, you can simply ignore it. Nexus3, the 3.* version of nexus, has very powerful functions and supports many languages and types of warehouses. Take the 3.29.2-02 installed in this article as an example, it supports: apt, bower, cocoapods, conan, conda, docker, gitlfs, go, helm, maven2, npm, nuget, p2, pypi, r, raw, rubygems, yum.
User roles and permissions
Nexus scheduling task
Nexus provides a series of configurable scheduling tasks to facilitate users to manage the system. The user can set the cron expression for these tasks to run. The scheduled task will run in the background when appropriate. To create a scheduled task, click "Scheduled Tasks" in the navigation menu on the left, then click the Add button on the interface on the right, and fill in the relevant content according to the prompts on the page.
Nexus includes the following types of scheduling tasks:
- Download Indexs: Download remote indexes for the agent warehouse
- Empty Trash: Empty the Nexus recycle bin, some operations actually move files to the recycle bin
- Evict Unused Proxied Items From Repository Caches: delete long-unused component caches in the proxy warehouse
- Expire Repository Cache: Nexus maintains remote warehouse information for the proxy warehouse to avoid unnecessary network traffic. This task clears this information to force Nexus to regain the remote warehouse information
- Publish Indexs: Publish warehouse indexes into a format that can be used by m2eclipse and other Nexus
- Purge Nexus Timeline: Delete the timeline file of Nexus, which is used to create the system's RSS feed
- Rebuild Maven Metadata Files: recreate the warehouse metadata files based on the warehouse content
maven-metadata.xml
, and recreate the checksum md5 and sha1 of each file - ReIndex Repositories: compile indexes for warehouses
- Remove Snapshots From Repositories: delete the snapshot components of the repository in a configurable way
- Synchronize Shadow Repository: Synchronize the contents of the virtual warehouse (service based on Maven1)
installation
Download the archive file:
wget
unpack:
tar -zxvf nexus-3.29.2-02-unix.tar.gz
To the specified directory:
mv nexus-3.29.2-02 /usr/local/nexus3
Configure your browser to access the IP and port number:
vim /usr/local/nexus3/etc/nexus-default.properties
will be application-host=0.0.0.0
amended to application-host=<your_ip>
, or use the default port of 8081.
Switch to the bin directory:
cd /usr/local/nexus3/bin/
start up:
./nexus start
At this point, you should be able to open the browser to access the address just configured:http://<ip>:8081
If it doesn't work, generally the firewall is not turned off. Since it is a private server built on the intranet, you can safely turn off the firewall:
systemctl stop firewalld
Set to start automatically after booting:
systemctl enable nexus
If an error is reported:
Unit nexus.service could not be found.
Then create a connection to /etc/init.d:
ln -s /usr/local/nexus3/bin/nexus /etc/init.d/nexus
Set to boot up:
systemctl enable nexus
Output:
nexus.service is not a native service, redirecting to systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable nexus
It shows success.
Successful installation interface:
Add Alibaba Cloud proxy warehouse
As shown in the figure: It
can be seen that there are three types of warehouses:
- Hosted: Local warehouse, you can deploy your own components to this type of warehouse. For example, the company's second party library;
- Proxy: proxy warehouse, used to proxy remote public warehouses, such as maven central warehouse;
- Group: Warehouse group, used to merge multiple hosted/proxy warehouses. When the project needs to reference multiple repository resources, you only need to put these resources in a group and reference this group;
Note that you must first log in:
After logging in, only to configure permissions:
Add warehouse:
because the agent is added Ali cloud storage, so choose Proxy Type:
three pieces of information must be configured:
the first represents the uniqueness of the name, you can enter aliyun;
first One is the address. Since it is Alibaba Cloud, enter http://maven.aliyun.com/nexus/content/groups/public/; the
third is the storage location. Click the drop-down list and select default.
At this point, the Alibaba Cloud proxy warehouse has been added successfully, but it is not recommended to use it directly. The purpose of building a nexus private server is not just to copy the jar of the Alibaba Cloud maven warehouse on the private server warehouse on your own intranet. This does not improve the build much. speed.
please watch the following part.
Combine settings.xml
The Hosted type warehouse mentioned above, the applicable scenario is mainly that Project A needs to reference the jar of Project B, and then download it from the nexus private server warehouse on the intranet.
Therefore, we also need to add a Hosted type warehouse, which is similar to the steps of adding a proxy warehouse above, except that this type of warehouse only needs to configure two parameters, a name and storage location that represents the uniqueness of the warehouse.
Question, why does Nexus provide Group type warehouses?
Imagine: In rare cases, if the required jar package cannot be found in Alibaba Cloud, do you still need to add proxy warehouses with other addresses? Do you have to add several warehouse mirror addresses to the settings.xml configuration file?
Therefore, the Group type warehouse is introduced. There are three configuration items that must be filled in, a unique name and storage address, and a subordinate warehouse (Member repositories):
renderings: the
left side is the alternative warehouse, the right side is the selected warehouse, pay attention to the priority order .
Final renderings:
select group, click copy, get http://xxx:8081/repository/group/
the address like:, put it settings.xml
in:
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<name>aliyun</name>
<url>http://xxx:8081/repository/group/</url>
</mirror>
</mirrors>
Reference: Use Nexus3 to build Maven private server + upload third-party jar package to local maven warehouse
Configure JVM parameters
Switch to the directory /usr/local/nexus3/bin
, there is a nexus.vmoptions
file, which is very similar to the JVM startup parameters or IDEA's JVM reference configuration file.
Could not transfer artifact 401 Unauthorized
The settings.xml
server tag needs to be configured in the, where the user name and password are set during the installation process:
<servers>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin</password>
</server>
<server>
<id>releases</id>
<username>admin</username>
<password>admin</password>
</server>
</servers>
mvn ERROR xxx for default is missing
mvn clean
Execution error:
[ERROR] Error executing Maven.
[ERROR] 2 problems were encountered while building the effective settings
[ERROR] 'mirrors.mirror.url' for default is missing @ C:\Users\johnn\.m2\settings.xml
[ERROR] 'mirrors.mirror.mirrorOf' for default is missing @ C:\Users\johnn\.m2\settings.xml
The reason is that there is an empty label, just delete it:
<mirror>
</mirror>
Upload to Nexus3 private server
Use mvn deploy
naming to upload the local jar to nexus private server.
If an error is reported:
Failed to deploy artifacts: Could not transfer artifact XXX from/to releases (http://xxxx:8081/repository/maven-releases/) 400 Bad Request
Error analysis:
mvn deploy
A 400 error occurs when the jar package already exists in the nexus3 private server. The reason is that the release default library does not allow repeated deployment, that is, the default is disable redeploy .
Solution:
Log in to the private server, find the warehouse where the error is reported, for example maven-releases
, and modify the deployment policy (Deployment policy) to Allow redeploy :
mvn deploy problem
was cached in the local repository, resolution will not be reattempted until the
solution:
modify the settings.xml
file and add the warehouse <updatePolicy>always</updatePolicy>
to force the dependent library to be updated every time.
Delete useless repository