본문 바로가기
조회 수 13304 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print Files
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print Files
Apache2 + MongoDB + ElasticSearch + Kibana

1. disable selinux


echo 0 > /selinux/enforce
vi /etc/selinux/config
---------//----------
SELINUX=disabled
---------//----------


2. install apache

yum -y install httpd

mkdir /var/www/kibana
echo '<h1>Works!</h1>' > /var/www/kibana/index.html

vi /etc/httpd/conf/httpd.conf
-------------------//---------------------
ServerName localhost

#
# IX Kibana
#
<VirtualHost *:80>
    ServerAdmin admin@localhost
    DocumentRoot /var/www/kibana
    ErrorLog logs/kibana-error_log
    CustomLog logs/kibana-access_log common
</VirtualHost>
-------------------//---------------------
service httpd restart
chkconfig httpd on

vi /etc/sysconfig/iptables
--------------8<---------------
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
--------------8<---------------
service iptables restart

Test with web browser:
http://host/


3. install mongoDB


vi /etc/yum.repos.d/mongodb.repo
--------------8<---------------
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
--------------8<---------------
yum -y install mongo-10gen mongo-10gen-server

tail -f /var/log/mongo/mongod.log <--------- start monitoring from other terminal

service mongod start
chkconfig mongod on

mongostat <------ Summary List of Status Statistics


** Testing

mongo --version
mongo <----- Enter the MongoDB Command Line

--------------8<---------------
> use test
switched to db test
> db.foo.find()
> db.foo.save({a: 1})
> db.foo.find()
{ "_id" : ObjectId("532455db3445b9d35bbc40be"), "a" : 1 }
> db.foo.update({a: 1}, {a: 5}) <------- 첫번째 {a: 1}가 오버라이드됨
> db.foo.find()
{ "_id" : ObjectId("532455db3445b9d35bbc40be"), "a" : 5 }
> db.foo.remove({a: 5})
> db.foo.find()
--------------8<---------------

Note: how to delete database

show dbs
use testdb
db.dropDatabase() 


4. install ElasticSearch and mongodb plugin


vi /etc/yum.repos.d/elasticsearch.repo
--------------8<---------------
[elasticsearch-1.0]
name=Elasticsearch repository for 1.0.x packages
baseurl=http://packages.elasticsearch.org/elasticsearch/1.0/centos
gpgcheck=1
gpgkey=http://packages.elasticsearch.org/GPG-KEY-elasticsearch
enabled=1
--------------8<---------------
yum -y install java-1.7.0-openjdk elasticsearch

tail -f /var/log/elasticsearch/elasticsearch.log <------- start monitoring from other terminal

service elasticsearch start
chkconfig elasticsearch on

Note: find right mongdb plugin version

[root@mongo-test bin]# mongo --version
MongoDB shell version: 2.4.9

[root@mongo-test bin]# /usr/share/elasticsearch/bin/elasticsearch -v
Version: 1.0.1, Build: 5c03844/2014-02-25T15:52:53Z, JVM: 1.7.0_51

02.png

** install river mongodb plugin
cd /usr/share/elasticsearch/bin
./plugin --install com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/2.0.0
./plugin --list
service elasticsearch restart


** install mapper attachments plugin
: find the right version of mapper attachments plugin
03.png

./plugin -install elasticsearch/elasticsearch-mapper-attachments/2.0.0.RC1
service elasticsearch restart


note: how to remove plugin

./plugin --remove river-mongodb
./plugin --list

service elasticsearch restart 

netstat -ntlp <------ 9200 포트 오픈 확인
curl localhost:9200 <------ json output 확인
--------------8<---------------
[root@localhost ~]# curl localhost:9200
{
  "status" : 200,
  "name" : "Gertrude Yorkes",
  "version" : {
    "number" : "1.0.1",
    "build_hash" : "5c03844e1978e5cc924dab2a423dc63ce881c42b",
    "build_timestamp" : "2014-02-25T15:52:53Z",
    "build_snapshot" : false,
    "lucene_version" : "4.6"
  },
  "tagline" : "You Know, for Search"
}
--------------8<---------------

vi /etc/sysconfig/iptables <-------- open port 9200 so your web browser can access
--------------8<---------------
-A INPUT -m state --state NEW -m tcp -p tcp --dport 9200 -j ACCEPT
--------------8<---------------
service iptables restart

vi ~/.bashrc
--------------8<---------------
# ElasticSearch
export ES_HOME=/usr/share/elasticsearch
--------------8<---------------
source ~/.bashrc


