Elasticsearch:负责日志检索和分析,它的特点有:分布式,零配置,自动发现,索引自动分片,索引副本机制,restful风格接口,多数据源,自动搜索负载等

Logstash:对日志进行收集、过滤,并将其存储供以后使用(如,搜索日志)

Kibana:为日志分析提供友好的Web界面,可以帮助汇总、分析和搜索重要数据日志

客户端软件:

在需要收集日志的所有服务上部署logstash,作为logstash agent(logstash shipper)用于监控并过滤收集日志,将过滤后的内容发送到logstash indexer,logstash indexer将日志收集在一起交给全文搜索服务ElasticSearch,可以用ElasticSearch进行自定义搜索,然后通过Kibana来结合自定义搜索进行页面展示。

借用网络上别人家的图

下载地址

cd /home
mkdir elk
cd elk
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.zip
unzip elasticsearch-6.2.4.zip
mv elasticsearch-6.2.4 elasticsearch

特别注意:elasticsearch5.0以上版本不支持root用户启动,现在增加一个用户

在增加用户之前,需要下载log4j  我安装的过程报了下面的错误 所以安装log4j

yum install -y unzip zip

yum install -y log4j*    ###安装log4j包
OpenJDK -Bit Server VM warning: Cannot open file logs/gc.log due to Permission denied
-- ::, main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException:
No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender java.lang.IllegalStateException:
-- ::, main ERROR RollingFileManager (/home/elk/elasticsearch/logs/elasticsearch_deprecation.log) java.io.FileNotFoundException:/home/elk/elasticsearch/logs/elasticsearch_deprecation.log (Permission denied) java.io.FileNotFoundException:

#groupadd esuser

#useradd -g esuser esuser

将data和logs目录的属主和属组改为esuser

#chown esuser.esuser /home/elk/elasticsearch -R  把目录/elasticsearch及其下的所有文件和子目录的属主改成esuser,属组改成esuser 第二个是属于哪个组。

标红的地方也要注意,要给绝对路径的用户

[root@insure elk]# sudo chown -R esuser.root /home/elk/elasticsearch
[root@insure elk]# ls -ltr
total
drwxr-xr-x esuser root Apr elasticsearch
-rw-r--r-- root root May logstash-6.2..zip
-rw-r--r-- root root Oct : kibana-6.2.-linux-x86_64.tar.gz
drwxr-xr-x root root Dec : back
[root@insure elk]# sudo chown -R esuser.esuser /home/elk/elasticsearch
[root@insure elk]# ls -ltr
total
drwxr-xr-x esuser esuser Apr elasticsearch

启动elasticsearch  &或者-d 可以后台启动

