溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Nexus安裝配置全過程

發(fā)布時(shí)間:2020-06-09 10:13:12 來源:網(wǎng)絡(luò) 閱讀:5478 作者:lzlutao 欄目:編程語言

一、準(zhǔn)備一臺(tái)Linux主機(jī)

IP:192.168.1.165

1、開SSH

systemctl enable sshd

2、關(guān)閉SELINUX

vi /etc/sysconfig/selinux

修改下邊紅字部分

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing - SELinux security policy is enforced.

# permissive - SELinux prints warnings instead of enforcing.

# disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of three two values:

# targeted - Targeted processes are protected,

# minimum - Modification of targeted policy. Only selected processes are protected.

# mls - Multi Level Security protection.

SELINUXTYPE=targeted

3、安裝rz

yum -y install lrzsz

之后上傳文件一定要用-be參數(shù)(其中-b是--binary用二進(jìn)制的方式上傳,-e是--escape強(qiáng)制escape所有控制字符),否則上傳的文件不完整

rz –be

4、安裝wget

yum -y install wget

5、更換yum源,用于提速yum

(1)備份yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

(2)下載新的CentOS-Base.repo 到/etc/yum.repos.d/

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

清理緩存

yum clean all

重新生成緩存

yum makecache

6、用firewalld開80端口

firewall-cmd --permanent --add-service=http

systemctl reload firewalld

?

二、安裝Nexus

1、安裝JDK1.8

https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Nexus安裝配置全過程

下載rpm包傳到服務(wù)器上,用rpm命令安裝

rpm -ivh jdk-8u191-linux-x64.rpm

Nexus安裝配置全過程

增加Java環(huán)境變量

vi /etc/profile

export JAVA_HOME=/usr/java/jdk1.8.0_191-amd64

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$PATH:$JAVA_HOME/bin

export RUN_AS_USER=root

使環(huán)境變量生效

source /etc/profile

查看java版本

java -version

Nexus安裝配置全過程

2、下載并安裝Nexus

官網(wǎng)下載地址:https://www.sonatype.com/download-oss-sonatype

Nexus安裝配置全過程

解壓nexus-3.14.0-04-unix.tar.gz

tar -zxvf nexus-3.14.0-04-unix.tar.gz

Nexus安裝配置全過程

將nexus-3.14.0-04改名nexus,且將nexus和sonatype-work目錄移動(dòng)到/usr/local/目錄下

mv nexus-3.14.0-04 nexus

mv nexus /usr/local/

mv sonatype-work /usr/local/

編輯nexus.rc,修改運(yùn)行nexus3所使用的用戶

cd /usr/local/nexus/bin

vi nexus.rc

修改為

run_as_user="root"

編輯nexus,修改nexus3啟動(dòng)時(shí)要使用的jdk版本

vi nexus

修改為

INSTALL4J_JAVA_HOME_OVERRIDE=/usr/java/jdk1.8.0_191-amd64

Nexus安裝配置全過程

修改nexus-default.properties

cd /usr/local/nexus/etc

vi nexus-default.properties

修改nexus3默認(rèn)端口

application-port=80

Nexus安裝配置全過程

關(guān)閉占用80端口的httpd服務(wù)

systemctl stop httpd

systemctl disable httpd

nexus3數(shù)據(jù)以及相關(guān)日志的存儲(chǔ)位置可以修改bin目錄下的nexus.vmoptions

把nexus3加入到系統(tǒng)服務(wù),使之能夠開機(jī)自啟動(dòng):

ln -s /usr/local/nexus/bin/nexus /etc/init.d/nexus

cd /etc/init.d

chkconfig --add nexus

chkconfig --levels 345 nexus on

systemctl start nexus

systemctl status nexus

Nexus安裝配置全過程

內(nèi)置啟動(dòng)和停止方法:

/usr/local/nexus/bin/nexus start

/usr/local/nexus/bin/nexus stop

三、配置Nexus

1、在瀏覽器輸入http://192.168.1.165

PS:nexus服務(wù)啟動(dòng)成功后,需要稍等一段時(shí)間,端口才起來

Nexus安裝配置全過程

默認(rèn)賬號(hào)和密碼:admin admin123

Nexus安裝配置全過程

可以在右上角查看賬戶登錄狀態(tài)

Nexus安裝配置全過程

2、配置LDAP(略)

3、新建普通用戶規(guī)則

點(diǎn)擊左側(cè)Security-Roles按鈕

點(diǎn)擊"Create role-Nexus role"按鈕

Nexus安裝配置全過程

Role ID:nx-user

Role name:nx-user

Rrivlieges:nx-repository-view-*-*-*、nx-search-read #允許私服倉庫任何操作

Nexus安裝配置全過程

創(chuàng)建成功

Nexus安裝配置全過程

之后可以在Users中為L(zhǎng)DAP賬號(hào)賦予對(duì)應(yīng)的權(quán)限

Nexus安裝配置全過程

4、添加公司內(nèi)部倉庫

點(diǎn)擊左側(cè)Repositories按鈕

Nexus安裝配置全過程

說明:

(1)name列

maven-central:maven中央庫,默認(rèn)從https://repo1.maven.org/maven2/拉取jar

maven-releases:私庫發(fā)行版jar

maven-snapshots:私庫快照(調(diào)試版本)jar

maven-public:倉庫分組,把上面三個(gè)倉庫組合在一起對(duì)外提供服務(wù),在本地maven基礎(chǔ)配置settings.xml中使用。

(2)type列(Nexus默認(rèn)的倉庫類型有以下四種):

group(倉庫組類型):又叫組倉庫,用于方便開發(fā)人員自己設(shè)定的倉庫;

hosted(宿主類型):內(nèi)部項(xiàng)目的發(fā)布倉庫(內(nèi)部開發(fā)人員,發(fā)布上去存放的倉庫);

proxy(代理類型):從遠(yuǎn)程中央倉庫中尋找數(shù)據(jù)的倉庫(可以點(diǎn)擊對(duì)應(yīng)的倉庫的Configuration頁簽下Remote Storage Location屬性的值即被代理的遠(yuǎn)程倉庫的路徑);

virtual(虛擬類型):虛擬倉庫(這個(gè)基本用不到,重點(diǎn)關(guān)注上面三個(gè)倉庫的使用);

點(diǎn)擊"Create Repositories"按鈕,再選擇maven2(hosted)

Nexus安裝配置全過程

Name:xxxx-releases #自定義

Version policy:Release # Releases: 一般是已經(jīng)發(fā)布的Jar包,Snapshot: 未發(fā)布的版本,Mixed:混合的

Deployment Pollcy:Allow redeploy

其他默認(rèn)

Nexus安裝配置全過程

xxxx-snapshots創(chuàng)建方法一樣

Nexus安裝配置全過程

Nexus安裝配置全過程

最后記得取消Anonymous里邊Allow anonymous users to access the server的勾,這樣不登錄看不到任何庫文件

Nexus安裝配置全過程

問題1:

web頁面最上邊提示:System Requirement: max file descriptors [4096] likely too low, Increase to at least [65536]

Nexus安裝配置全過程

操作系統(tǒng)文件描述符太低,建議改成65536

vi /etc/security/limits.conf

添加

* soft nofile 65536

* hard nofile 65536

Nexus安裝配置全過程

注意value不能查過/proc/ysy/fs/nr_open的值,否則不能登錄操作系統(tǒng)

Nexus安裝配置全過程

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI