a、官方下载地址:https://www.elastic.co/downloads/logstash编程
b、解压:tar -xzvf logstash-5.1.1.tar.gzbootstrap
c、设置用户测试的配置文件:vim logstatsh_test.conf,编辑内容以下:vim
input { stdin { } } output { stdout { codec => rubydebug {} } }
d、运行logstash测试:bin/logstash -f logstatsh_test.conf,运行成功界面以下:浏览器
e、logstash和elasticsearch整合:能够直接命令行启动以下ruby
bin/logstash -e 'input{stdin{}}output{elasticsearch {hosts => "localhost:9200" index => "logstash_test"} stdout{codec=>rubydebug}}'
或者对logstatsh_test.conf进行修改以下服务器
input{ stdin{ } } output{ elasticsearch { hosts => "localhost:9200" index => "logstash_test" } stdout{ codec=>rubydebug } }
f、状态查看:elasticsearch
a、官方下载地址:https://www.elastic.co/downloads/elasticsearch测试
b、解压:tar -xzvf elasticsearch-5.1.1.tar.gzurl
c、配置文件:vim config/elasticsearch.ymlspa
path.data: /data/es #数据路径 path.logs: /data/logs/es #日志路径 network.host: 本机地址 #服务器地址 http.port: 9200 #端口
d、启动程序:/bin/elasticsearch
e、访问:http://localhost:9200/ 查看elasticsearch是否成功运行。
f、访问:http://localhost:9200/logstash_test/_search,查看logstash_test这个index下的日志信息。
a、官方下载地址:https://www.elastic.co/downloads/kibana
b、解压:tar -xzvf kibana-5.1.1.tar.gz
c、设置配置文件:打开config/kibana.yml,修改以下内容
//启动端口 由于端口受限 因此变动了默认端口 server.port: 8601 //启动服务的ip server.host: "本机ip" //elasticsearch地址 elasticsearch.url: "http://localhost:9200”
d、启动程序:bin/kibana
e、访问:http://localhost:8610/查看kibana是否成功运行,并检索查看已存入的信息。
a、elasticsearch和kibana版本要对应,不然服务起不来。
b、若是浏览器中访问http://localhost:9200/没有返回预期的结果,就须要修改Elasticsearch的配置,使其支持外网访问。首先,按Ctrl +C中止Elasticsearch,而后,打开Elasticsearch的配置文件vimconfig/elasticsearch.yml,找到network.host这一行。
c、max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
解决:切换到root用户修改配置sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
d、max number of threads [1024] for user [lish] likely too low, increase to at least [2048]
解决:切换到root用户,进入limits.d目录下修改配置文件。
vi /etc/security/limits.d/90-nproc.conf
修改以下内容:
soft nproc 1024
修改成
soft proc 2048
e、 ERROR: bootstrap checks failed max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536] max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]
解决:切换到root用户,编辑limits.conf 添加相似以下内容
vi /etc/security/limits.conf
添加以下内容:
soft nofile 65536
hard nofile 131072
soft nproc 2048
hard proc 4096
f、useradd: cannot open /etc/group;useradd: cannot open /etc/gshadow;useradd: cannot open /etc/passwd;useradd: cannot open /etc/shadow
一、lsattr /etc/group
—-i——–e- /etc/group
二、chattr -i /etc/group 依次去掉group、gshadow、passwd、shadow
三、建立elsearch用户组及elsearch用户
groupadd elasticsearch
四、更改elasticsearch文件夹及内部文件的所属用户及组为elasticsearch: elasticsearch
useradd elasticsearch -g elsearch -p elasticsearch
cd /elasticsearch-5.1.1
chown -R elasticsearch: elasticsearch elasticsearch-5.1.1
五、切换到elasticsearch用户再启动
su elasticsearch
cd elasticsearch
./bin/elasticsearch
g、logstash启动报错
[2016-12-28T17:49:08,367][WARN ][logstash.outputs.elasticsearch] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>#<URI::HTTP:0x1deb02b URL:http://10.129.28.149:9200>, :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError, :error=>"Got response code '401' contact Elasticsearch at URL 'http://10.129.28.149:9200/'"}
若是从新设置了密码,可是没有配置密码,就须要像下面同样配置一下。
配置logstash.conf output { elasticsearch { ... user => logstash_internal password => changeme }