vim /etc/logstash/conf.d/logstash_indexer.conf
input {
redis {
host => "192.168.0.1"
data_type => "list"
key => "logstash:redis"
type => "redis-input"
port => "6379"
}
}
output {
elasticsearch {
host => "192.168.0.1"
}
}
4、启动服务
/etc/init.d/logstash start
5、使用jps -mlv或ps -ef来查看下进程
ps -ef|grep logst
6、设置开机启动
update-rc.d logstash defaults
update-rc.d: using dependency based boot sequencing
六、安装kibana(前端web)
1、下载
wget https://download.elastic.co/kibana/kibana/kibana-4.1.2-linux-x64.tar.gz
2、解压到指定目录
tar zxvf kibana-4.1.2-linux-x64.tar.gz -C /opt
3、创建日志目录
mkdir -p /opt/kibanalog
4、配置
1)备份配置
cp /opt/kibana-4.1.2-linux-x64/config/kibana.yml /opt/kibana-4.1.2-linux-x64/config/kibana.yml.bak
2)修改配置
sed -i 's!^elasticsearch_url: .*!elasticsearch_url: "http://192.168.0.1:9200"!g' /opt/kibana-4.1.2-linux-x64/config/kibana.yml
sed -i 's!^host: .*!host: "192.168.0.1"!g' /opt/kibana-4.1.2-linux-x64/config/kibana.yml
5、启动服务
cd /opt/kibanalog && nohup /opt/kibana-4.1.2-linux-x64/bin/kibana &
6、查看进程和端口
1)查看进程
ps aux |grep kibana
2)查看端口
netstat -tupnl|grep 5601
7、在Windows上访问
:5601
8、设置开机启动
echo "cd /opt/kibanalog && nohup /opt/kibana-4.1.2-linux-x64/bin/kibana &" >> /etc/rc.local
到此服务器A的相关软件全部安装完成;
现在安装日志采集端的程序(服务器B),可以有多个
clientB安装配置logstash(agent)
1、安装java环境
yum -y list java*
yum -y install openjdk-7-jdk
1、下载logstash
wget https://download.elastic.co/logstash/logstash/packages/centos/logstash-1.5.4-1.noarch.rpm
2、安装logstash
rpm -ivh logstash-1.5.4-1.noarch.rpm
3、配置(默认没有这个配置文件)
1)配置logstash_agent
vim /etc/logstash/conf.d/logstash_agent.conf
input {
file {
path => "/tmp/*.log"
start_position => beginning
}
}
output {
redis {
host => "192.168.0.1"
data_type => "list"
key => "logstash:redis"
}
}
5、启动服务
/etc/init.d/logstash start
logstash started.
6、使用jps -mlv或ps -ef来查看下进程
ps -ef|grep logst
7、设置开机启动
update-rc.d logstash defaults
update-rc.d: using dependency based boot sequencing
至此服务器B也安装配置完成,根据日志采集端的需要可以配置N个服务B
如何查看日志:
1、查看redis日志
cat /var/log/redis/redis-server.log
2、查看elasticsearch日志
cat /var/log/elasticsearch/elasticsearch.log
tail -300f /var/log/elasticsearch/elasticsearch.log
3、查看logstash日志
cat /var/log/logstash/logstash.errtail -30f /var/log/logstash/logstash.err
4、查看kibana日志
cat /opt/kibanalog/nohup.out
tail -30f /opt/kibanalog/nohup.out
错误处理
1)unable to fetch mapping, do you have indices matching the pattem?
kibana 报这个错误就是因为没有从logstash 过来任何数据一般检查一下数据传输