CentOS 安裝 SonaType Nexus Maven Repository以及舊庫遷移

轉載:http://www.cnblogs.com/zhangqingsh/archive/2013/03/14/2959301.html


1. CentOS下安裝SonaType Nexus:

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 創建nexus用戶/用戶組:

1.3.1 創建用戶組:groupadd -g 104 nexus

1.3.2 創建用戶:useradd -u 103 -g 104 -c "Neuxs Maven Repository"  nexus

1.4 配置屬性文件/權限:

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=${bundleBasedir}/sonatype-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF

複製代碼

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

 

2. 配置Nginx:

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;
        }
    }
複製代碼

service nginx restart

3. 登錄 Sonatype Nexus

http://192.168.XXX.XXX

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

發佈了22 篇原創文章 · 獲贊 2 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章