Nexus3 使用root报“WARNING: Detected execution as “root“ user. This is NOT recommended!” 以及 启动命令

网上找了很多资料,给出的解决方法大部分都是:
要么是在bin目录下的nexus.rc文件添加:
vim nexus.rc 加入run_as_user=root
要么就是加入系统变量
vim /etc/profile 加入export RUN_AS_USER=root
然而啥用都没有,启动还是一样的报这个提示。后面查看了一下启动脚本,即vim nexus,里面有一句:run_as_root=true ,原来是此处直接给拦死了,故只要改成run_as_root=false 就可以。
其实还有一种方法,就是添加nexus用户,即:
useradd nexus
chown -R nexus:nexus /opt/nexus
然后su nexus 执行:./nexus start 就成功了。

可能大部分人都是使用./nexus start吧,但这种是后台启动,看不到实时日志;用./nexus run 是实时启动可以看到日志,但是此启动方式不能退出回命令模式。 ./nexus status #查看启动状态, ./nexus stop #停止

前台启动:
  cd /opt/nexus3/nexus-3.13.0-01
  ./bin/nexus console

以后台进程启动:
  ./bin/nexus start
  
 查看输出的日志:
  tail -f logs/wrapper.log

linux下解压使用 tar -zvxf nexus-3.20.1-01-unix.tar.gz 一般是没有什么问题的,用run启动时可能会看到有关memery的报错,这时可以考虑是机器运行内存不够,nexus中默认是2g
如果nexus启动正常,但访问可能无果,这时候可以查看一下防火墙是否关闭或者nexus对应端口是否开通,nexus默认端口是8081,关闭防火墙命令:systemctl stop firewalld 。

如果需要修改nexus的端口, 可在你安装nexus的文件目录下找到nexus.properties 进行修改,如 vim /opt/nexus3/nexus-3.13.0-01/etc/nexus-default.properties ,找到 application-port=8081进行修改即可。

开放防火墙端口
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

在 CentOS 或其他 Linux 系统上安装 Sonatype Nexus Repository Manager,配置完毕启动登录后,在 /support/status 状态页面的 File Descriptors 项目可能会显示 Recommended file descriptor limit is 65536 but count is 4096. 警告。

原因是 Nexus 3 将很有可能要消耗比 Linux 或 OSX 操作系统允许每个用户的默认文件句柄数(4096)更多的数量。

耗尽文件描述符可能是灾难性的,并且很可能导致数据丢失。确保在启动之前将运行 Nexus Repository Manager 的用户打开的文件描述符的数量限制永久增加到 65,536 个或更多。

解决方法
在多数 Linux 系统上,可以通过编辑 /etc/security/limits.conf 文件为特定用户设置持久限制。若要将 Nexus 用户的软限制和硬限制的最大打开文件数设置为 65536,请在 /etc/security/limits.conf 文件中添加以下行,其中 “nexus” 应该替换为用于运行 Nexus 的用户登录名(如 root):

nexus soft nofile 65536
nexus hard nofile 65536

root soft nofile 65536
root hard nofile 65536

  • soft nofile 65536
  • hard nofile 65536

然后重启系统。若扔热不好使,直接将/etc/systemd/system.conf 和 /etc/systemd/user.conf 中DefaultLimitNOFILE=65536修改,默认是注释的。

官方建议 服务器硬件配置:
CPU:≥4核
memory:≥4G (do not set max heap size larger than 4GB)
file descriptors:65536

有需要下载nexus最新版的,可移步到我另一文章下载:https://blog.csdn.net/u010741112/article/details/103886347

Nexus3 使用root报“WARNING: Detected execution as “root“ user. This is NOT recommended!” 以及 启动命令_第1张图片

你可能感兴趣的:(nexus,linux,vim,运维)