ELK集群
修改位置
编译安装
修改hosts文件
安装elasticsearch
修改elasticsearch主配置文件
18 cluster .name: ELK 集群名字ELK
25 node. name: centos01 节点计算机名
46 bootstrap . memory_ 1ock: false 不锁定内存
59 network.host: 192.168. 100.10 监听的IP地址
64 http.port: 9200 监听的端口
74 discovery.zen.ping.unicast.hosts: ["centos01", "centos02"] 集群节点添加
启动服务
客户端测试字符界面
http://192.168.100.10:9200/
http://192.168.100.10:9200/_cluster/health
安装字符界面管理
tar jxvf /mnt/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/src/
查看快捷键是否支持 是否可以TABb补全
修改主配置文件
http. cors. enabled: true .
开启跨域访问
http. cors.allow-origin:
”*”
跨域允许访间主机或者域名
重启服务
修改elasticsearch-head配置文件
修改配置文件监听的ip
启动
按照以上步骤可以配置多台ELK服务器
客户端测试
http://192.168.100.10:9100/
配置logstash采集客户端日志
安装logstah命令
优化命令
测试logstash设置标准输入和输出内容
logstash -e 'input { stdin {} } output { stdout {} }'
测试输入的域名显示出来
logstash -e 'input { stdin {} } output { stdout { codec=>rubydebug } }'
将测试的日志信息写入到elasticsearch
logstash -e 'input { stdin { } } output { elasticsearch { hosts=>["192.168.100.10"] } }'
设置允许用户读取系统日志
创建采集系统日志配置文件
配置采集系统日志文件
input {
file {
path => "/var/log/messages"
type => "system"
start_position => "beginning"
}
}
output {
elasticsearch {
hosts => ["192.168.100.10:9200"]
index => "system-%{+YYYY.MM.dd}"
}
}
检查采集文件是否错误
logstash -f /etc/logstash/conf.d/system.conf
重新启动服务
客户端测试
安装apache
启动服务
创建apache日志采集文件
启动服务
创建apache日志采集文件
配置采集文件
input {
file {
path => "/var/log/httpd/access_log"
type => "access"
start_position => "beginning"
}
file {
path => "/var/log/httpd/error_log"
type => "error"
start_position => "beginning"
}
}
output {
if [type] == "access" {
elasticsearch {
hosts => ["192.168.100.10:9200"]
index => "apache_access-%{+YYYY+MM+dd}"
}
}
if [type] == "error" {
elasticsearch {
hosts => ["192.168.100.10:9200"]
index => "apache_error-%{+YYYY+MM+dd}"
}
}
}
设置开机自启
客户端测试
安装kibana
修改配置文件
3 server.port: 5601 监所端口
9 server. host: "192.168.100.10" 监听IP地址
24 elasticsearch.url: "http://192.168. 100.10:9200"采集192.168. 100.10日志
34 kibana. index: " .kibana" 使用kibana查看日志
启动服务设置开机自启
访问kibana服务器
http://192.168.100.10:5601