转载:http://www.cnblogs.com/zhangqingsh/archive/2013/03/14/2959301.html
@H_301_3@1.1 下载SonaTYpe Nexus:
cd /usr/local/src
wget http://download.sonatype.com/nexus/oss/nexus-2.3.1-01-bundle.tar.gz
1.2 安装:
cd /usr/local/src
sudo cp nexus-2.3.1-01-bundle.tar.gz /usr/local
cd /usr/local
sudo tar xvzf nexus-2.3.1-01-bundle.tar.gz
ln -s nexus-2.3.1-01 nexus
cp nexus/bin/nexus /etc/init.d/nexus
cd /etc/init.d
chmod 755 /etc/init.d/nexus
1.3.1 创建用户组:groupadd -g 104 nexus
1.3.2 创建用户:useradd -u 103 -g 104 -c “Neuxs Maven Repository” nexus
1.4.1 配置/etc/init.d/nexus:
vi /etc/init.d/nexus (修改如下变量)
复制代码
Set this to the root of the Nexus installation
NEXUS_HOME=”/usr/local/nexus”
NOTE - This will set the user which is used to run the Wrapper as well as
the JVM and is not useful in situations where a privileged resource or
port needs to be allocated prior to the user being changed.
RUN_AS_USER=nexus
复制代码
1.4.2 配置/usr/local/nexus/conf/nexus.properties
vi /usr/local/nexus/conf/nexus.properties
复制代码
Jetty section
application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/
Nexus section
nexus-work=
复制代码
1.4.3 配置/usr/local/nexus权限
chown -R nexus:nexus /usr/local/nexus
1.5 启动Nexus
1.5.1 启动:
cd /etc/init.d
chkconfig –add nexus
chkconfig –levels 345 nexus on
service nexus start
启动正常,会得到如下信息:
Starting Nexus OSS… Started Nexus OSS.
1.5.2 监控
tail -f /usr/local/nexus/logs/wrapper.log
1.5.3 查看进程
ps -ef | grep nexus
获得类似如下进程:
nexus 15133 1 0 13:56 ? 00:00:00 /usr/local/nexus/bin/jsw/linux-x86-64/wrapper /usr/local/nexus/bin/jsw/conf/wrapper.conf wrapper.syslog.ident=nexus wrapper.pidfile=/usr/local/nexus/bin/jsw/linux-x86-64/nexus.pid wrapper.daemonize=TRUE
nexus 15135 15133 13 13:56 ? 00:00:21 java -Djava.library.path=bin/jsw/lib -classpath bin/jsw/lib/wrapper-3.2.3.jar:./lib/sisu-jetty8-1.4.2.jar:./lib/logback-core-1.0.7.jar:./lib/jetty-io-8.1.8.v20121106.jar:./lib/jetty-webapp-8.1.8.v20121106.jar:./lib/jetty-http-8.1.8.v20121106.jar:./lib/jetty-servlet-8.1.8.v20121106.jar:./lib/logback-classic-1.0.7.jar:./lib/jetty-server-8.1.8.v20121106.jar:./lib/appcontext-3.2.jar:./lib/jetty-xml-8.1.8.v20121106.jar:./lib/javax.servlet-3.0.0.v201112011016.jar:./lib/jetty-deploy-8.1.8.v20121106.jar:./lib/nexus-bootstrap-2.3.1-01.jar:./lib/jetty-continuation-8.1.8.v20121106.jar:./lib/jetty-security-8.1.8.v20121106.jar:./lib/nexus-logging-extras-appender-2.3.1-01.jar:./lib/jetty-rewrite-8.1.8.v20121106.jar:./lib/slf4j-api-1.7.2.jar:./lib/jetty-util-8.1.8.v20121106.jar:./lib/plexus-interpolation-1.15.jar:./lib/jetty-jmx-8.1.8.v20121106.jar:./conf/ -Dwrapper.key=3C3oeOSu3AweFCPW -Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.pid=15133 -Dwrapper.version=3.2.3 -Dwrapper.native_library=wrapper -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=10 -Dwrapper.jvmid=1 org.sonatype.nexus.bootstrap.jsw.JswLauncher ./conf/jetty.xml
vi /etc/Nginx/Nginx.conf,加入如下server:
复制代码
server{
listen 80;
server_name 192.168.xxx.xxx; (服务器IP或者DNS域名)
#charset koi8-r;
#access_log logs/host.access.log main;
location / { proxy_read_timeout 120; proxy_send_timeout 120; proxy_connect_timeout 120; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://localhost:8081; } error_page 404 /404.html; location = /404.html { root /usr/share/Nginx/html; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/Nginx/html; } }@H_301_3@
4.旧库迁移(Nexus 到 Nexus)
旧库迁移其实非常简单,只需要将旧的库文件拷贝到新库对应位置,然后repair index就可以了。如:
将旧库的“/usr/local/nexus/sonatype-work/nexus/storage/releases”文件夹覆盖到新库的“/usr/local/nexus/sonatype-work/nexus/storage/releases”,然后“repair index”(需要花费一点时间),就可以了。
参考:https://support.sonatype.com/entries/21602547-How-do-I-migrate-an-existing-repository-to-Nexus-
4.旧库迁移(其他仓库到 Nexus)
官网有详细的描述:http://www.sonatype.com/books/nexus-book/reference/migrating.html