ELK日志系统

ELK日志系统
是一套完整的日志集中处理方案。
E:ElasticSearck ES 分布式索引型非关系数据库,存储logsstash输出的日志 全文检索引擎,保存的格式是json格式
L:logstash 基于java语言开发的,数据收集引擎。日志的收集,可以对数据进行过滤,分析,汇总,以标准格式输出。
K:Kiabana 是es的可视化工具。对es存储是数据进行可视化展示,分析和检索

ELK F K
F:filebeat 轻量级的开源日志文件数据搜集器。logstash占用系统资源比较大,属于重量级
有了filebeat可以节省资源,可以通过filebeat和logstash实现远程数据收集。
filebeat不能对数据进行便准输出,不能输出为es格式的数据,所以需要logstash把filebeat数据做标准化处理

K:kafka 消息队列

192.168.233.10 es1
192.168.233.20 es2
192.168.233.30 losgtash libana nginx/http

#关闭防火墙
systemctl stop firewalld
setenforce 0
#实现时间同步
yum -y install ntpdate
ntpdate ntp.aliyun.com
date

es1 es2

#安装java
yum -y install java
cd /opt
rz -E
elasticsearch-6.7.2.rpm
rpm -ivh elasticsearch-6.7.2.rpm
vim /etc/elasticsearch/elasticsearch.yml

es1

---17---
cluster.name: elk-cluster
---23---
node.name: node1
node.master: true
#是否保存数据
node.data: true
---55---
network.host: 0.0.0.0
---59---
http.port: 9200
#es集群内部通信的端口
transport.tcp.port: 9300
#内部发现彼此的地址
discovery.zen.ping.unicast.hosts: ["192.168.233.10:9300","192.168.233.20:9300"]

grep -v "^#" /etc/elasticsearch/elasticsearch.yml
systemctl restart elasticsearch.service
systemctl enable elasticsearch.service
netstat -anpt | grep 9200

#如果端口没启,查看日志文件
tail -f /var/log/elasticsearch//elk-cluster.log

rz -E
node-v8.2.1.tar.gz
phantomjs-2.1.1-linux-x86 64.tar.bz2
elasticsearch-head-master.zip

yum -y install gcc gcc-c++ make
tar -xf node-v8.2.1.tar.gz
ls
cd node-v8.2.1/
./configure
make -j 2 && make install

cd /opt
tar -xf phantomjs-2.1.1-linux-x86_64.tar.bz2
cd /opt/phantomjs-2.1.1-linux-x86_64/bin
cp phantomjs /usr/local/bin

cd /opt
unzip elasticsearch-head-master.zip
cd elasticsearch-head-master
#安装依赖包
npm config set registry http://registry.npm.taobao.org/  
npm install

vim /etc/elasticsearch/elasticsearch.yml
#再最后添加
#开启跨域访问
http.cors.enabled: true
#允许跨域访问的域名地址为所有地址
http.cors.allow-origin: "*"

systemctl restart elasticsearch.service
netstat -anpt | grep 9200
cd /opt/elasticsearch-head-master
npm run start &

es2

---17---
cluster.name: elk-cluster
---23---
node.name: node2
node.master: false
#是否保存数据
node.data: true
---55---
network.host: 0.0.0.0
---59---
http.port: 9200
#es集群内部通信的端口
transport.tcp.port: 9300
#内部发现彼此的地址
dicovery.zen.ping.unicast.hosts: ["192.168.233.10:9300","192.168.233.20:9300"]

grep -v "^#" /etc/elasticsearch/etc/elasticsearch.yml
systemctl restart elasticsearch.service
netstat -anpt | grep 9200

#如果端口没启,查看日志文件
tail -f /var/log/elastiscsearch/elk-cluster.log

rz -E
node-v8.2.1.tar.gz
phantomjs-2.1.1-linux-x86 64.tar.bz2
elasticsearch-head-master.zip

yum -y install gcc gcc-c++ make
tar -xf node-v8.2.1.tar.gz
ls
cd node-v8.2.1/
./configure
make -j 2 && make install

cd /opt
tar -xf phantomjs-2.1.1-linux-x86_64.tar.bz2
cd /opt/phantomjs-2.1.1-linux-x86_64
cp phantomjs /usr/local/bin

cd /opt
unzip elasticsearch-head-master.zip
cd elasticsearch-head-master
#安装依赖包
npm install
npm config set registry http://://registry.npm.taobao.org/
npm install

vim /etc/elasticsearch/elasticsearch.yml
#再最后添加
#开启跨域访问
http.cors.enabled: true
#允许跨域访问的域名地址为所有地址
http.cors.allow-origin: "*"

systemctl restart elasticsearch.service
netstat -anpt | grep 9200
cd /opt/elasticsearch-head-master
npm run start &

node:基于谷歌浏览器的运行环境

phantomjs:虚拟浏览器

es-head-master:es的独立可视化工具,可以实现分片索引的

192.168.233.30 losgtash libana nginx/http

yum -y install httpd
systemctl restart httpd
yum -y install java
java -version
rz -E
logstash-6.7.2.rpm
rpm -ivh logstash-6.7.2.rpm
systemctl restart logstash.service
systemctl enable logstash.service
ln -s /usr/share/logstash/bin/logstash /usr/local/bin/


cd /etc/logstash
vim logstash.yml
#数据文件
path.data: /var/lib/logstash
----64---
#默认的工作目录
/etc/logstash/conf.d

cd /etc/logstash/conf.d
logstash -e 'input { stdin{} } output { stdout{ codec=>rubydebug } }'
www.baidu.com

logstash -e 'input { stdin{} } output { elasticsearch { hosts=>["192.168.233.10:9200","192.168.233.20:9200"] } }' --path.data /opt/test1

1.es的主从和数据模式

node.master: false
es数据库的主从类型 true false
node.data: true
数据节点,是否保存数据,logstash发送数据,节点是否接受以及保存

es如何创建,修改,删除数据 数据管理
通过http的方式
post方式修改数据
创建数据
curl -X PUT ‘localhost:9200/index-demo/test/1?pretty&pretty’ -H ‘content-Type: application/json’ -d ‘{“user”:“zhangsan”,“mesg”:“hello world”}’
对应的就是本地数据库的地址 ip+端口
index-demo
创建索引分片的名称
test
数据的名称
1
数据的id字段
?pretty&pretty
参数设定为json格式
-d
数据的具体内容
“user”:“zhangsan”,“mesg”:“hello world”

修改数据:
curl -X POST ‘localhost:9200/index-demo/test/1/_update?pretty’ -H ‘Content-Type: application/json’ -d ‘{ “doc”: { “user”: “zhangsan”, “mesg”: “hello1 world1” } }’

删除
curl -X DELETE ‘localhost:9200/index-demo/test/1?pretty&pretty’ -H ‘content-Type: application/json’ -d ‘{“user”:“zhangsan”,“mesg”:“hello1 world1”}’

test3

cd /etc/logstash/conf.d
vim system.conf
input {
	file{
		path =>"/var/log/messages"
		type =>"system"
		start_position =>"beginning"
		#从日志的结尾开始收集信息是end
	}
}

output {
		elasticsearch {
			hosts =>["192.168.233.10:9200","192.168.233.20:9200"]
			index =>"system-%{+YYYY.MM.dd}"	
	}
}

logstash -f system.conf --path.data /opt/test7 &

配置kibana的

rz -E
kibana-6.7.2-x86 64.rpm
rpm -ivh kibana-6.7.2-x86_64.rpm
vim /etc/kibana/kibana.yml
---2
#取消注释
server.port: 5601
----7
server.host: 0.0.0.0
----28
elasticsearch.host: ["http://192.168.233.10:9200","http://192.168.233.20:9200"]
----96
#日志路径
logging.dest: /var/log/kibana.log
---113
#把语言模式改为中文
il8n.locale: "zh-CN"
----37
kibina.index: ".kibana"

touch /var/log/kibana.log
chown kibana:kibana /var/log/kibana.log
chmod 777 /var/log/kibana.log
systemctl restart kibana.service
systemctl enable kibana.service
systemctl status kibana.service
netstat -anpt | grep 5601
systemctl restart httpd
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值