目录
1. 新建nexus启动脚本
进入/etc/init.d
目录,新建脚本文件nexus
# 进入/etc/init.d
cd /etc/init.d/
# 新建脚本文件nexus
vim nexus
脚本内容
#!/bin/bash
#chkconfig:2345 20 90
#description:nexus
#processname:nexus
export JAVA_HOME=/usr/local/soft/java/jdk1.8.0_251
case $1 in
start) su root /usr/local/soft/nexus/nexus-3.9.0-01/bin/nexus start;;
stop) su root /usr/local/soft/nexus/nexus-3.9.0-01/bin/nexus stop;;
status) su root /usr/local/soft/nexus/nexus-3.9.0-01/bin/nexus status;;
restart) su root /usr/local/soft/nexus/nexus-3.9.0-01/bin/nexus restart;;
dump) su root /usr/local/soft/nexus/nexus-3.9.0-01/bin/nexus dump;;
console) su root /usr/local/soft/nexus/nexus-3.9.0-01/bin/nexus console;;
*) echo "Usage: nexus {start|stop|run|run-redirect|status|restart|force-reload}"
esac
2. 设置脚本权限
chmod +x /etc/init.d/nexus
3. 使用service命令使用nexus
service nexus status
4. 添加到开机启动
chkconfig nexus on
5. 查看nexus开机启动
chkconfig --list nexus
6. 设置防火墙
# 进入防火墙设置文件目录
cd /etc/firewalld/zones/
# 使用vim, 修改防火墙配置文件
vim public.xml
添加以下放开端口内容, 其它不变
<rule family="ipv4">
<!-- 开放8084端口给任意ip -->
<port protocol="tcp" port="8084"/>
<accept/>
</rule>