简体   繁体   English

Chef-solo挂在最后,安装redis

[英]chef-solo hangs at the end installing redis

chef-solo hangs at the end when installing redis as if chef is waiting for some event to occur. 当安装redis时,chef-solo挂在末尾,好像厨师正在等待某个事件发生。 Here is output when I had to kill it with ctrl+c. 这是我必须使用ctrl + c杀死它时的输出。

[2013-05-14T15:55:27+00:00] ERROR: Running exception handlers [2013-05-14T15:55:27 + 00:00]错误:正在运行异常处理程序
[2013-05-14T15:55:27+00:00] ERROR: Exception handlers complete Chef Client failed. [2013-05-14T15:55:27 + 00:00]错误:异常处理程序完成Chef Client失败。 8 resources updated 更新了8种资源
[2013-05-14T15:55:27+00:00] FATAL: Stacktrace dumped to /home/ubuntu/cache/chef-stacktrace.out [2013-05-14T15:55:27+00:00] FATAL: Chef::Exceptions::MultipleFailures: Multiple failures occurred: [2013-05-14T15:55:27 + 00:00]致命:Stacktrace转储到/home/ubuntu/cache/chef-stacktrace.out [2013-05-14T15:55:27 + 00:00]致命:厨师:: Exceptions :: MultipleFailures:发生了多个故障:
* SystemExit occurred in chef run: service[redis] (redis::default line 107) had an error: SystemExit: exit *在厨师运行中发生SystemExit:service [redis](redis ::默认行107)有一个错误:SystemExit:退出
* Chef::Exceptions::Exec occurred in delayed notification: service[redis] (redis::default line 83) had an error: Chef::Exceptions::Exec: /sbin/start redis returned 1, expected 0 * Chef :: Exceptions :: Exec发生在延迟通知中:service [redis](redis :: default第83行)发生错误:Chef :: Exceptions :: Exec:/ sbin / start重传了1,预期为0

I am new to chef and unable to figure out why this is happening. 我是厨师新手,无法弄清楚为什么会这样。 Has anyone noticed this behaviour before? 有没有人注意到这种行为?

Here is my recipe file 这是我的配方文件

package "build-essential" do
  action :install
end

user node[:redis][:user] do
  action :create
  system true
  shell "/bin/false"
end

directory node[:redis][:dir] do
  owner node[:redis][:user]
  group node[:redis][:user]
  mode "0755"
  action :create
end

directory node[:redis][:data_dir] do
  owner node[:redis][:user]
  group node[:redis][:user]
  mode "0755"
  action :create
end

directory node[:redis][:log_dir] do
  owner node[:redis][:user]
  group node[:redis][:user]
  mode "0755"
  action :create
end

remote_file "#{Chef::Config[:file_cache_path]}/redis-2.6.10.tar.gz" do
  source "http://redis.googlecode.com/files/redis-2.6.10.tar.gz"
  action :create_if_missing
end

# Adding 'make test' causes the install to freeze for some reason.
bash "compile_redis_source" do
  cwd Chef::Config[:file_cache_path]
  code <<-EOH
    tar zxf redis-2.6.10.tar.gz
    cd redis-2.6.10
    make && sudo make install
    # to give permissions to the executables that it copied to.
    chown -R redis:redis /usr/local/bin
  EOH
  creates "/usr/local/bin/redis-server"
end

service "redis" do
  provider Chef::Provider::Service::Upstart
  subscribes :restart, resources(:bash => "compile_redis_source")
  supports :restart => true, :start => true, :stop => true
end

template "redis.conf" do
  path "#{node[:redis][:dir]}/redis.conf"
  source "redis.conf.erb"
  owner node[:redis][:user]
  group node[:redis][:user]
  mode "0644"
  notifies :restart, resources(:service => "redis")
end

template "redis.upstart.conf" do
  path "/etc/init/redis.conf"
  source "redis.upstart.conf.erb"
  owner node[:redis][:user]
  group node[:redis][:user]
  mode "0644"
  notifies :restart, resources(:service => "redis")
end

service "redis" do
  action [:enable, :start]
end

There are 2 service "redis" resource statements, is that a problem? 有2个服务“ redis”资源语句,是否有问题? or how does chef workout in this case, does it merge into a single resource when running? 或者在这种情况下如何进行厨师锻炼,跑步时是否将其合并为一个资源?

I am using upstart and here is the redis.upstart.conf.erb file. 我正在使用upstart,这是redis.upstart.conf.erb文件。 Not sure if anything is wrong with this. 不知道这是否有问题。 Does the order of the statement matter in this file? 语句的顺序在此文件中是否重要?

#!upstart
description "Redis Server"
emits redis-server

# run when the local FS becomes available
start on local-filesystems
stop on shutdown

setuid redis
setgid redis
expect fork

# Respawn unless redis dies 10 times in 5 seconds
#respawn
#respawn limit 10 5

# start a default instance
instance $NAME
env NAME=redis
#instance $NAME

# run redis as the correct user
#setuid redis
#setgid redis

# run redis with the correct config file for this instance
exec /usr/local/bin/redis-server /etc/redis/redis.conf

respawn
#respawn limit 10 5

I think Dmytro was on the right path, but not exactly. 我认为Dmytro走在正确的道路上,但不完全正确。

I see that you are using Upstart as the service provider in Chef. 我看到您正在使用Upstart作为Chef中的服务提供商。 Please check your Upstart config for redis-server for any expect statement. 请检查redis-server Upstart配置中是否有任何expect语句。 If you have an expect fork or expect daemon statement in there, it means that when starting redis-server , Upstart will be waiting for the Redis service to fork once or twice respectively. 如果您在其中有一个expect forkexpect daemon语句,则意味着启动redis-server ,Upstart将分别等待Redis服务分支一次或两次。 If you have daemonize no in the redis.conf , Redis process will never fork, and therefore Upstart just hangs at the execution of the init script. 如果在daemonize noredis.conf进程daemonize no ,那么Redis进程将永远不会分叉,因此Upstart只会在执行初始化脚本时挂起。

Your redis is not failing to start, it simply runs in the foreground. 您的redis不会启动,只是在前台运行。

I had similar problem with one of the Redis cookbooks I was using. 我使用的Redis食谱之一也有类似的问题。 In the redis.conf.erb file it had configuration option redis.conf.erb文件中,它具有配置选项

daemonize no

Some other cookbooks have this option configurable by attribute. 其他一些食谱具有可通过属性配置的此选项。 So, your fix would depend on the cookbook you are using. 因此,您的修复将取决于您使用的食谱。 Either edit your redis.conf.erb file or find how that attribute is configured and set it to yes . 编辑您的redis.conf.erb文件,或者找到如何配置该属性并将其设置为yes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM