Nexus to build a MAVEN game server example

Source: Internet
Author: User
Tags ldap wrapper nginx reverse proxy sonatype

After the local build has the following advantages: 1, accelerate the construction; 2, save bandwidth, 3, save the central Maven warehouse bandwidth, 4, stable (when the central server problem) 5, control and audit, 6, can deploy Third-party components, 7, can build local internal warehouses, 8, can establish a public warehouse. Is it not enough to attract you with so many advantages?


One, Nexus download installation
1, the installation of Nexus

The Official Download archive page is: http://www.sonatype.org/nexus/archived

The above page can be downloaded to all current versions of Nexus, currently the latest version of 2.7.2, the official provides the tar, war, zip three format download. I am downloading a zip package here.

The code is as follows Copy Code

#cd/app
#mkdir Nexus
#cd Nexus
#wget Http://download.sonatype.com/nexus/oss/nexus-2.7.2-bundle.zip
#unzip Nexus-2.7.2-bundle.zip
#cd Nexus-2.7.2/bin
#sh Nexus Start

Note: Nexus because it is developed in the Java language, it relies on the Java environment to first confirm that there is a Java environment on the host, and if it is a Windows host, start Nexus.bat or bin/jsw/ WINDOWS-X86-32 (or 64) to the appropriate directory to start or install the service.

Error 1:

[Root@localhost bin]# SH Nexus start
****************************************
Warning-not recommended to RUN as ROOT
****************************************
If you are insist running as root, then set the environment variable run_as_user=root the before this script.

The reason for the error on the www.111cn.net is simple because the root user is used. The solution is simple, a new user nexus or WWW, and then give the right to restart.

The code is as follows Copy Code

#useradd www
#chown Www:www/app/nexus
#su www
#sh Nexus Start

Error 2:

Wrapper | JVM exited while loading the application.
JVM 5 | Exception in thread "main" Java.lang.unsupportedclassversionerror:org/sonatype/nexus/bootstrap/jsw/jswlauncher: Unsupported Major.minor version 51.0
JVM 5 | At Java.lang.ClassLoader.defineClass1 (Native method)
JVM 5 | At Java.lang.ClassLoader.defineClassCond (classloader.java:631)
JVM 5 | At Java.lang.ClassLoader.defineClass (classloader.java:615)
JVM 5 | At Java.security.SecureClassLoader.defineClass (secureclassloader.java:141)
JVM 5 | At Java.net.URLClassLoader.defineClass (urlclassloader.java:283)
JVM 5 | At java.net.urlclassloader.access$000 (urlclassloader.java:58)
JVM 5 | At Java.net.urlclassloader$1.run (urlclassloader.java:197)
JVM 5 | At Java.security.AccessController.doPrivileged (Native method)
JVM 5 | At Java.net.URLClassLoader.findClass (urlclassloader.java:190)
JVM 5 | At Java.lang.ClassLoader.loadClass (classloader.java:306)
JVM 5 | At Sun.misc.launcher$appclassloader.loadclass (launcher.java:301)
JVM 5 | At Java.lang.ClassLoader.loadClass (classloader.java:247)
JVM 5 | Could not find the main class:org.sonatype.nexus.bootstrap.jsw.JswLauncher. Program would exit.
Wrapper | There were 5 failed launches in a row, each lasting less-than. Giving up.
Wrapper | There may be a configuration problem:please check the logs.
Wrapper | <--wrapper Stopped

The reason for this is that the latest version of Maven needs to rely on java1.7, a problem that has been encountered during the company's Nexus upgrade. Here just to do the demo, lazy on the test machine to replace the JDK, directly under the nexus-2.5 version. Then redo the steps above.

Error 3:

Ception:address already in use
JVM 1 | Java.net.BindException:Address already in use
JVM 1 | At Sun.nio.ch.Net.bind (Native method) ~[na:1.6.0_29]

Because the default 8081 port, has been occupied by another program, Vim/app/nexus/nexus-2.5.0-04/conf/nexus.properties, find application-port=8081 change the lower port, and then reboot. Through the Http://IP: The port can be accessed, after login, the upper right corner has the login option, the default username password is admin/admin123.
2, Nginx reverse proxy Nexus

The code is as follows Copy Code

server {
Listen 80;
server_name maven.361way.com; Domain Name of the configuration
Location/{
Proxy_pass http://127.0.0.1:8081; Jump to the address
Proxy_redirect off;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for
$proxy _add_x_forwarded_for;
}
}


Second, Nexus configuration
1. LDAP authentication

As shown in the following illustration, select the Security-->ldap Configuration on the left, followed by the following configuration:

The code is as follows Copy Code

Nexusladp1

Nexusladp2

Action Method security->roles->add->external role

Mapping,realm Select Ldap,role If there is no data, the LDAP is not set up, role Select a group, click Create Mapping.

