【问题标题】:Ubuntu upstart can not stop/restart graphite carbon-cacheUbuntu 新贵无法停止/重启石墨碳缓存
【发布时间】:2013-11-07 06:09:10
【问题描述】:

我在 /etc/init/carbon-cache.conf 创建了 upstart 配置文件来停止/启动/重启 carbon-cache 进程。我可以使用命令启动 carbon-cache 进程:start carbon-cache,但是,我无法使用 stop/restart carbon-cache 并且总是给我错误:“stop: Unknown instance:”。

有谁知道这似乎是什么问题?这是我的新贵配置:/etc/init/carbon-cache.conf

description "Daemonized Carbon-Cache"

start on runlevel [2345]
stop on runlevel [016]

setuid www-data
setgid www-data

exec /opt/graphite/bin/carbon-cache.py start

respawn
respawn limit 10 5

【问题讨论】:

  • 这可能与进程启动时正在执行的操作有关。如果它分叉,您应该获得分叉进程的 pid 而不是父进程。使用ps ax | grep carbon 来找出答案。 upstart 中有一个特殊的节 - 期望 - 处理这种情况。阅读此upstart.ubuntu.com/cookbook/#expect
  • 我尝试了以下操作,但效果不佳:wiki.xkyle.com/Carbon_Collector

标签: linux ubuntu ubuntu-12.04 upstart graphite


【解决方案1】:

我建议使用这个 carbon-cache.conf 文件:https://gist.github.com/dbeckham/8057390

【讨论】:

  • 这个文件的 cmets 引用的钱:# 有趣的事实,没有 --nodaemon,twistd carbon-cache 分叉五次(5!)。 # Upstart 的设计初衷不是为了处理这种级别的 wtf。
【解决方案2】:

我认为正在发生的事情是您的暴发户能够成功执行它,但是一旦它运行,carbon-cache 就会因为它的守护进程而与暴发户分离。因此,当 upstart 试图杀死它时,它会意识到 carbon-cache 不再附加。

Upstart 期望命令运行保持在前台,而不是分叉和解除附加。

“Twistd,用于守护碳缓存的实用程序支持--nodaemon 标志,该标志在前台启动进程而不是将其分叉到后台。在发布此article 时,获得twistd 的 --nodaemon 标志是通过使用 --debug 启动 carbon-cache。"

不过,我建议不要取消守护碳,这在新贵实施中是必要的。

【讨论】:

  • 新贵目前支持“期望守护进程”,但不知何故我无法让它按预期工作。我宁愿不使用 --debug。
【解决方案3】:

sudo /opt/graphite/bin/carbon-cache.py start

【讨论】:

  • 嗨@erbdex,我知道我可以使用 carbon-cache.py 停止/启动进程,但是,让暴发户停止/重新启动对我来说是一个我必须弄清楚的问题。
  • 您正在将用户权限授予“www-data”用户。因此,碳缓存启动是代表该用户完成的。但是 carbon-cache 需要 root 级别的访问权限来启动套接字连接并将人员发送到火星。因此,使用-"""exec sudo /opt/graphite/bin/carbon-cache.py start"""
  • 即使使用root,也无济于事。请注意,我可以启动但我不能停止/重新启动暴发户。
  • 我仍然觉得这是一个权限问题。您能否尝试将“setuid www-data”替换为“setuid root”和“setgid www-data”替换为“setgid root”以确认。 (并且不要忘记使用 root 删除“sudo”。)
  • 更改为您的建议,启动正常,停止显示错误:# stop carbon-cache stop: Unknown instance:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-13
  • 1970-01-01
  • 1970-01-01
  • 2023-03-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多