Redis+Logstash+Elasticsearch配置筆記

一、 開機自動啓動Redisweb

1),拷貝redis目錄utils下的redis_init_script文件到/etc/init.d,並將其重命名爲redisd,再運行chmod u+x redisdredis

2),修改redis根目錄下的redis.conf,將daemonize修改成yes,將pidfile,修改成/var/run/redis_6379.pidjson

3),將redis根目錄下的redis.conf拷貝到/etc/redis/目錄下,重命名爲6379.confruby

4),修改6379.conf,找到 SNAPSHOTTING一節,將working directory處的dir ./改成dir /var/lib/redis。建立/var/lib/redis目錄 cors

5),在控制檯輸入chkconfig redisd on,配置爲開機啓動,若是報錯則在redisd文件頭修改成ssh

#!/bin/shelasticsearch

# chkconfig:   2345 90 10spa

6)執行命令service redisd start啓動服務,如要關閉則將start改爲stopdebug

 

二、SSH遠程執行Logstash和elasticsearch,關閉ssh窗口後不關閉進程code

1)配置並啓動elasticsearch。首先編輯elasticsearc目錄下config目錄中的elastcsearch.yml文件,在最後添加內容http.cors.enabled: true,而後輸入命令nohup bin/elasticsearch & 啓動。

2)修改redis的配置文件。在logstash的目錄下建立一個目錄redis_conf,再建立一個文件redis.conf,內容以下:

input {
redis {
host => "127.0.0.1"
type => "redis-input"
# these settings should match the output of the agent
data_type => "list"
key => "log"#這裏是redis的數據來源,根據須要自行配置
}
}

filter{
json{source => "message"}

date{
match => ["WRITETIME", "ISO8601"]
}

}

output {
  stdout {
    codec => rubydebug
  }

  elasticsearch {
        host => "localhost"       
  }

}

運行命令nohup bin/logstash agent -f redis_conf &,啓動logstash

注意:logstash默認給elasticseach配置了一個index模板,裏面會將全部的字符串類型,再新建一個raw的類型,不作analysis,但前提是你的index 的名字是以logstash開頭的


3)打開logstash的web界面,運行命令nohup bin/logstash-web &

這時,應該啓動的服務有

a、redis進程

b、elasticsearch進程

c、logstash的進程

d、logstash-web進程

相關文章
相關標籤/搜索