7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

fluentd 1.1 + Elasticsearch 1.2 + Kibana 3 on CentOS6.5 in Vagrant

Last updated at Posted at 2015-04-14

Vagrant上でfluentd, Elasticsearch, Kibanaを動かしたのでそのメモ.
CentOS7.x上でElasticsearch1.5, Kibana4を動かしたいですが,情報が少ないのでまずは古いバージョンで試しました.

基本的には以下のサイト
参考:AWS EC2上にfluentd + fluent-plugin-twitter + elasticsearch + kibana インストールするメモ
に加えて,Vagrantのポートフォワーディングの設定と,それぞれの設定でそのポートに関する記述を加えると動作します.

題材も参考サイトと同様にTwitterのデータをfluentdで取ってきます.

まずはVagrantfileにポートフォワーディングなどの設定を加えて,vagrant upします.

Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "opscode-centos-6.5"
  config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box"

  config.vm.network :forwarded_port, host: 4567, guest: 80
  #config.vm.network :forwarded_port, host: 5601, guest: 5601
  config.vm.network :forwarded_port, host: 9200, guest: 9200

  config.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--memory", "1024"]
  end

  config.vm.provision "shell", inline: <<-SHELL
  SHELL

end

9200はelasticsearchのポート,5601はkibana4のポートなので,kibana3を使用する際には必要ないと思います.ホストの4567番ポートに外部からアクセスすると,vagrant上のこのCentOSの80番のポートに飛ばされるようになっています.

boxのダウンロードにしばらく時間がかかりますが,20分程度(?)待っていると終わります.

vangrant sshで接続します.

その後は基本的に参考サイトと同様の手順.で環境設定を行っていく.
このとき,CentOS7.xだとエラーがでてうまく設定されませんでした.

参考:fluent-plugin-twitterインストール

$ sudo service td-agent restart

の後に

$ eventmachine

は必要だと思います.

http://localhost:9200/twitter-2014.07.15/_search

と書いてある部分は,日付はその日の日付になります.

cURLコマンドを使用せず,このURLに直接ブラウザからアクセスするとJSON形式のデータ全て見れます.

参考サイトのconfig.jsの変更点

/home/kibana/kibana/config.js
define(['settings'],
function (Settings) {
  return new Settings({
    elasticsearch: "http://xxx.xxx.xxx.xxx:4567/es/",
    default_route     : '/dashboard/file/default.json',
    kibana_index: "kibana-int",
    panel_names: [
      'histogram',
      'map',
      'goal',
      'table',
      'filtering',
      'timepicker',
      'text',
      'hits',
      'column',
      'trends',
      'bettermap',
      'query',
      'terms',
      'stats',
      'sparklines'
    ]
  });
});

また,

/etc/httpd/conf.d/kibana.conf
NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot /home/kibana/kibana
    ServerName xxx.xxx.xxx.xxx:4567
    ProxyPass /es/ http://xxx.xxx.xxx.xxx:9200/
    ProxyPassReverse /es/ http://xxx.xxx.xxx.xxx:9200/
    CustomLog logs/access_log custom
    ErrorLog logs/error_log
    Options FollowSymLinks
</VirtualHost>

and then

$ sudo service elasticsearch start
$ sudo service td-agent start
$ sudo service httpd start

これで

http://xxx.xxx.xxx.xxx:4567

に接続するとkibana3のDashboardが見られると思います.

失敗した所

最初ポートの設定がよく分からず,
CentOS iptablesによるパケットフィルタ
CentOS に iptables の設定を行う (IPv4)
立ち上げ直後のiptablesを設定する。
CentOS on Slicehost – iptablesを設定する
iptablesとかいじっていたら
$ vagrant sshで仮想マシンに入れなくなった場合の対処法
こういうことになりました.iptablesをイジる必要はありません.

その他参考資料

Vagrant + Webサーバ

Vagrant + CentOS 6.4 + Apacheで仮想サーバ構築

Elasticsearch

Elasticsearch Advent Calendar 2014
ElasticSearch + MongoDBをNode.jsで操作する
「niconicoの検索を支えるElasticsearch」と題して、第7回Elasticsearch勉強会で発表しました
ニコニコデータセット

Kibana

Kibana入門 by Yusuke Mito

Spark

Apache Spark & Elasticsearch by DATABRICKS
あのSpark開発の総本山Databricksは何を目指しているのか、共同創業者に聞く
Spark on elasticsearch-hadoop トライアル

MongoDB

fluentd + MongoDB + Elasticsearch + Kibanaでログを可視化する
USING MONGODB WITH HADOOP & SPARK: PART 3 - SPARK EXAMPLE & KEY TAKEAWAYS

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?