提问者:小点点

Puppetserver服务启动失败


我有一个流浪者CentOSVM运行ps.内存=2048RAM分配。

当我尝试启动木偶服务器服务时:

$ puppet --version
4.4.0
$ sudo puppet resource service puppetserver ensure=running
Error: Could not start Service[puppetserver]: Execution of '/bin/systemctl start puppetserver' returned 1: Job for puppetserver.service failed. See 'systemctl status puppetserver.service' and 'journalctl -xn' for details.
Error: /Service[puppetserver]/ensure: change from stopped to running failed: Could not start Service[puppetserver]: Execution of '/bin/systemctl start puppetserver' returned 1: Job for puppetserver.service failed. See 'systemctl status puppetserver.service' and 'journalctl -xn' for details.
service { 'puppetserver':
  ensure => 'stopped',
}
$ journalctl -xn
No journal files were found.
$ systemctl status puppetserver.service
puppetserver.service - puppetserver Service
   Loaded: loaded (/usr/lib/systemd/system/puppetserver.service; disabled)
  Process: 4708 ExecStartPre=/usr/bin/install --directory --owner=puppet --group=puppet --mode=775 /var/run/puppetlabs/puppetserver (code=exited, status=0/SUCCESS)
 Main PID: 4709 (java);         : 4710 (bash)
   CGroup: /system.slice/puppetserver.service
           ├─4709 /usr/bin/java -Xms1g -Xmx1g -XX:MaxPermSize=1g -XX:OnOutOfMemoryError=kill -9 %p -Djava.security.egd=/...
           └─control
             ├─4710 /bin/bash /opt/puppetlabs/server/apps/puppetserver/ezbake-functions.sh wait_for_app
             └─4755 sleep 1

我的JAVA_ARGS/etc/sysconfig/木偶服务器

JAVA_ARGS="-Xms1g -Xmx1g -XX:MaxPermSize=1g"

根据要求,木偶服务器. service文件:

$ cat /usr/lib/systemd/system/puppetserver.service
[Unit]
Description=puppetserver Service
After=syslog.target network.target

[Service]
Type=simple
EnvironmentFile=/etc/sysconfig/puppetserver
User=puppet
TimeoutStartSec=120
TimeoutStopSec=60
Restart=on-failure
StartLimitBurst=5

PermissionsStartOnly=true
ExecStartPre=/usr/bin/install --directory --owner=puppet --group=puppet --mode=775 /var/run/puppetlabs/puppetserver

ExecStart=/usr/bin/java $JAVA_ARGS \
          '-XX:OnOutOfMemoryError=kill -9 %%p' \
          -Djava.security.egd=/dev/urandom \
          -cp "${INSTALL_DIR}/puppet-server-release.jar" clojure.main \
          -m puppetlabs.trapperkeeper.main \
          --config "${CONFIG}" \
          -b "${BOOTSTRAP_CONFIG}" $@

KillMode=process

ExecStartPost=/bin/bash "${INSTALL_DIR}/ezbake-functions.sh" wait_for_app

SuccessExitStatus=143

StandardOutput=syslog

[Install]
WantedBy=multi-user.target

尝试手动运行ExecStartPost命令:

$ /usr/bin/java -Xms1g -Xmx1g -XX:MaxPermSize=1g -XX:OnOutOfMemoryError='kill -9 %%p' -Djava.security.egd=/dev/urandom -cp /opt/puppetlabs/server/apps/puppetserver/puppet-server-release.jar clojure.main -m puppetlabs.trapperkeeper.main --config /etc/puppetlabs/puppetserver/conf.d -b /etc/puppetlabs/puppetserver/bootstrap.cfg

RuntimeError: Got 2 failure(s) while initializing: File[/var/log/puppetlabs/puppetserver]: change from 0700 to 0750 failed: failed to set mode 0700 on /var/log/puppetlabs/puppetserver: Operation not permitted - No message available; File[/var/run/puppetlabs/puppetserver]: change from 0775 to 0755 failed: failed to set mode 0775 on /var/run/puppetlabs/puppetserver: Operation not permitted - No message available

所以我又试了一次,但这次我更改了一些目录权限,但仍然出现类似的错误(鉴于我刚刚更改了模式,这没有意义?):

$ sudo chown -R vagrant:vagrant /var/run/puppetlabs/
$ sudo chown -R vagrant:vagrant /var/log/puppetlabs/
$ sudo chmod -R 0755 /var/run/puppetlabs/

$ /usr/bin/java -Xms1g -Xmx1g -XX:MaxPermSize=1g -XX:OnOutOfMemoryError='kill -9 %%p' -Djava.security.egd=/dev/urandom -cp /opt/puppetlabs/server/apps/puppetserver/puppet-server-release.jar clojure.main -m puppetlabs.trapperkeeper.main --config /etc/puppetlabs/puppetserver/conf.d -b /etc/puppetlabs/puppetserver/bootstrap.cfg

OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=1g; support was removed in 8.0
RuntimeError: Got 1 failure(s) while initializing: File[/var/run/puppetlabs/puppetserver]: change from 0775 to 0755 failed: failed to set mode 0775 on /var/run/puppetlabs/puppetserver: Operation not permitted - No message available
                use at /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/settings.rb:1007

可能是什么问题?


共3个答案

匿名用户

你确定这是一个OnOutOfMemory错误吗?我问是因为我发现最新的PuppetServer包含一个更新版本的logback,如 /var/log/messages中的此消息所示:

Mar 18 01:56:21 puppetserver java: Exception in thread "main" java.lang.AbstractMethodError: ch.qos.logback.core.net.SyslogAppenderBase.createOutputStream()Lch/qos/logback/core/net/SyslogOutputStream;
Mar 18 01:56:21 puppetserver java: at ch.qos.logback.core.net.SyslogAppenderBase.start(SyslogAppenderBase.java:62)
Mar 18 01:56:21 puppetserver java: at ch.qos.logback.classic.net.SyslogAppender.start(SyslogAppender.java:48)

如果您看到,这将把logback. xml中的"classic.net.Syslog"替换为"core.net.Syslog"

sed -i_old -e 's/classic.net.Syslog/core.net.Syslog/' /etc/puppetlabs/puppetserver/logback.xml

如果这不是问题,请发布您的日志文件。

匿名用户

您已将日志提供为

OpenJDK 64位服务器VM警告:忽略选项MaxPermSize=1g;8.0中删除了支持

因此,很明显您使用的是删除永久空间的jdk 8。

永久生成(PermGen)空间已被完全删除,取而代之的是一个名为Metaspace的新空间。删除PermGen的后果是,显然PermSize和MaxPermSizeJVM参数被忽略,您将永远不会得到java. lang.OutOfMemoryError:PermGen错误

  1. 所以请删除-XX: MaxPermSize=1g部分从JAVA_ARGS的位置/etc/sysconfig/puppetserver

JAVA_ARGS="-Xms1g-Xmx1g"

所以呢

您的命令如下所示:

$ /usr/bin/java -Xms1g -Xmx1g -XX:OnOutOfMemoryError='kill -9 %%p' -Djava.security.egd=/dev/urandom -cp /opt/puppetlabs/server/apps/puppetserver/puppet-server-release.jar clojure.main -m puppetlabs.trapperkeeper.main --config /etc/puppetlabs/puppetserver/conf.d -b /etc/puppetlabs/puppetserver/bootstrap.cfg

$ /usr/bin/java -Xms1g -Xmx1g -Djava.security.egd=/dev/urandom -cp /opt/puppetlabs/server/apps/puppetserver/puppet-server-release.jar clojure.main -m puppetlabs.trapperkeeper.main --config /etc/puppetlabs/puppetserver/conf.d -b /etc/puppetlabs/puppetserver/bootstrap.cfg

请尝试这两个命令。我希望两者都能成功运行。出于谨慎的目的,我已经添加了两者。

注意:无需更改文件权限。保持它们与使用前一样。

否则,如果您不想更改任何内容,您可以将java8降级为java7

相关链接:

  1. JDK中的PermGen消除
  2. JavaHotSpot(TM)64位服务器VM警告:忽略选项MaxPermSize
  3. JAVA 8 XX:PERMSIZE和XX:MAXPERMSIZE消失
  4. JDK八大里程碑
  5. JEP 122:删除永久生成

匿名用户

@lollercoster,您的服务开始于:

sudo puppet resource service puppetserver ensure=running

但是你的下一个命令并没有告诉它是哪个用户

/usr/bin/java -Xms1g -Xmx1g -XX:MaxPermSize=1g -XX:OnOutOfMemoryError='kill -9 %%p' -Djava.security.egd=/dev/urandom -cp /opt/puppetlabs/server/apps/puppetserver/puppet-server-release.jar clojure.main -m puppetlabs.trapperkeeper.main --config /etc/puppetlabs/puppetserver/conf.d -b /etc/puppetlabs/puppetserver/bootstrap.cfg

请在运行上述命令之前直接运行whoami:

whoami
/usr/bin/java -Xms1g -Xmx1g -XX:MaxPermSize=1g -XX:OnOutOfMemoryError='kill -9 %%p' -Djava.security.egd=/dev/urandom -cp /opt/puppetlabs/server/apps/puppetserver/puppet-server-release.jar clojure.main -m puppetlabs.trapperkeeper.main --config /etc/puppetlabs/puppetserver/conf.d -b /etc/puppetlabs/puppetserver/bootstrap.cfg

为什么是这个命令?我很有信心您的问题是权限/用户上下文问题,以下命令会使情况变得更糟:

$ sudo chown -R vagrant:vagrant /var/run/puppetlabs/
$ sudo chown -R vagrant:vagrant /var/log/puppetlabs/
$ sudo chmod -R 0755 /var/run/puppetlabs/

对于上述情况,您必须在正确的用户上下文上执行sudo才能使文件可写,但这取决于其他数据是否可写。所以你可以尝试一下,但我会使用为服务创建的木偶用户

User=puppet

因此,您的木偶服务作为用户木偶运行,但您的日志文件处于流浪用户控制之下,并且对木偶用户不可写。

所以我也会尝试切换回:

$ sudo chown -R puppet /var/run/puppetlabs/
$ sudo chown -R puppet /var/log/puppetlabs/
$ sudo chmod -R 0755 /var/run/puppetlabs/

Java

此外,我建议您不要乱搞JVM堆参数,除非您知道自己在做什么。因为自JDK5以来,您不需要在JavaVM堆上强制执行下限和最大限。我只会限制在上限

-Xmx1g

堆和真正分配的内存将由javaVM很好地管理。当JVM需要更多时,它将逐步增加堆并保持所需的大小(不会缩小到更低的值)。所以你将在你的机器上有一个更好的使用RAM。

也请切换到OracleJVM。我经常面临OpenJDK的安全性和兼容性问题。所以我的第一个测试是在Oracle最新需要的JDK上运行它。在你的情况下,Oracle JDK8。但是请先尝试我之前提到的权限问题。

祝你好运,请随时向我通报最新情况。