Then select Add in configuration, add two permissions, one is Nexus deployment role, and one is all maven repositories.

Then the small partners in the corresponding group will have permission.

2. Nexus Warehouse

Nexus has four types of warehouses: Group (Warehouse Group), hosted (host), Proxy (proxy), virtual (dummy), a common group warehouse that is found after the first logon, which contains the following.

Public repositories: Warehouse Group

3rd party: Component warehouses for Third-party releases that cannot be obtained from public warehouses
Apache Snapshots: Component warehouse with Agent Apachemaven Warehouse snapshot version
Central: A warehouse that is used to broker a release build widget in the Maven centralized warehouse
Central M1 Shadow: A component mirroring warehouse that provides a release version of the M1 format in a centralized warehouse
Codehaus Snapshots: Warehouse used to broker the snapshot version widget for the Codehausmaven warehouse
Releases: Host type warehouse used to deploy management internal release build artifacts
Snapshots: The host type Warehouse used to deploy the snapshot version artifacts within management

3. Configure remote Indexing

The newly built NEUXS environment is just an empty warehouse, need to synchronize manually and Remote Central Library, nexus The default is to turn off remote index download, the most important thing is to open the remote index download. Click the repositories on the left administration menu to locate the three warehouses in the right-hand warehouse list Apache
Snapshots,codehaus Snapshots and Maven
The download Remote indexes is then modified to true by the configuration of the warehouse.

Mavneindex

After this setting, Nexus will automatically download the index file from the Remote central warehouse, in order to check whether the automatic download of the index file is effective, can be changed to browse index, such as to see indexed directory, said already OK.

Note: This can be set according to their actual needs, to avoid all open words will occupy bandwidth (a large number of download remote files), two is likely to have the possibility of a burst (this will be mentioned later).
4, the establishment of the host warehouse

To create a new company's internal warehouse, step to repositories–> add–> hosted Repository, fill in the Repository ID and Repository name in the lower half of the page, such as filling in test and Test repostiory, deployment policy is set to allow redeploy, click Save to create a complete.

Mavenhost

Nexusadd
5. Nexus Warehouse Group

Nexus
The concept of a medium warehouse group is not maven, and in Maven's view, whether you are hosted, proxy or group, is the same for me, I just
Groupid,artifactid,version and other information to you to the component. To facilitate the configuration of MAVEN, Nexus is able to store multiple warehouses, hosted, or
The proxy is merged into a group so that Maven relies on only one group to use the contents of all the warehouses that the group contains.

Neuxs Default has a name of "public www.111cn.nEt
Repositories "group, click on the group to adjust the warehouse he protected, and put the company's internal warehouse test just established
Repostiory joins, so there is no need to explicitly specify the address of the internal warehouse in Maven. Create a group at the same time
ID is public-snapshots, Group name is public snapshots
Repositories's group, put Apache snapshots, Codehaus snapshots, snapshots and ZfY
Repostiory to join them.

Mavengroup


Nexusgroup2
Third, MAVEN client configuration

Settings.xml file for MAVEN client

The code is as follows Copy Code

#vim/app/maven/conf/settings.xml
<?xml version= "1.0" encoding= "UTF-8"?>
<settings xmlns= "http://maven.apache.org/SETTINGS/1.0.0"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation= "http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" >
<pluginGroups></pluginGroups>
<proxies></proxies>
<servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus-releases</id>
<mirrorOf>*</mirrorOf>
<url>http://maven.361way.com/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>nexus-snapshots</id>
<mirrorOf>*</mirrorOf>
<url>http://maven.361way.com/nexus/content/groups/public-snapshots</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus-releases</id>
<url>http://nexus-releases</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>nexus-snapshots</id>
<url>http://nexus-snapshots</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus-releases</id>
<url>http://nexus-releases</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
<pluginRepository>
<id>nexus-snapshots</id>
<url>http://nexus-snapshots</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>

Note: When configuring LDAP authentication in the settings file, the default is to save the plaintext password, which is not very secure and can generate the encrypted password file by mvn the--encrypt-master-password password. This is required MVN version support, you can view the official documents and configuration instructions.

Pom.xml files under the MAVEN project

<distributionManagement>
<!--Two IDs must be consistent with <server><id>nexus-releases</id></server> in Setting.xml--> < Repository>
<id>nexus-releases</id>
<name>nexus Release repository</name>
<url>http://maven.361way.com/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>nexus Snapshot repository</name>
<url>http://maven.361way.com/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

Iv. Matters of note
1, the solution of the problem of the burst warehouse

Login->scheduled Tasks->add, add a scheduled task to clean up the directory regularly. The last option "remove if released" need to be cautious, usually development may not be particularly formal when the time may be snapshot and release are needed.
2, reduce the back-end pressure

This method is also learned from the Internet, can be opened by the front-end Nginx cache function to reduce the back-end Nexus maven warehouse pressure.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.