问题
需要在EC2机器上面安装私有maven库。
步骤
更新OS
bash
sudo yum update -y
JDK11
bash
# 安装JDK11
sudo yum install java-11-amazon-corretto
# 查询jdk11位置
sudo alternatives --config java
内容如下:
bash
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/java-17-amazon-corretto.aarch64/bin/java
2 /usr/lib/jvm/java-11-amazon-corretto.aarch64/bin/java
Enter to keep the current selection[+], or type selection number:
nexus安装包
bash
cd /opt
# 下载
sudo wget https://download.sonatype.com/nexus/3/nexus-3.67.0-03-java11-unix.tar.gz
# 解压
sudo tar -xvf nexus-3.67.0-03-java11-unix.tar.gz
这里解压出来是在两个文件夹,如下:
bash
drwxr-xr-x. 10 root root 181 Apr 8 11:10 nexus-3.67.0-03
-rw-r--r--. 1 root root 228889361 Apr 2 06:18 nexus-3.67.0-03-java11-unix.tar.gz
drwxr-xr-x. 3 root root 20 Apr 8 11:10 sonatype-work
添加nexus用户和用户组
bash
sudo useradd --system --home /home/nexus --shell /sbin/nologin --comment "nexus user" --user-group nexus
配置目录权限
bash
sudo chown -R nexus:nexus /opt/nexus-3.67.0-03
sudo chown -R nexus:nexus /opt/sonatype-work
设置nexus运行用户
bash
sudo vim /opt/nexus-3.67.0-03/bin/nexus.rc
设置如下内容:
bash
run_as_user="nexus"
配置JDK11
bash
sudo vim /opt/nexus-3.67.0-03/bin/nexus
添加如下内容:
bash
INSTALL4J_JAVA_HOME_OVERRIDE=/usr/lib/jvm/java-11-amazon-corretto.aarch64
SysV设置
bash
sudo vim /etc/systemd/system/nexus.service
内容如下:
bash
[Unit]
Description=nexus service
After=network.target
[Service]
Type=forking
LimitNPROC=65536
LimitNOFILE=65536
ExecStart=/opt/nexus-3.67.0-03/bin/nexus start
ExecStop=/opt/nexus-3.67.0-03/bin/nexus stop
User=nexus
Group=nexus
Restart=on-abort
[Install]
WantedBy=multi-user.target
启动nexus
bash
sudo systemctl daemon-reload
sudo systemctl start nexus.service
sudo systemctl status nexus.service
sudo systemctl enable nexus.service
后面放开8081端口,访问web页面即可,效果如下:
第一次登录
这里获取admin密码:
bash
cat /opt/sonatype-work/nexus3/admin.password
修改完密码后,重启nexus,如下:
bash
sudo systemctl restart nexus
总结
到此为止就nexus maven私库的手动sysv方式安装。