[esuser@insure elasticsearch]$ ./bin/elasticsearch
[--27T10::,][INFO ][o.e.n.Node ] [] initializing ...
[--27T10::,][INFO ][o.e.e.NodeEnvironment ] [LGHRC-d] using [] data paths, mounts [[/ (rootfs)]], net usable_space [.6gb], net total_space [492gb], types [rootfs]
[--27T10::,][INFO ][o.e.e.NodeEnvironment ] [LGHRC-d] heap size [.8mb], compressed ordinary object pointers [true]
[--27T10::,][INFO ][o.e.n.Node ] node name [LGHRC-d] derived from node ID [LGHRC-dHRqCXmCwcXI6XSg]; set [node.name] to override
[--27T10::,][INFO ][o.e.n.Node ] version[6.2.], pid[], build[ccec39f/--12T20::.497551Z], OS[Linux/3.10.-693.2..el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK -Bit Server VM/1.8.0_181/25.181-b13]
[--27T10::,][INFO ][o.e.n.Node ] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch.O9wXX03d, -XX:+HeapDumpOnOutOfMemoryError, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=, -XX:GCLogFileSize=64m, -Des.path.home=/home/elk/elasticsearch, -Des.path.conf=/home/elk/elasticsearch/config]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [aggs-matrix-stats]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [analysis-common]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [ingest-common]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [lang-expression]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [lang-mustache]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [lang-painless]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [mapper-extras]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [parent-join]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [percolator]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [rank-eval]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [reindex]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [repository-url]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [transport-netty4]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] loaded module [tribe]
[--27T10::,][INFO ][o.e.p.PluginsService ] [LGHRC-d] no plugins loaded
[--27T10::,][INFO ][o.e.d.DiscoveryModule ] [LGHRC-d] using discovery type [zen]
[--27T10::,][INFO ][o.e.n.Node ] initialized
[--27T10::,][INFO ][o.e.n.Node ] [LGHRC-d] starting ...
[--27T10::,][INFO ][o.e.t.TransportService ] [LGHRC-d] publish_address {127.0.0.1:}, bound_addresses {127.0.0.1:}
[--27T10::,][INFO ][o.e.c.s.MasterService ] [LGHRC-d] zen-disco-elected-as-master ([] nodes joined), reason: new_master {LGHRC-d}{LGHRC-dHRqCXmCwcXI6XSg}{0rZYMLjHT9Wib9xZBG18Fg}{127.0.0.1}{127.0.0.1:}
[--27T10::,][INFO ][o.e.c.s.ClusterApplierService] [LGHRC-d] new_master {LGHRC-d}{LGHRC-dHRqCXmCwcXI6XSg}{0rZYMLjHT9Wib9xZBG18Fg}{127.0.0.1}{127.0.0.1:}, reason: apply cluster state (from master [master {LGHRC-d}{LGHRC-dHRqCXmCwcXI6XSg}{0rZYMLjHT9Wib9xZBG18Fg}{127.0.0.1}{127.0.0.1:} committed version [] source [zen-disco-elected-as-master ([] nodes joined)]])
[--27T10::,][INFO ][o.e.h.n.Netty4HttpServerTransport] [LGHRC-d] publish_address {127.0.0.1:}, bound_addresses {127.0.0.1:}
[--27T10::,][INFO ][o.e.n.Node ] [LGHRC-d] started
[--27T10::,][INFO ][o.e.g.GatewayService ] [LGHRC-d] recovered [] indices into cluster_state

验证

