ActiveMQ cookbook触发ActiveMQ服务,但该服务未启动

ActiveMQ cookbook触发ActiveMQ服务,但该服务未启动,activemq,chef-infra,cookbook,Activemq,Chef Infra,Cookbook,Activemq服务通过cookbook触发,但不运行: activemq/attributes/default.rb default['activemq']['version'] = '5.11.0' src_filename="apache-activemq-#{node['activemq']['version']}-bin.tar.gz" src_filepath = "#{Chef::Config['file_cache_path']}/#{src_filena

Activemq服务通过cookbook触发,但不运行:

activemq/attributes/default.rb

    default['activemq']['version'] = '5.11.0'
    src_filename="apache-activemq-#{node['activemq']['version']}-bin.tar.gz"
    src_filepath = "#{Chef::Config['file_cache_path']}/#{src_filename}"
    default['activemq']['src_filepath'] = "#{src_filepath}"
    default['activemq']['tar_filepath'] = "http://xxx-xx-xx-xxx-xx:8091/3rdparty/activemq/#{src_filename}"

    default['activemq']['dir'] = "/usr/local/apache-activemq-#{node['activemq']['version']}"

    default['activemq']['wrapper']['max_memory'] = '1024'
    default['activemq']['wrapper']['useDedicatedTaskRunner'] = 'true'

    default['activemq']['zooKeeper']['address']="xxx.xx.xx.xx:2181"
    default['activemq']['zooKeeper']['hostname']="xxx.xx.xx.xx"
include_recipe "lgjava"

activemq_home= node['activemq']['dir']


remote_file "#{node['activemq']['src_filepath']}" do
  mode 0755
  source node['activemq']['tar_filepath']
  action :create
  notifies :create, "directory[apache-activemq-#{node['activemq']['version']}]", :immediately
  notifies :run, "execute[untar-activemq]", :immediately
end


directory "apache-activemq-#{node['activemq']['version']}" do
  path "#{activemq_home}"
  mode 0755
  recursive true
end


execute "untar-activemq" do
  cwd Chef::Config[:file_cache_path]
  command <<-EOF
    tar xvzf apache-activemq-#{node['activemq']['version']}-bin.tar.gz -C #{node['activemq']['dir'] } --strip 1
  EOF
  action :run
end



file "#{activemq_home}/bin/activemq" do
  owner 'root'
  group 'root'
  mode  '0755'
end


arch = node['kernel']['machine'] == 'x86_64' ? 'x86-64' : 'x86-32'

link '/etc/init.d/activemq' do
  to "#{activemq_home}/bin/linux-#{arch}/activemq"
end

template "jetty-realm.properties" do
  source "jetty-realm.properties.erb"
  mode "0755"
  path "#{activemq_home}/conf/jetty-realm.properties"
  action :create
  notifies :restart, 'service[activemq]'
end


template "activemq.xml" do
  source "activemq.xml.erb"
  mode "0755"
  path "#{activemq_home}/conf/activemq.xml"
  action :create
  notifies :restart, 'service[activemq]'
end

service 'activemq' do
  supports :restart => true, :status => true
  action   [:enable, :start]
end


# symlink so the default wrapper.conf can find the native wrapper library
link "#{activemq_home}/bin/linux" do
  to "#{activemq_home}/bin/linux-#{arch}"
end

# symlink the wrapper's pidfile location into /var/run
link '/var/run/activemq.pid' do
  to "#{activemq_home}/bin/linux/ActiveMQ.pid"
  not_if 'test -f /var/run/activemq.pid'
end

template "#{activemq_home}/bin/linux/wrapper.conf" do
  source   'wrapper.conf.erb'
  mode     '0644'
  notifies :restart, 'service[activemq]'
end
activemq/recipes/default.rb

    default['activemq']['version'] = '5.11.0'
    src_filename="apache-activemq-#{node['activemq']['version']}-bin.tar.gz"
    src_filepath = "#{Chef::Config['file_cache_path']}/#{src_filename}"
    default['activemq']['src_filepath'] = "#{src_filepath}"
    default['activemq']['tar_filepath'] = "http://xxx-xx-xx-xxx-xx:8091/3rdparty/activemq/#{src_filename}"

    default['activemq']['dir'] = "/usr/local/apache-activemq-#{node['activemq']['version']}"

    default['activemq']['wrapper']['max_memory'] = '1024'
    default['activemq']['wrapper']['useDedicatedTaskRunner'] = 'true'

    default['activemq']['zooKeeper']['address']="xxx.xx.xx.xx:2181"
    default['activemq']['zooKeeper']['hostname']="xxx.xx.xx.xx"
include_recipe "lgjava"

activemq_home= node['activemq']['dir']


remote_file "#{node['activemq']['src_filepath']}" do
  mode 0755
  source node['activemq']['tar_filepath']
  action :create
  notifies :create, "directory[apache-activemq-#{node['activemq']['version']}]", :immediately
  notifies :run, "execute[untar-activemq]", :immediately
end


directory "apache-activemq-#{node['activemq']['version']}" do
  path "#{activemq_home}"
  mode 0755
  recursive true
end


execute "untar-activemq" do
  cwd Chef::Config[:file_cache_path]
  command <<-EOF
    tar xvzf apache-activemq-#{node['activemq']['version']}-bin.tar.gz -C #{node['activemq']['dir'] } --strip 1
  EOF
  action :run
end



