ELK安装

前言

基于elastic官方文档整理的安装过程,官方文档链接: Elastic Stack
安装过程中的问题解决方案也可以参考博文:ELK安装常见问题
ELK核心产品列表:

  • Elasticsearch
  • Kibana
  • Beats
  • Logstash

安装环境

  1. 操作系统:CentOS Linux release 7.6.1810 (Core)
  2. JDK: 1.8.0_191

安装过程

Elasticsearch安装

下载

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.tar.gz
tar -xzvf elasticsearch-6.5.4.tar.gz

环境变量设置

# $HOME为用户主目录路径
export ES_HOME=$HOME/elasticsearch-6.5.4
# 将Elasticsearch命令添加至PATH路径中
export PATH=$PATH:$ES_HOME/bin

Elasticsearch配置文件修改

vi $ES_HOME/config/elasticsearch.yml

需要修改elasticsearch.yml 文件中的network.host和http.port两个参数修改为本机IP地址和Elasticsearch访问端口,例如:

# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.1.1
#
# Set a custom port for HTTP:
#
http.port: 9200

CentOS防火墙权限修改(备选)

为了便于后期远程访问Elasticsearch,可以将Elasticsearch访问端口防火墙访问权限打开,使用root用户执行防火墙命令,如下:

#将9200端口开放端口访问权限
firewall-cmd --zone=public --add-port=9200/tcp --permanent
#重新加载防火墙配置
firewall-cmd --reload
#查看防火墙开放的端口
firewall-cmd --zone=public --list-ports

启动Elasticsearch

cd $ES_HOME/bin

elasticsearch

验证Elasticsearch

使用curl命令验证Elasticsearch运行情况,访问http://本地IP地址:访问端口,例如:

curl http://192.168.1.1:9200

Elasticsearch正常运行则返回相应信息,如下:

{
  "name" : "DIbQ2LW",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "tdqWbCTgTVGN0sRuKi8raQ",
  "version" : {
    "number" : "6.5.4",
    "build_flavor" : "default",
    "build_type" : "zip",
    "build_hash" : "d2ef93d",
    "build_date" : "2018-12-17T21:17:40.758843Z",
    "build_snapshot" : false,
    "lucene_version" : "7.5.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

Elasticsearch后台运行

elasticsearch -d -p pid

后台运行后停止Elasticsearch

  1. 在Elasticsearch日志中查找pid,如下:
grep pid $ES_HOME/logs/elasticsearch.log | less
  1. 使用kill命令杀死Elasticsearch进程

Elasticsearch安装报错解决方法

问题一
报错信息:

max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]

报错原因:

无法创建本地文件问题,用户最大可创建文件数太小

解决方案

切换到root用户,编辑limits.conf配置文件,

vi /etc/security/limits.conf

添加类似如下内容:

elk hard nofile 65536

elk soft stack 65536

备注
elk 代表CentOS下Elasticsearch安装用户

使用SSH远程登陆服务器时需要重新登陆

问题一
报错信息:

max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

报错原因:

最大虚拟内存太小

解决方案

切换到root用户下,修改配置文件**/etc/sysctl.conf**,命令如下:

vi /etc/sysctl.conf

添加下面配置:

vm.max_map_count=655360

执行命令,重新加载sysctl

sysctl -p

Kibana安装

下载

curl -L -O https://artifacts.elastic.co/downloads/kibana/kibana-6.5.4-linux-x86_64.tar.gz

tar xzvf kibana-6.5.4-linux-x86_64.tar.gz

环境变量设置

# $HOME为用户主目录路径
export KIBANA_HOME=$HOME/kibana-6.5.4-linux-x86_64
# 将Kibana命令添加至PATH路径中
export PATH=$PATH:$KIBANA_HOME/bin

Kibana 配置文件修改

vi $KIBANA_HOME/config/kibana.yml

需要修改kibana.yml 文件中的server.port和server.host两个参数修改为本机IP地址和Kibana访问端口,以及elasticsearch.url参数,用于访问Elasticsearch,例如:

# Kibana is served by a back end server. This setting specifies the port to use.
server.port: 5601

# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
server.host: "192.168.1.1"
# The URL of the Elasticsearch instance to use for all your queries.
elasticsearch.url: "http://192.168.1.1:9200"

CentOS防火墙权限修改(备选)

为了便于后期远程访问Kibana,可以将Kibana访问端口防火墙访问权限打开,使用root用户执行防火墙命令,如下:

#将5601端口开放端口访问权限
firewall-cmd --zone=public --add-port=5601/tcp --permanent
#重新加载防火墙配置
firewall-cmd --reload
#查看防火墙开放的端口
firewall-cmd --zone=public --list-ports

启动Kibana

cd $KIBANA_HOME/bin

kibana

验证Kibana

使用浏览器访问http://本机IP地址:访问端口号即可登陆Kibana

Kibana后台运行

可以使用nohup命令将Kibana后台运行

nohup kibana &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值