[root@insure elasticsearch]# curl 127.0.0.1:9200
{
"name" : "LGHRC-d",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "NuqE84ouT463APhJLg21uA",
"version" : {
"number" : "6.2.4",
"build_hash" : "ccec39f",
"build_date" : "2018-04-12T20:37:28.497551Z",
"build_snapshot" : false,
"lucene_version" : "7.2.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

如果要在外网的浏览器访问

修改config/elasticsearch.yml

#network.host: 192.168.0.1 改为network.host: 47.96.14.108   这个是物理的IP

如果是阿里云服务器,一般外网访问都会做IP映射,那么这个IP就要改成可以全部访问的地址

可以改为 network.host: 0.0.0.0 

[esuser@insure bin]$ jps
Jps
Elasticsearch
[esuser@insure bin]$ kill - 1595
[esuser@insure bin]$ ./elasticsearch &

浏览器访问

到此elasticsearch 搜索引擎搭建成功

可能会遇到的问题

[]: max virtual memory areas vm.max_map_count [] is too low, increase to at least []

解决办法

在/etc/sysctl.conf文件最后添加一行

vm.max_map_count=262144

执行命令 sysctl -p

下一节我们搭建kibana

centos7搭建elasticsearch的更多相关文章

  1. CentOS7搭建elasticsearch集群

    准备三个节点,系统版本为CentOS7.3. 11.0.10.18 es01 11.0.10.19 es02 11.0.10.20 es03 1.安装java环境 # yum install -y j ...

  2. centos7搭建ELK Cluster集群日志分析平台(一):Elasticsearch

    应用场景: ELK实际上是三个工具的集合,ElasticSearch + Logstash + Kibana,这三个工具组合形成了一套实用.易用的监控架构, 很多公司利用它来搭建可视化的海量日志分析平 ...

  3. centos7搭建ELK Cluster集群日志分析平台(三):Kibana

    续  centos7搭建ELK Cluster集群日志分析平台(一) 续  centos7搭建ELK Cluster集群日志分析平台(二) 已经安装好elasticsearch 5.4集群和logst ...

  4. centos7搭建ELK Cluster集群日志分析平台(二):Logstash

    续  centos7搭建ELK Cluster集群日志分析平台(一) 已经安装完Elasticsearch 5.4 集群. 安装Logstash步骤 . 安装Java 8 官方说明:需要安装Java ...

  5. centos7搭建ELK Cluster集群日志分析平台

    应用场景:ELK实际上是三个工具的集合,ElasticSearch + Logstash + Kibana,这三个工具组合形成了一套实用.易用的监控架构, 很多公司利用它来搭建可视化的海量日志分析平台 ...

  6. Elasticsearch使用系列-Docker搭建Elasticsearch集群

    Elasticsearch使用系列-ES简介和环境搭建 Elasticsearch使用系列-ES增删查改基本操作+ik分词 Elasticsearch使用系列-基本查询和聚合查询+sql插件 Elas ...

  7. centos7 搭建GlusterFS

    centos7 搭建GlusterFS 转载http://zhaijunming5.blog.51cto.com/10668883/1704535 实验需求:4台机器安装GlusterFS组成一个集群 ...

  8. ELK初学搭建(elasticsearch)

    ELK初学搭建(elasticsearch) elasticsearch logstash kibana ELK初学搭建 elasticsearch 1.环境准备 centos6.8_64 mini ...

  9. Centos7搭建FTP服务器

    从网上搜索了好多搭建Centos7搭建服务器的教程都没有成功唯独这个,利用Windows资源管理器连接测试成功. 一.通过yum安装vsftpd yum install -y vsftpd 二.修改v ...

随机推荐

  1. JavaScript函数箭头的优势在哪里

    译者按: 看上去只是语法的变动,其实也影响了this的作用域. 原文: JavaScript: Arrow Functions for Beginners 译者: Fundebug 为了保证可读性,本 ...

  2. canvas-2drawRectFun.html

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. js之全选即点击全选标签可选择全部复选框

    目标效果:网页全选功能,即点击全选标签可选择全部复选框 实现代码如下 <!DOCTYPE html> <html lang="en"> <head&g ...

  4. mysql插入表数据中文乱码问题解决方案

    一.问题 开发中遇到将其它数据库数据插入到mysql数据库表中一直会报类似如下错误: Incorrect string value: '\xE6\x88\x91' for column 'name' ...

  5. 使用node.js进行API自动化回归测试

    概述 传统的QA自动化测试通常是基于GUI的,比如使用Selenium,模拟用户在界面上操作.但GUI测试的开发.维护成本和运行的稳定性一直是测试界的老大难问题.投入大量的人力物力开发.维护.运行,却 ...

  6. 《Attention is All You Need》浅读(简介+代码)

    2017年中,有两篇类似同时也是笔者非常欣赏的论文,分别是FaceBook的<Convolutional Sequence to Sequence Learning>和Google的< ...

  7. (后端)java回调机制

    转自强哥: 所谓回调,就是客户程序C调用服务程序S中的某个函数A,然后S又在某个时候反过来调用C中的某个函数B,对于C来说,这个B便叫做回调函数.例如Win32下的窗口过程函数就是一个典型的回调函数. ...

  8. linux 开机自启动脚本

    在/etc/rc.local文件中添加自启动命令(其中一种方法) 1.案例,就用博主本人之前发的博文 “nginx + flask + uwsgi + centos + python3 搭建web项目 ...

  9. 简述 Spring Cloud 是什么1

    很多同学都了解了Spring ,了解了 Spring Boot, 但对于 Spring Cloud 是什么还是比较懵逼的. 本文带你简单的了解下,什么是Spring Cloud. Spring Clo ...

  10. [20170927]hugepages与内核参数nr_overcommit_hugepages.txt

    [20170927]hugepages与内核参数nr_overcommit_hugepages.txt /proc/sys/vm/nr_overcommit_hugepages specifies h ...