linux nexus3服務端配置
- 使用阿裡雲配置nexus3
-
- nexus2配置
- nexus3配置
- npm釋出
- maven釋出
使用阿裡雲配置nexus3
最近想玩一下如何搭建上傳私服等,是以就去阿裡雲買了最便宜的伺服器1核2G,然後就把自己給坑了;
記錄一些linux操作指令:
解壓壓縮包:tar -zxvf nexus-3.33.0-01-unix.tar.gz
網絡下載下傳:wget https://download.sonatype.com/nexus/3/nexus-3.33.0-01-unix.tar.gz
移動檔案: mv xx/xxx/目前檔案夾 yyy/yyy/目标檔案夾
遞歸删除:rm -rf xxx/xxx
建立檔案夾:mkdir xxx
打開檔案編輯:vim xxx
執行修改檔案指令:i
退出目前vim操作:esc
退出編輯: :quit
退出并儲存: :wq
nexus2配置
首先我嘗試使用nexus2進行配置,遇到一些問題:
1、需要在阿裡雲伺服器配置安全組,不然雖然啟動成功,但是無法通路:
2、但是在打包上傳的時候發現無法本地登陸,度娘提示需要配置realms,可是我用的nexus2的版本在security目錄下根本沒有realms,一直找不到解決辦法,沒辦法就重新下載下傳了nexus3來玩;
nexus3配置
首先在官網下載下傳nexus3包,我是用梯子在電腦上下載下傳好,然後上傳伺服器,上傳伺服器工具用的FinalShell 非常好用;
過程簡單粗暴,下載下傳好解壓兩個檔案夾:
在nexus-3.33.0-01/bin下面執行:
nexus start
顯示
表明啟動成功,但是無法通路,檢視端口,也沒有8081端口
檢視端口指令: netstat -tunlp
端口啟動成功的樣子:
檢視度娘發現,這個是僞啟動成功,專門欺騙像我們這樣的純情大齡青年;
應該用另一個啟動指令,可以檢視什麼錯誤原因:
nexus run
度娘—>傳送門
Native memory allocation (mmap) failed to map 1890254848 bytes for committing
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x000000074f550000, 1890254848, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 1890254848 bytes for committing reserved memory.
# An error report file with more information is saved as:
原來是因為我申請的伺服器太小2g,但是這個服務啟動就要1.7G,玩不起啊!需要手動修改nexus3服務所用記憶體(隻是學習,不考慮那麼多了),
修改bin目錄下的nexus.vmoptions 檔案
vim nexus.vmoptions
修改下面的值,我試了幾下,太高,造成上面說的硬體記憶體不足,太低,運作記憶體不足,我取了個相對比較低的512;
-Xms512m
-Xmx512m
-XX:MaxDirectMemorySize=512m
然後啟動nexus run 成功運作(啟動要一段時間的);
還好終于啟動成功了,後面在玩玩上傳私服,希望問題少一點😂
npm釋出
先簡單寫一下npm釋出流程,後面通過具體工程實際應用:
1、Nexus設定realms
2、登陸npm
npm login --registry=http://your.ip:8081/repositorywwl-component/
登陸成功顯示:
Logged in as admin on http://your.ip:8081/repository/wwl-component/
3、釋出
package包配置:
"publishConfig": {
"registry": "http://your.ip:8081/repository/wwl-component/"
},
npm publish wwl-ui-vue --registry=http://your.ip:8081/repository/wwl-component/
釋出成功!!! 後面找時間寫webpack工程配置,vue搭建,順便學習一下vue3
maven釋出
1、首先建立maven倉庫:
http://yourIp:8081/repository/xui/
2、Android Studio建立Library用于生成aar:
apply plugin: ‘com.android.library’
3、建立gradle上傳檔案:
先在build.gradle中添加
apply from: ‘upload.gradle’ 建立upload.gradle檔案:
apply plugin: 'maven'
def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}
def getRepositoryUrl() {
return isReleaseBuild() ? RELEASE_REPOSITORY_URL : SNAPSHOT_REPOSITORY_URL
}
def getRepositoryUsername() {
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "admin"
}
def getRepositoryPassword() {
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "admin123"
}
afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
pom.packaging = 'aar'
pom.name = 'helloworld'
repository(url: getRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
}
}
}
}
4、添加gradle.properties檔案
這個檔案裡面的變量是剛才upload.gradle檔案中用到的;
# implementation 'com.wwl:xui:1.0.0'
#aar包的groupId
GROUP=com.wwl
#aar包的版本号
VERSION_NAME=1.0.0
#aar包的artifactId
POM_ARTIFACT_ID=xui
#snapshot(dev環境)的倉庫位址
SNAPSHOT_REPOSITORY_URL=http://yourip:8081/repository/xuidev/
#Release環境aar包打包位址
RELEASE_REPOSITORY_URL=http://yourip:8081/repository/xui/
#打包機name
NEXUS_USERNAME=admin
#打包機密碼
NEXUS_PASSWORD=admin123
5、打包上傳:很簡單,輕按兩下右邊的
6、使用aar
工程根目錄build.gradle配置
maven { url ‘http://yourip:8081/repository/xui/’ }
module build.gradle配置依賴:
implementation ‘com.wwl:xui:1.0.0’
先這樣吧,電腦沒電了,後面再寫 多工程,多倉庫的開發模式