一、准备安装包
1、环境概况
系统:CentOS 7
es主节点/es数据节点/kibana/head 192.168.3.11
es主节点/es数据节点/filebeat 192.168.3.12
es主节点/es数据节点/logstash 192.168.3.13
2、下载资源包
mkdir -p /root/soft/elk && cd /root/soft/elk
wget -c https://mirrors.huaweicloud.com/nodejs/latest-v12.x/node-v12.14.1-linux-x64.tar.gz
wget -c https://github.com/mobz/elasticsearch-head/archive/master.zip
wget -c https://mirrors.huaweicloud.com/elasticsearch/7.7.0/elasticsearch-7.7.0-linux-x86_64.tar.gz
wget -c https://mirrors.huaweicloud.com/kibana/7.7.0/kibana-7.7.0-linux-x86_64.tar.gz
wget -c https://mirrors.huaweicloud.com/logstash/7.7.0/logstash-7.7.0.tar.gz
wget -c https://mirrors.huaweicloud.com/filebeat/7.7.0/filebeat-7.7.0-linux-x86_64.tar.gz
官网下载:https://www.elastic.co/cn/downloads/past-releases
备用地址:
wget -c http://yunwei.qzbaitan.com/elk/node-v12.14.1-linux-x64.tar.gz
wget -c http://yunwei.qzbaitan.com/elk/master.zip
wget -c http://yunwei.qzbaitan.com/elk/elasticsearch-7.7.0-linux-x86_64.tar.gz
wget -c http://yunwei.qzbaitan.com/elk/kibana-7.7.0-linux-x86_64.tar.gz
wget -c http://yunwei.qzbaitan.com/elk/logstash-7.7.0.tar.gz
wget -c http://yunwei.qzbaitan.com/elk/filebeat-7.7.0-linux-x86_64.tar.gz
wget -c http://yunwei.qzbaitan.com/elk/jdk-11.0.7_linux-x64_bin.tar.gz
二、配置基础环境(全部安装)
1、关闭防火墙和seliunx
# systemctl stop firewalld && systemctl disable firewalld
# sed -i 's/=enforcing/=disabled/g' /etc/selinux/config && setenforce 0
2、设置打开文件数
vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
vim /etc/sysctl.conf
vm.max_map_count=655360 #单个vm进程最大线程数量为改值的一半左右
sysctl -p
3、环境配置
以下2个环境都是解压后配置一下path即可直接使用
下载安装jdk11并配置环境
ln -s /usr/local/jdk/bin/java /usr/local/bin/java
安装nodejs环境
ln -s /usr/local/node/bin/node /usr/bin/node
三、安装elasticsearch-head(192.168.3.11安装)
1、安装head
cd /root/soft/elk
unzip master.zip
mv elasticsearch-head-master /usr/local/elasticsearch-head
2、安装head插件
cd /usr/local/elasticsearch-head
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install -g grunt-cli
cnpm install -g grunt
cnpm install grunt-contrib-clean
cnpm install grunt-contrib-concat
cnpm install grunt-contrib-watch
cnpm install grunt-contrib-connect
cnpm install grunt-contrib-copy
cnpm install grunt-contrib-jasmine #若报错就再执行一遍
3、配置文件
vim /usr/local/elasticsearch-head/Gruntfile.js
#找到下面connect属性,新增 hostname: '0.0.0.0',
connect: {
server: {
options: {
hostname: '0.0.0.0', #不要忘了后面的逗号
port: 9100,
base: '.',
keepalive: true
}
}
}
4、启动测试
cd /usr/local/elasticsearch-head && nohup grunt server &
5、启动脚本
vim /etc/init.d/elasticsearch-head
#!/bin/bash
#chkconfig: 2345 55 24
#description: elasticsearch-head service manager
data="cd /usr/local/elasticsearch-head/ ; nohup /usr/local/node/bin/npm run start&"
START() {
source /etc/profile
eval ${data}
}
STOP() {
ps -ef | grep grunt | grep -v "grep" | awk '{print $2}' | xargs kill -s 9 >/dev/null
}
case "$1" in
start)
START
;;
stop)
STOP
;;
restart)