5. configure the river in elasticsearch


** create a river

curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{
    "type": "mongodb", 
    "mongodb": { 
        "db": "DATABASE_NAME", 
        "collection": "COLLECTION", 
        "gridfs": true
    }, 
    "index": { 
        "name": "ES_INDEX_NAME", 
        "type": "ES_TYPE_NAME" 
    }
}'
--------------8<---------------
curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{ 
    "type": "mongodb", 
    "mongodb": { 
        "db": "testmongo", 
        "collection": "person"
    }, 
    "index": {
        "name": "mongoindex", 
        "type": "person" 
    }
}'
--------------8<---------------

** create a db

mongo
use testmongo
var p = {firstName: "John", lastName: "Doe"}
db.person.save(p)
db.person.find()
show dbs
--------------8<---------------
> use testmongo
switched to db testmongo
> show dbs
local 0.078125GB
test 0.203125GB <--------- content가 없으므로 use testmongo를 해도 생성되는 것이 아님
> var p = {firstName: "John", lastName: "Doe"}
> db.person.save(p)
> db.person.find()
{ "_id" : ObjectId("5324f783fe5187574cb70726"), "firstName" : "John", "lastName" : "Doe" }
> show dbs
local 0.078125GB
test 0.203125GB
testmongo 0.203125GB <------- 생성됨
>
--------------8<---------------

** query test

curl -XGET 'http://localhost:9200/mongoindex/_search?q=firstName:John'
----------- output -------------
{
  "_shards": {
    "failed": 0, 
    "successful": 5, 
    "total": 5
  }, 
  "hits": {
    "hits": [], 
    "max_score": null, 
    "total": 0
  }, 
  "timed_out": false, 
  "took": 3
}
----------- /output -------------

** Admin URL: 

http://172.16.180.150:9200/_plugin/river-mongodb/
01.png

Note: how to remove the river and index

curl -XDELETE localhost:9200/_river/mongodb <------- delete river
curl -XDELETE localhost:9200/person  <----- delete index

or remove all rivers and indices

curl -XDELETE localhost:9200/_river/*
curl -XDELETE localhost:9200/* 


6. install kibana


cd /tmp
wget https://download.elasticsearch.org/kibana/kibana/kibana-latest.tar.gz
tar xfz kibana-latest.tar.gz
cp -a kibana-latest/* /var/www/kibana/


7. configure dashboard in Kibana

http://host/

Title
List of Articles
번호 제목 글쓴이 날짜 조회 수
448 /boot 파티션 손상시 복구 방법 Hojung 2011.01.07 27908
447 /proc/meminfo 내용 설명 Hojung 2011.01.07 21979
446 1.txt ~ 999.txt 파일명을 001.txt ~ 999.txt 로 변경하기 Hojung 2010.12.31 17294
445 10 Ways to Generate a Random Password from the Command Line Hojung 2014.11.16 6064
444 18 commands to monitor network bandwidth on Linux server file Hojung 2014.04.13 10070
443 20 Linux System Monitoring Tools Every SysAdmin Should Know (Cool!) Hojung 2009.10.20 12423
442 59 Open Source Tools That Can Replace Popular Security Software Hojung 2011.06.16 22372
441 A simple Linux backup method Hojung 2010.11.25 21296
440 About initrd from Wikipedia Hojung 2008.01.06 17264
439 Add arguments from previous command Hojung 2011.08.22 16806
438 Advanced SSH security tips and tricks Hojung 2011.08.18 14347
437 Apaceh2 + SSL on Fedora Core Hojung 2007.12.14 46670
436 Apache 2 with SSL/TLS (https) Hojung 2012.07.20 9737
435 Apache 2 with SSL/TLS: Step-by-Step, Part 1 Hojung 2007.12.14 16849
» Apache2 + MongoDB + ElasticSearch + Kibana file Hojung 2014.03.16 13304
433 APM (Apache + PHP + MySQL) with phpmyadmin in CentOS VM Hojung 2014.11.16 7040
432 ARP Spoofing 감지하기 (arpwatch) Hojung 2011.01.14 25854
431 arping Hojung 2007.11.18 25784
430 ATI x1300 on Fedora Core 10 Hojung 2009.04.20 22297
429 awk 명령어 간단 사용법 Hojung 2009.03.11 17799
Board Pagination ‹ Prev 1 2 3 4 5 6 7 8 9 10 ... 23 Next ›
/ 23

Designed by sketchbooks.co.kr / sketchbook5 board skin

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5