nexus "root" user. This is NOT recommended

来源:本站原创 IT必备工具 超过4,070 views围观 0条评论

[root@Hcc]# /opt/nexus/bin/nexus start
WARNING: ************************************************************
WARNING: Detected execution as "root" user.  This is NOT recommended!
WARNING: ************************************************************
Starting nexus
[root@Hcc]#
[root@Hcc]#
[root@Hcc]# /opt/nexus/bin/nexus status
WARNING: ************************************************************
WARNING: Detected execution as "root" user.  This is NOT recommended!
WARNING: ************************************************************
Error: Could not find or load main class com.install4j.runtime.launcher.UnixLauncher

 

Aug 07 10:29:03 ip-172-31-47-229.ap-northeast-1.compute.internal nexus[10018]: Error: Could not find or load main class com.install4j.runtime.launcher.UnixLauncher

解决

setp1:移动文件到正常位置
[root@ip-172-31-47-229 nexus]# find / -name *install4j*   ——–查找
/root/.install4j
/tmp/nexus-3.12.1-01/.install4j
/tmp/nexus-3.12.1-01/.install4j/user/install4j-common-1.1.1.jar
/tmp/nexus-3.12.1-01/.install4j/user/install4j-slf4j-1.1.1.jar
[root@ip-172-31-47-229 nexus]# cp /tmp/nexus-3.12.1-01/.install4j .
cp: omitting directory ‘/tmp/nexus-3.12.1-01/.install4j’
[root@ip-172-31-47-229 nexus]# cp -a /tmp/nexus-3.12.1-01/.install4j .   —–放到nexus目录

setp2:然后用run进行测试
[root@ip-172-31-47-229 nexus]# /opt/nexus/bin/nexus run
Last login: Tue Aug  7 11:33:53 UTC 2018 on pts/1
OpenJDK 64-Bit Server VM warning: Cannot open file ../sonatype-work/nexus3/log/jvm.log due to Permission denied–无权限

Warning:  Cannot open log file: ../sonatype-work/nexus3/log/jvm.log
Warning:  Forcing option -XX:LogFile=/tmp/jvm.log
Unable to update instance pid: Unable to create directory /opt/sonatype-work/nexus3/instances
/opt/sonatype-work/nexus3/log/karaf.log (Permission denied)
Unable to update instance pid: Unable to create directory /opt/sonatype-work/nexus3/instances
[root@ip-172-31-47-229 nexus]# id nexus
id: nexus: no such user
[root@ip-172-31-47-229 nexus]# ll ../sonatype-work/nexus3/log/jvm.log
-rw-r–r–. 1 root root 3833 Aug  7 10:49 ../sonatype-work/nexus3/log/jvm.log
[root@ip-172-31-47-229 nexus]#

setp3:修改用户
vim ./bin/nexus.rc
run_as_user="ec2-user"
vim nexus
run_as_user="ec2-user"

setp4:修改权限为ec2-user
chown ec2-user:ec2-user -R nexus
cd /opt/
chown ec2-user:ec2-user -R *

setp5:继续测试
/opt/nexus/bin/nexus run 

测试正常
[root@aws_jenkins001 ~]# !net
netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
tcp        0      0 127.0.0.1:41025         0.0.0.0:*               LISTEN      18390/java         
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN      18390/java

setp6:使用命令起动服务
systemctl status nexus

[root@ip-172-31-47-229 ~]# systemctl status nexus
● nexus.service – nexus service
   Loaded: loaded (/usr/lib/systemd/system/nexus.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2018-08-07 11:46:32 UTC; 16s ago
  Process: 16737 ExecStop=/opt/nexus/bin/nexus stop (code=exited, status=0/SUCCESS)
  Process: 18959 ExecStart=/opt/nexus/bin/nexus start (code=exited, status=0/SUCCESS)
Main PID: 19094 (java)
   CGroup: /system.slice/nexus.service
           └─19094 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/bin/java -se…

Aug 07 11:46:32 aws_jenkins001 systemd[1]: Starting nexus service…
Aug 07 11:46:32 aws_jenkins001 nexus[18959]: Starting nexus
Aug 07 11:46:32 aws_jenkins001 systemd[1]: Started nexus service.
[root@ip-172-31-47-229 ~]#

文章出自:CCIE那点事 http://www.jdccie.com/ 版权所有。本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源。 禁止全文转载。
本文链接:http://www.jdccie.com/?p=3909转载请注明转自CCIE那点事
如果喜欢:点此订阅本站