ELK5 安装教程

启动教程

1 elasticsearch

cd /soft/elasticsearch-5.1.2/ nohup ./bin/elasticsearch >/dev/null &

ps aux | grep -i elasticsearch | awk {'print $2'} | xargs kill -9

2 elasticsearch-head

cd /soft/elasticsearch-head-master/ nohup grunt server >/dev/null &

ps aux | grep -i grunt | awk {'print $2'} | xargs kill -9

3 logstash

cd /soft/logstash-5.1.2/ nohup ./bin/logstash -f userconf/test-log.conf >/dev/null &

ps aux | grep -i logstash | awk {'print $2'} | xargs kill -9

4 kibana

cd /soft/kibana-5.1.2 nohup ./bin/kibana >/dev/null &

ps aux | grep -i kibana | awk {'print $2'} | xargs kill -9

安装教程

elk新版要求jdk1.8以上版本,请先确定服务器jdk版本 java -version

https://www.elastic.co/products 下载 logstash elasticsearch kibana

cd /soft

tar -xzvf logstash-5.1.2.tar.gz tar -xzvf elasticsearch-5.1.2.tar.gz tar -xzvf kibana-5.1.2-linux-x86_64.tar.gz

rm -rf logstash-5.1.2.tar.gz rm -rf elasticsearch-5.1.2.tar.gz rm -rf kibana-5.1.2-linux-x86_64.tar.gz

1 elasticsearch安装

cd /soft/elasticsearch-5.1.2/

vi config/elasticsearch.yml

network.host: 0.0.0.0
#增加新的参数,开启http可以访问es
http.cors.enabled: true
http.cors.allow-origin: "*"

保存退出

vi config/jvm.options

-Xms1g -Xmx1g

保存退出

cd /soft/elasticsearch-5.1.2/

http://www.cnblogs.com/sloveling/p/elasticsearch.html 常见问题解决

./bin/elasticsearch

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] 解决启动报错 切换到root用户修改配置sysctl.conf

vi /etc/sysctl.conf

添加下面配置:

vm.max_map_count=655360

并执行命令:

sysctl -p

然后,重新启动elasticsearch,即可启动成功。

nohup ./bin/elasticsearch >/dev/null &

ps -ef |grep elasticsearch

验证是否启动成功

curl 127.0.0.1:9200

返回

{
  "name" : "r-juGZs",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "TKOx86-kRn2H0HrZ3hrQEg",
  "version" : {
    "number" : "5.1.2",
    "build_hash" : "c8c4c16",
    "build_date" : "2017-01-11T20:18:39.146Z",
    "build_snapshot" : false,
    "lucene_version" : "6.3.0"
  },
  "tagline" : "You Know, for Search"
}

2 elasticsearch-head插件安装

切换root帐号

https://nodejs.org/en/download/ 下载nodejs上传到服务器

cd /usr/local/

yum -y install xz xz -d node-v6.9.4-linux-x64.tar.xz tar -xvf node-v6.9.4-linux-x64.tar rm -rf node-v6.9.4-linux-x64.tar

设置软链 ln -s /usr/local/node-v6.9.4-linux-x64/bin/node /usr/sbin/node ln -s /usr/local/node-v6.9.4-linux-x64/bin/npm /usr/sbin/npm

设置npm代理镜像 npm config set registry https://registry.npm.taobao.org

安装、配置grunt npm install -g grunt ln -s /usr/local/node-v6.9.4-linux-x64/lib/node_modules/grunt/bin/grunt /usr/sbin/grunt

安装head

cd elasticsearch-head-master/

npm install

修改_site/app.js vi _site/app.js

// 把localhost改为ip
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
修改为
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://172.16.1.13:9200";

修改Gruntfile.js vi Gruntfile.js

connect: {
    server: {
        options: {                                                                                                                                                                                                                                                    
            hostname: "0.0.0.0", #这里
            port: 9100,
            base: '.',
            keepalive: true
        }   
    }   
}

启动

nohup grunt server >/dev/null &

访问 http://172.16.1.13:9100/

3 logstash 安装

cd /soft/logstash-5.1.2/

mkdir userconf

vi userconf/test-log.conf

input {
    redis {
        data_type => "list"
        key => "logstash:redis"
        host => "172.16.1.22"
        port => 6381
        threads => 5
        type => "test-log"
        codec => "json"
    }
}
output {
   if [type] == "test-log" {
        elasticsearch {
            hosts => ["172.16.1.13:9200"]
            index => "youren-test-%{+YYYY.MM.dd}"
        }
    }
}

保存退出

nohup ./bin/logstash -f userconf/test-log.conf >/dev/null &

代码端参考网址 https://github.com/kmtong/logback-redis-appender http://www.cnblogs.com/ASPNET2008/p/5594479.html

4 kibana

cd /soft/kibana-5.1.2

vi config/kibana.yml

server.port: 5601 server.host: "0.0.0.0" elasticsearch.url: "http://192.168.50.135:9200"

保存退出

nohup ./bin/kibana >/dev/null &

访问 http://172.16.1.13:5601/

评论

暂无评论