CentOS 7 安装nexus
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
1、下載nexus ,使用版本nexus-3.13.0-01-unix.tar.gz,下載地址
https://sonatype-download.global.ssl.fastly.net/repository/repositoryManager/3/nexus-3.13.0-01-unix.tar.gz2、解壓后移動(dòng)到安裝目錄(/opt/nexus)
創(chuàng)建安裝目錄
[root@ou Downloads]# mkdir /opt/nexus/解壓安裝包到安裝目錄:
[root@ou Downloads]# tar -zxvf nexus-3.13.0-01-unix.tar.gz -C /opt/nexus/切換到安裝目錄:
[root@ou Downloads]# cd /opt/nexus查看目錄詳情:
[root@ou nexus]# ls nexus-3.13.0-01 sonatype-work解壓縮后可以看到有兩個(gè)文件夾,第一個(gè)是nexus服務(wù),第二個(gè)是它的私有倉(cāng)庫(kù)目錄。 這時(shí)已經(jīng)可以啟動(dòng) nexus
進(jìn)入位置:NEXUS_HOME/bin本示例位置:
/opt/nexus/nexus-3.13.0-01/bin進(jìn)入bin目錄:
[root@ou nexus]# cd nexus-3.13.0-01/bin [root@ou bin]# ./nexus start **************************************** WARNING - NOT RECOMMENDED TO RUN AS ROOT **************************************** If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.當(dāng)用root權(quán)限運(yùn)行時(shí)會(huì)彈出提示,解決方式是
[root@ou bin]# vim nexus 在配置文件上部找到 #RUN_AS_USER= 在下一行添加 RUN_AS_USER=root 具體示例: # 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= RUN_AS_USER=root3、設(shè)置系統(tǒng)服務(wù)
3.1、添加 NEXUS_HOME 環(huán)境變量
vim /etc/profile在后面添加
export NEXUS_HOME=/opt/nexus/nexus-3.13.0-01使新加入的內(nèi)容生效
source /etc/profile3.2、添加本地jdk
vim /opt/nexus/nexus-3.13.0-01/bin/nexus在文件中找到 INSTALL4J_JAVA_HOME_OVERRIDE 這一行(這一行默認(rèn)被注釋),添加上自己的JDK路徑
INSTALL4J_JAVA_HOME_OVERRIDE=/usr/java/jdk1.8.0_181-amd643.3、配置以 nexus 用戶啟動(dòng)應(yīng)用
nexus 官網(wǎng)建議不要使用 root 帳戶啟動(dòng)應(yīng)用,所以創(chuàng)建一個(gè) nexus 用戶
useradd nexus修改 nexus 配置,使用 nexus 作為應(yīng)用啟動(dòng)的帳戶
gedit /opt/nexus/nexus-3.13.0-01/bin/nexus.rc將內(nèi)容修改為
run_as_user=”nexus”修改 nexus 的目錄權(quán)限
chown nexus nexus3.4、設(shè)置系統(tǒng)服務(wù)(systemd)
vi /usr/lib/systemd/system/nexus.service [Unit] Description=nexus After=network.target[Service] Type=forking ExecStart=/opt/nexus/nexus-3.13.0-01/bin/nexus start ExecReload=/opt/nexus/nexus-3.13.0-01/bin/nexus stop ExecStop=/opt/nexus/nexus-3.13.0-01/bin/nexus stop PrivateTmp=true[Install] WantedBy=multi-user.target 然后執(zhí)行 systemctl daemon-reload,重新加載服務(wù) 再執(zhí)行 systemctl enable nexus,使該服務(wù)可以開(kāi)機(jī)自啟。 啟動(dòng)服務(wù) systemctl start nexus4、登陸管理界面
默認(rèn)管理地址為:http://localhost:8081/nexus/ 使用界面右上角log in進(jìn)行默認(rèn)用戶的登陸, 默認(rèn)用戶為:admin,密碼為:admin123。5、點(diǎn)擊左側(cè)的users查看當(dāng)前系統(tǒng)的用戶。
可以看到一共三個(gè)用戶,admin,deployment和anonymous。 admin:該用戶擁有Nexus的全部權(quán)限,默認(rèn)密碼為admin123。 deployment:該用戶能夠訪問(wèn)Nexus,瀏覽倉(cāng)庫(kù)內(nèi)容、搜索、上傳部署構(gòu)件,但是不能對(duì)Nexus進(jìn)行任何配置,默認(rèn)密碼為deployment123。 anonymous:該用戶對(duì)應(yīng)了所有未登錄的匿名用戶,它們可以瀏覽倉(cāng)庫(kù)并進(jìn)行搜索6、集成Maven 打開(kāi)本地 %M2_HOME%\conf\settings.xml 文件 6.1、設(shè)置本地倉(cāng)庫(kù)位置
<localRepository>/opt/apache-maven-3.5.4/repository</localRepository>6.2、設(shè)置 Server
<server><id>nexus-releases</id><username>admin</username><password>admin123</password> </server> <server><id>nexus-snapshots</id><username>admin</username><password>admin123</password> </server>6.3、設(shè)置 Nexus 鏡像(localhost 修改為安裝 Nexus 的服務(wù)器地址)
<mirror><id>nexus</id><mirrorOf>*</mirrorOf><url>http://localhost:8081/repository/maven-public/</url> </mirror>6.4、設(shè)置 Profile(localhost 修改為安裝 Nexus 的服務(wù)器地址)
<profile><id>nexus-resp</id><repositories><repository><id>nexus-releases</id><url>http://localhost:8081/repository/maven-releases/</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></repository><repository><id>nexus-snapshots</id><url>http://localhost:8081/repository/maven-snapshots/</url><releases><enabled>false</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>nexus-plugin</id><url>http://localhost:8081/repository/maven-public/</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></pluginRepository></pluginRepositories> </profile>6.5、設(shè)置默認(rèn)激活的 profile
<activeProfiles><activeProfile>nexus-resp</activeProfile> </activeProfiles>6.6、修改工程pom文件
<distributionManagement><repository><id>nexus-releases</id><name>Team Nexus Release Repository</name><url>http://localhost:8081/repository/maven-releases/</url></repository><snapshotRepository><id>nexus-snapshots</id><name>Team Nexus Snapshot Repository</name><url>http://localhost:8081/repository/maven-snapshots/</url></snapshotRepository> </distributionManagement><repositories><repository><id>nexus-public</id><name>Nexus public Repository</name><url>http://localhost:8081/repository/maven-public</url></repository> </repositories>操作完成,執(zhí)行 mvn deploy,應(yīng)該就可以 Nexus 上查找到你當(dāng)前項(xiàng)目了。
轉(zhuǎn)載于:https://my.oschina.net/ouyushan/blog/1935515
總結(jié)
以上是生活随笔為你收集整理的CentOS 7 安装nexus的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: MySQL高可用的几种方案
- 下一篇: 饿了么超级会员数量暴增,外卖市场“去泡沫