As shown in the figure below, after deploying Nexus on the local area network, the jars in the central warehouse can be cached, and the developed second-party libraries can be published on Nexus. Others in the local area network can also download these second-party libraries from Nexus for use:
The actual combat is to install Nexus3 through Docker on the Linux server:
apt-get update
apt-get install -y curl
curl -sSL https://get.docker.com | sh
mkdir -p /usr/local/work/nexus-data && chown -R 200/usr/local/work/nexus-data
docker run -d \
- p 8081:8081 \
- - name nexus \
- v /usr/local/work/nexus-data:/nexus-data \
sonatype/nexus3:3.19.1
The above command has many parameters, there are several points to note:
a. Port 8081 of the container is mapped to port 8081 of [Host] (https://cloud.tencent.com/product/cdh?from=10680);
b. The container name is nexus;
c. The /nexus-data/ directory of the container is mapped to /usr/local/work/nexus-data/ of the host;
d. The image is the official version 3.19.1 of sonatype;
echo `docker exec nexus cat /nexus-data/admin.password`
What I got here is 2c9c5399-d0da-48ec-9050-dc4f43cede10
2. Click Sign in in the red box in the upper right corner of the figure below to enter the login page:
In actual use, for security reasons, each user cannot use the admin account. You can create a role first, add various permissions to the role according to actual needs, and then create an account under this role:
At this point, the deployment of Nexus3 is complete. Next, verify whether Nexus can provide the jar cache function;
The next thing to verify is the ability of Nexus to cache the jar packages of the central warehouse, and see if Nexus can allow us to download the required jars faster during the development and construction process;
The conf/settings.xml files in the maven directory on Computer A and Computer B must be modified as follows:
< server><id>maven-central</id><username>bolingcavalry</username><password>888888</password></server>
< mirror><id>maven-central</id><mirrorOf>*</mirrorOf><url>http://192.168.50.75:8081/repository/maven-central/</url></mirror>
Compile the open source project spring-cloud-alibaba on computer A. At this time, there is no jar package cached on Nexus, so the compilation speed will be very slow, because all dependent jars must be downloaded from the central warehouse, let's try:
wget https://github.com/alibaba/spring-cloud-alibaba/archive/v2.1.1.RELEASE.tar.gz
tar -zxvf v2.1.1.RELEASE.tar.gz
cd spring-cloud-alibaba-2.1.1.RELEASE/
mvn clean compile -U -DskipTests
Do the same operation on computer B. At this time, the jar package required for compilation has been cached on Nexus, so the entire compilation process should be significantly faster. The final operation result is shown in the figure below, which only took 1 minute and 6 seconds:
At this point, the actual deployment and experience of Nexus3 on Ubuntu is complete. If you are looking for a simple and quick Nexus deployment plan, I hope this article can give you some reference.
Recommended Posts