maven私服部署-nexus

1.官网下载最新版本

nexus官网地址https://www.sonatype.com/

打开官网,拉到最下面

点击 Nexus Repository OSS

选择对应的系统版本下载

2.安装

将安装包解压到/usr/local/nexus目录下

cd /usr/local

mkdir nexus

tar -zxvf nexus-3.73.0-12-unix.tar.gz -C /usr/local/nexus

nexus-3.73.0-12 nexus服务

sonatype-work 私有库目录

注意:nexus-3.73.0-12这个版本的jdk,需要17

3.给nexus创建一个用户

useradd nexus #创建用户,不用给这个用户设置密码

4.给与nexus用户对应的文件夹权限

chown -R nexus:nexus /usr/local/nexus

5.配置

/usr/local/nexus/nexus-3.73.0-12/etc/nexus-default.properties

可以修改启动端口

6.启动

su nexus #切换用户

cd /usr/local/nexus/nexus-3.73.0-12/bin

./nexus start

7.https访问私服

7.1 生成自签名证书和私钥

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes

openssl req:使用OpenSSL的req命令来生成证书请求或自签名证书。
-x509:生成自签名证书而不是证书请求。
-newkey rsa:2048:生成一个新的2048位RSA密钥对。
-keyout key.pem:将生成的私钥保存到文件key.pem中。
-out cert.pem:将生成的自签名证书保存到文件cert.pem中。
-days 365:设置证书的有效期为365天。
-nodes:不加密私钥文件,即私钥文件不会被密码保护。

7.2 将证书和私钥转换为PKCS12格式

openssl pkcs12 -export -in cert.pem -inkey key.pem -out keystore.p12 -name nexus -CAfile cert.pem -caname root

openssl pkcs12:使用OpenSSL的pkcs12命令来处理PKCS12格式的文件。
-export:导出证书和私钥到PKCS12文件。
-in cert.pem:指定输入的证书文件。
-inkey key.pem:指定输入的私钥文件。
-out keystore.p12:将输出的PKCS12文件保存到keystore.p12中。
-name nexus:为证书指定一个别名,这里使用nexus。
-CAfile cert.pem:指定CA证书文件,这里使用自签名证书文件cert.pem。
-caname root:为CA证书指定一个名称,这里使用root。

7.3 将PKCS12文件转换为JKS格式

keytool -importkeystore -srckeystore keystore.p12 -destkeystore keystore.jks -deststoretype pkcs12

keytool:Java的密钥和证书管理工具。
-importkeystore:从一个现有的密钥库导入条目到另一个密钥库。
-srckeystore keystore.p12:指定源密钥库文件,这里是keystore.p12。
-destkeystore keystore.jks:指定目标密钥库文件,这里是keystore.jks。

-deststoretypePKCS12:指定目标密钥库的类型为PKCS12。

7.4 配置Nexus支持HTTPS

编辑Nexus的配置文件 /usr/local/nexus/nexus-3.73.0-12/etc/nexus-default.properties,修改以下内容:

application-port-ssl=80

nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-https.xml,${jetty.etc}/jetty-requestlog.xml

ssl证书需要放到如下目录中:/usr/local/nexus/nexus-3.73.0-12/etc/ssl

去bin目录下启动 ./nexus start

停止 ./nexus stop

注意:使用nexus用户启动时尽量端口大于1024

监听小于1024的端口通常需要root权限。如果你不是以root用户身份运行服务,可能会因为权限不足而导致无法绑定到端口

8 登录引导

点击右上角登录,会提示有用户名和密码的位置,使用登录,

下一步勾选disable,拉取依赖时需要认证

仓库代理设置为国内

9 其他问题

Nexus was not configured with an encryption key and is using the Default key

官方文档

Re-encryption in Nexus Repository

$data-dir/sonatype-work/nexus3/etc/nexus-default.properties

增加一个配置

nexus.secrets.file=/full/path/to/your/secrets/content.json

content.json内容为:

{
  "active": "my-key",
  "keys": [
    {
      "id": "my-key",
      "key": "任意的字符串"
    }
  ]
}

admin com.sonatype.nexus.plugins.outreach.internal.outreach.SonatypeOutreach - Could not download page bundle
org.apache.http.conn.ConnectTimeoutException: Connect to sonatype-download.global.ssl.fastly.net:443 [sonatype-download.global.ssl.fastly.net/199.59.148.106] failed: Connect timed out

相关问题参考https://support.sonatype.com/hc/en-us/articles/213464978-How-to-avoid-Could-not-download-page-bundle-messages

禁用Nexus存储库3中的外联功能
要禁用Nexus Repository 3中的出站外展请求,请执行以下操作:

Sign in to your Nexus Repository instance as an Administrator.

Open Administration -> System -> Capabilities. Select the Outreach Management capability.

Click the Disable button. Your changes are immediately saved.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值