ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

ELK的安装配置及使用

2019-04-22 21:53:05  阅读:483  来源: 互联网

标签:ELK es5 http 9200 root 配置 192.168 curl 安装


ELK:

  • Elasticsearch:负责日志检索和存储
  • Logstash:负责日志的可视化
  • Kibana:负责日志的可视化
    ELK组件在海量日志系统的运维中,可用于解决:
    (1)分布式日志数据集中式查询和管理
    (2)系统监控,包含系统硬件和应用各个组件的监控
    (3)故障排查
    (4)安全信息和事件管理
    (5)报表功能
    Elasticsearch主要特点:
  • 实时分析
  • 分布式实时文件存储,并将每一个字段都编入索引
  • 文档导向,所有的对象全部是文档
  • 高可用性,易扩展,支持集群(Cluster)、分片和复制(Shards和Replicas)
  • 接口友好,支持JSON
    Elasticsearch是一种面向文档的数据库,与关系型数据库的对比
    DB(关系型)–>Databases(数据库)–>Tables(表)–>Rows(行)–>Columns(列)
    ES(ES)–>Indices(索引)–>Types(类型)–>Documents(文档)–>Fields(域或字段)
    ES集群安装
    1、准备5台虚拟机
    192.168.8.41 es1
    192.168.8.42 es2
    192.168.8.43 es3
    192.168.8.44 es4
    192.168.8.45 es5
    2、配置yum
[root@room9pc01 ~]# ls /var/ftp/elk/
filebeat-1.2.3-x86_64.rpm
elasticsearch-2.3.4.rpm
kibana-4.5.2-1.x86_64.rpm
logstash-2.3.4-1.noarch.rpm
elasticsearch-kopf-master.zip
elasticsearch-head-master.zip
bigdesk-master.zip 
[root@room9pc01 ~]#createrepo /var/ftp/elk/
[root@room9pc01 ~]#createrepo --update /var/ftp/elk/
[root@es1 ~]# vim /etc/yum.repos.d/dvd.repo
[elk]
name=elk
baseurl=ftp://192.168.8.254/elk/
enabled=1
gpgcheck=0
[rhel7]
name=rhel7
baseurl=ftp://192.168.8.254/rhel7/
enabled=1
gpgcheck=0

3、安装并配置Elasticsearch(以es1为例,其余es主机类似)

[root@es1 ~]#yum -y install java-1.8.0-openjdk
[root@es1 ~]#yum -y install elasticsearch
[root@es1 ~]# vim /etc/hosts
192.168.8.41 		es1
192.168.8.42 		es2
192.168.8.43 		es3
192.168.8.44 		es4
192.168.8.45 		es5
[root@es1 ~]# vim /etc/elasticsearch/elasticsearch.yml
17 cluster.name: nsd1812
23 node.name: es1
54 network.host: 0.0.0.0
68 discovery.zen.ping.unicast.hosts: ["es1", "es2", "es3"]
[root@es1 ~]# systemctl start elasticsearch
[root@es1 ~]# systemctl enable elasticsearch
[root@es1 ~]# netstat -ntulap |grep :9200		//查看服务是否启动
[root@es1 ~]# firefox http://192.168.8.41:9200		//访问9200端口查看是否安装成功
[root@es1 ~]# firefox http://192.168.8.44:9200/_cluster/health?pretty		//ES集群验证,显示5台节点
...
"cluster_name" : "nsd1812",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 5,
  "number_of_data_nodes" : 5,
...

4、curl命令的使用
系统命令curl:是一个利用URL规则在命令行下工作的文件传输工具,可以说是一款很强大的http命令行工具,它支持多种请求模式、自定义请求头等等强大功能,是一款综合工具
curl常用参数介绍:
-A 修改请求头
-X设置请求方法
-i显示返回头信息
例如:

[root@es1 ~]# curl -X GET http://192.168.8.42:9200/_cat		//索引的分片信息
[root@es1 ~]# curl -X GET http://192.168.8.42:9200/_cat/health?v		//显示health的详细信息
[root@es1 ~]# curl -X GET http://192.168.8.42:9200/_cat/nodes?help		//查看nodes的帮助

5、部署插件(插件部署在那一台机器上,只能在那台机器上使用,这里以安装在es5上为例)

[root@es5 ~]# cd /usr/share/elasticsearch/bin/
[root@es5 bin]#  ./plugin install ftp://192.168.8.254/elk/elasticsearch-head-master.zip
[root@es5 bin]#  ./plugin install ftp://192.168.8.254/elk/elasticsearch-kopf-master.zip
[root@es5 bin]# ./plugin install ftp://192.168.8.254/elk/bigdesk-master.zip
[root@es5 bin]# ./plugin list		//查看安装的插件
[root@room9pc01 ~]# firefox http://192.168.8.45:9200/_plugin/head/		//真机访问es5的head插件
[root@room9pc01 ~]# firefox http://192.168.8.45:9200/_plugin/kopf/		//真机访问es5的kopf插件
[root@room9pc01 ~]# firefox http://192.168.8.45:9200/_plugin/bigdesk/		//真机访问es5的bigdesk插件

6、使用curl实现ES数据库的增、删、改、查
增 PUT
curl -XPUT http://es3:9200/索引/类型/id -d ‘json数据’
改 POST
curl -XPOST http://es3:9200/索引/类型/id/_update -d ‘json数据’
查 GET
curl -XGET http://es3:9200/索引/类型/id?pretty
删除 DELETE
curl -XDELETE http://es3:9200/索引/类型/id?pretty
例如:

[root@es5 ~]# curl -XPUT http://es3:9200/tea -d '{"settings":{"index":{"number_of_shards":5,"number_of_replicas":1}}}'		//创建索引tedu
[root@es5 ~]# curl -XPUT http://es3:9200/tea/teacher/1 -d '{ "姓名": "张三","爱好": "篮球","阶段": "2阶段","年龄": "22" }'		//增加数据1
[root@es5 ~]# curl -XPUT http://es3:9200/tea/teacher/2 -d '{ "姓名": "李四","爱好": "足球","阶段": "3阶段","年龄": "25" }'		//增加数据2
[root@es5 ~]# curl -XPUT http://es3:9200/tea/teacher/3 -d '{ "姓名": "王五","爱好": "乒乓球","阶段": "2阶段","年龄": "23" }'		//增加数据3
[root@es5 ~]# curl -XPOST http://es3:9200/tea/teacher/3/_update -d '{"doc":{"年龄":""20"}}'		//修改王五的年龄为20
[root@es5 ~]# curl -XGET http://es3:9200/tea/teacher/3?pretty		//查询id为3的数据信息
[root@es5 ~]# curl -XDELETE http://es3:9200/tea/teacher/3?pretty		//删除id为3的数据信息
[root@es5 ~]# curl -XDELETE http://es3:9200/*	//删除所有索引

标签:ELK,es5,http,9200,root,配置,192.168,curl,安装
来源: https://blog.csdn.net/liuxe1990/article/details/89445608

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有