环境信息

操作系统

Nexus版本

端口

旧服务器

Centos7.7

V3.*

8081

新服务器

Centos7.9

V3.*

8081

Nexus主要由两部分文件组成,安装目录和数据目录,nexus迁移只需要将两个目录从旧服务器复制到新服务器即可。

迁移操作

1. 将旧环境文件复制到新环境对应目录下

旧环境目录

安装目录:/opt/nexus3/

数据目录:/opt/sonatype-work/nexus3/

新环境目录

安装目录:/opt/nexus3/

数据目录:/home/nexus-data/

修改<安装目录>/bin/nexus.vmoptions文件,自定义数据目录

-Dkaraf.data=/home/nexus-data
-XX:LogFile=/home/nexus-data/log/jvm.log
-Djava.io.tmpdir=/home/nexus-data/tmp

2. 创建nexus用户(密码nexus)

$ useradd nexus

$ passwd nexus  

$ su - nexus 

3. 启动nexus应用

$ /opt/nexus3/bin/nexus start

若实时查看日志可以使用 run启动

$ /opt/nexus3/bin/nexus run

4. 防火墙设置(二选一)

1) 若关闭防火墙:

$ systemctl stop firewalld

2) 若开放防火墙

$ systemctl status firewalld #查看防火墙状态

$ firewall-cmd --zone=public --list-ports #查看端口开放情况

$ firewall-cmd --zone=public --add-port=8081/tcp --permanent

$ firewall-cmd --reload #刷新防火墙设置

$ firewall-cmd --zone=public --list-ports

 在浏览器验证服务是否启动成功http://<ip>:8081

5. 配置nexus服务,并设置开机自启动

$ vi /usr/lib/systemd/system

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

[Unit]Description=nexus

After=network.target

  

[Service]

Type=forking

ExecStart=/opt/nexus3/bin/nexus start

ExecStop=/opt/nexus3/bin/nexus stop

User=nexus #启动nexus进程的用户,需要确认目录是否有访问权限

  

[Install]

WantedBy=multi-user.target #命令行模式

$ systemctl daemon-reload #重新加载服务配置文件

$ systemctl enable nexus #设置开机自启动

$ systemctl start nexus 

$ systemctl status nexus 

补充:

  • 如何查找nexus的两个文件目录

1) 安装目录

# whereis nexus

nexus:/opt/nexus3/bin/nexus /opt/nexus3/bin/nexus.rc /opt/nexus3/bin/nexus.vmoptions

/opt/nexus3/bin/nexus为nexus的可执行文件,判断nexus安装在/opt/nexus3目录下

2) 数据目录

# whereis nexus

nexus:/opt/nexus3/bin/nexus /opt/nexus3/bin/nexus.rc /opt/nexus3/bin/nexus.vmoptions

# cat /opt/nexus3/bin/nexus.vmoptions

.......

-Dkaraf.data=../sonatype-work/nexus3

.......

# cd /opt/nexus3/bin/nexus.vmoptions/sonatype-work/nexus3 

nexus3修改端口

 

 

 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