我尝试将elasticsearch和kibana的安装制作成Chef的食谱。#elasticsearch #kibana #chef

如果将其变为一位厨师的食谱,可能会很方便呢。

环境

CentOS 6.5:中文下的短语相对应为“CentOS 6.5”。

Elasticsearch 弹性搜索

## java install
package "java-1.7.0-openjdk" do
  action :install
end

## install
bash "elasticsearch" do
  not_if "ls /usr/local/share/elasticsearch-1.2.1"
  user "root"
  cwd "/usr/local/src"
  code <<-EOH
    wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.2.1.tar.gz
    tar xvzf elasticsearch-1.2.1.tar.gz -C /usr/local/share/
  EOH
end

## add service
bash "elasticsearch_as_service" do
  not_if "ls usr/local/share/elasticsearch-1.2.1/bin/service"
  user "root"
  cwd "/usr/local/src"
  code <<-EOH
    wget https://github.com/elasticsearch/elasticsearch-servicewrapper/archive/master.zip
    unzip /usr/local/src/master
    mv /usr/local/src/elasticsearch-servicewrapper-master/service/ /usr/local/share/elasticsearch-1.2.1/bin/
    /usr/local/share/elasticsearch-1.2.1/bin/service/elasticsearch install
  EOH
end

## elasticsearch log dir
directory '/usr/local/share/elasticsearch-1.2.1/logs/' do
  owner 'root'
  group 'root'
  mode '0755'
  action :create
end

## elasticsearch.yml
template "/usr/local/share/elasticsearch-1.2.1/config/elasticsearch.yml" do
  source "elasticsearch.yml.erb"
  owner "root"
  group "root"
  mode 755
end


## service start
service "elasticsearch" do
    action [ :enable, :start ]
    subscribes :restart, resources(:template => "/usr/local/share/elasticsearch-1.2.1/config/elasticsearch.yml")
end

## chkconfig
execute "add_elasticsearch_service" do
  user "root"
  command  "chkconfig elasticsearch on"
  action :run
end
    template/default

请将以下文件放在这个目录中。

elasticsearch的配置文件elasticsearch.yml.erb

哎呀?我觉得怎么回事

    • logディレクトリがなくて、起動に失敗したので、ディレクトリ作成を追加した

 

    javaがなかったのでインストールしました。。

Kibana基本上是Elasticsearch(ES)的一个高级用户界面,允许用户通过图表、图形和可视化工具来浏览和管理数据。

## directory
directory '/var/www/html/kibana' do
  owner 'root'
  group 'root'
  mode '0755'
  action :create
end

## kibana install
bash "kibana" do
  not_if "ls /var/www/html/kibana"
  user "root"
  cwd "/usr/local/src"
  code <<-EOH
    wget https://download.elasticsearch.org/kibana/kibana/kibana-3.1.0.tar.gz
    tar xvzf kibana-3.1.0.tar.gz -C /var/www/html
    mv /var/www/html/kibana-3.1.0 /var/www/html/kibana
  EOH
end

## kibana config setting
template "/var/www/html/kibana/config.js" do
  source "config.js.erb"
  owner "root"
  group "root"
  mode 755
end

将Apache安装独立为一个单独的配方,并可重复使用。

package "httpd" do
    version "2.2.15-30.el6.centos"
    action :install
end

service "httpd" do
  supports :status =>true, :restart=>true, :reload=>true
  action [:enable, :start]
end

execute "add_httpd_service" do
  user "root"
  command  "chkconfig httpd on"
  action :run
end
    template/default

请将以下文件放在此目录下。

config.js.erb的文件

广告
将在 10 秒后关闭
bannerAds