file "#{activemq_home}/bin/activemq" do
  owner 'root'
  group 'root'
  mode  '0755'
end


arch = node['kernel']['machine'] == 'x86_64' ? 'x86-64' : 'x86-32'

link '/etc/init.d/activemq' do
  to "#{activemq_home}/bin/linux-#{arch}/activemq"
end

template "jetty-realm.properties" do
  source "jetty-realm.properties.erb"
  mode "0755"
  path "#{activemq_home}/conf/jetty-realm.properties"
  action :create
  notifies :restart, 'service[activemq]'
end


template "activemq.xml" do
  source "activemq.xml.erb"
  mode "0755"
  path "#{activemq_home}/conf/activemq.xml"
  action :create
  notifies :restart, 'service[activemq]'
end

service 'activemq' do
  supports :restart => true, :status => true
  action   [:enable, :start]
end


# symlink so the default wrapper.conf can find the native wrapper library
link "#{activemq_home}/bin/linux" do
  to "#{activemq_home}/bin/linux-#{arch}"
end

# symlink the wrapper's pidfile location into /var/run
link '/var/run/activemq.pid' do
  to "#{activemq_home}/bin/linux/ActiveMQ.pid"
  not_if 'test -f /var/run/activemq.pid'
end

template "#{activemq_home}/bin/linux/wrapper.conf" do
  source   'wrapper.conf.erb'
  mode     '0644'
  notifies :restart, 'service[activemq]'
end

手动启动activemq是否有效?听起来并不是chef不启动activemq,而是activemq无法启动start@Tensibai它是手动工作的。正如您所说,这是activemq的一个问题,我通过查看activemq.log文件修复了它。
Recipe: activemq::default
  * remote_file[/var/chef/cache/apache-activemq-5.11.0-bin.tar.gz] action create (up to date)
  * directory[apache-activemq-5.11.0] action create (up to date)
  * execute[untar-activemq] action run
    - execute     tar xvzf apache-activemq-5.11.0-bin.tar.gz -C /usr/local/apache-activemq-5.11.0 --strip 1

  * file[/usr/local/apache-activemq-5.11.0/bin/activemq] action create (up to date)
  * link[/etc/init.d/activemq] action create (up to date)
  * template[jetty-realm.properties] action create
    - update content in file /usr/local/apache-activemq-5.11.0/conf/jetty-realm.properties from 827a97 to 96c9a9
    --- /usr/local/apache-activemq-5.11.0/conf/jetty-realm.properties   2015-01-30 13:13:51.000000000 +0000
    +++ /tmp/chef-rendered-template20150211-9315-ul0l7k 2015-02-11 07:03:37.711054777 +0000
    @@ -5,9 +5,9 @@
     ## The ASF licenses this file to You under the Apache License, Version 2.0
     ## (the "License"); you may not use this file except in compliance with
     ## the License.  You may obtain a copy of the License at
    -## 
    +##
     ## http://www.apache.org/licenses/LICENSE-2.0
    -## 
    +##
     ## Unless required by applicable law or agreed to in writing, software
     ## distributed under the License is distributed on an "AS IS" BASIS,
     ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    @@ -17,6 +17,6 @@

     # Defines users that can access the web (console, demo, etc.)
     # username: ***** 
    -admin: *****, *****
    -user: ****, *****
    +admin: *****, ****
    +user: *****, ****
    - change mode from '0644' to '0755'
    - restore selinux security context
  * template[activemq.xml] action create
    - update content in file /usr/local/apache-activemq-5.11.0/conf/activemq.xml from ca8528 to 219698
    --- /usr/local/apache-activemq-5.11.0/conf/activemq.xml 2015-01-30 13:13:51.000000000 +0000
    +++ /tmp/chef-rendered-template20150211-9315-8syvv7 2015-02-11 07:03:37.736055052 +0000
    @@ -78,11 +78,20 @@

                 http://activemq.apache.org/persistence.html
             -->
    +        <!--
             <persistenceAdapter>
                 <kahaDB directory="${activemq.data}/kahadb"/>
    -        </persistenceAdapter>
    +        </persistenceAdapter>  -->
    +        <persistenceAdapter>
    +           <replicatedLevelDB directory="activemq-data"
    +            replicas="2"
    +            bind="tcp://x.x.x.x:x"
    +            zkAddress=xxxxxxx
    +            zkPath=xxxxxx
    +            hostname=xxxxxx />


    +        </persistenceAdapter>
               <!--
                 The systemUsage controls the maximum amount of space the broker will
                 use before disabling caching and/or slowing down producers. For more information, see:
    @@ -133,5 +142,4 @@
         <import resource="jetty.xml"/>

     </beans>
    -<!-- END SNIPPET: example -->
    - change mode from '0644' to '0755'
    - restore selinux security context
  * service[activemq] action enable (up to date)
  * service[activemq] action start (up to date)
  * link[/usr/local/apache-activemq-5.11.0/bin/linux] action create (up to date)
  * link[/var/run/activemq.pid] action create (up to date)
  * template[/usr/local/apache-activemq-5.11.0/bin/linux/wrapper.conf] action create (up to date)
Recipe: lgtomcat::default
  * service[tomcat7] action restart
    - restart service service[tomcat7]
Recipe: activemq::default
  * service[activemq] action restart
    - restart service service[activemq]
ps -eaf| grep activemq
root      9867  9301  0 07:07 pts/1    00:00:00 grep --color=auto activemq