ELK 最新版本对JDK的最低要求是1.8,安装java_1.8版本

一.Elasticsearch

1.创建目录

2.下载安装包

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.3.tar.gz

3.解压安装包

tar -zxvf elasticsearch-6.2.3.tar.gz

4.新建用户

groupadd elk#创建组

useradd elk -g elk  #创建用户并将用户添加到组

#修改文件所有者

chown -R elk /usr/elk/elasticsearch/elasticsearch-6.2.3/

5.启动服务

切换用户至elk,启动服务

6.设置开机启动

vim /etc/init.d/elasticsearch

#!/bin/sh
# chkconfig: 2345 90 10
# description: elasticsearch service

su - elk<<!
cd  /usr/elk/elasticsearch/elasticsearch-6.2.3/
./bin/elasticsearch -d &
exit

!

保存

添加自启动权限

chmod a+x /etc/init.d/elasticsearch

使用

service elasticsearch status/start/stop
查看nexus服务状态、启动服务、停止服务等

使用
chkconfig elasticsearch on/off

设置nexus服务开机自启动或者开机不启动

设置开机启动的时候出现下面提示会

解决方案:

vim elasticsearch

在开始加上下面两行内容

# chkconfig: 2345 90 10
# description: elasticsearch service

然后重新设置

7.验证是否启动成功

如果有信息返回则说明启动成功

8.elasticsearch默认端口为9200,开启端口

添加

firewall-cmd --zone=public --add-port=9200/tcp --permanent    (--permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd --reload
查看
firewall-cmd --zone= public --query-port=9200/tcp
查看所有打开的端口
firewall-cmd --zone=public --list-ports

9.修改elasticsearch配置,通过浏览器可以访问

如果浏览器中访问http://localhost:9200/没有返回预期的结果,就需要修改Elasticsearch的配置,使其支持外网访问。

为了能够通过浏览器访问elasticsearch,我们需要配置elasticsearch的配置文件,主要是修改

network.host和http.port

vim config/elasticsearch.yml

#修改配置文件内容如下:
network.host: 0.0.0.0

注意:

:后面需要一个空格,格式不正确会报错误
然后保存,重新启动服务

重启服务,发现报错

ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

修改/etc/security/limits.conf配置文件:

1
2
3
4
5
6
7
[root@yqtrack-elk03 /]# vim /etc/security/limits.conf
 
添加如下配置项:
 
* - nproc 65535
* - nofile 409600
elastic - memlock unlimited

 修改/etc/security/limits.d/90-nproc.conf配置文件:

1
2
3
4
5
6
[root@yqtrack-elk03 /]# vim /etc/security/limits.d/90-nproc.conf
 
修改如下配置项目:
 
* soft nproc unlimited
root soft nproc unlimited  

 修改完成后,重新登录elk账户,查看设置是否生效。

1
2
3
4
[elk@yqtrack-elk03 /]$ ulimit -n
409600
[elk@yqtrack-elk03 /]$ ulimit -u
65535

以root账户更改/etc/sysctl.conf文件,添加如下内容

vm.max_map_count=655360

以root账户执行下面命令

[***@elk01 ~]$ sudo sysctl -p
vm.max_map_count = 655360

二.Logstash

1.创建目录

2.下载安装包

wget -c https://artifacts.elastic.co/downloads/logstash/logstash-6.2.3.tar.gz

3.解压安装包

tar -xzvf logstash-6.2.3.tar.gz

4.创建配置文件

vim logstash.conf
在配置文件logstash.conf添加如下内容:

input {
log4j {
host => "192.168.0.200"
port => 4560
}
}

#过滤器
filter{

#删除无用字段
mutate {
remove_field => "file"
remove_field => "method"
remove_field => "@version"
remove_field => "thread"
remove_field => "class"
remove_field => "timestamp"
remove_field => "@timestamp"
}

#自定义字段
json
{
source=>"message"
}

}

output {
stdout
{
codec => rubydebug
}
elasticsearch{
hosts => ["127.0.0.1:9200"]
index => "app_%{appId}"
document_type => "appLog"
}
}

5.启动

#修改文件所有者

chown -R elk /usr/elk/logstash/logstash-6.2.3

./bin/logstash ./config/logstash.conf

启动的时候如果出现下面错误,则说明缺少LOG4J插件,需要进行安装

可以通过命令查看已安装插件

安装插件

./logstash-plugin install logstash-input-log4j


6.设置开机启动

vim /etc/init.d/logstash

#!/bin/bash

# chkconfig: 2345 50 50
# description: logstash
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH

if [ `id -u` -ne 0 ]; then
echo "You need root privileges to run this script"
exit 1
fi

name=logstash
pidfile="/var/run/$name.pid"

LS_USER=elk
LS_GROUP=elk
LS_HOME=/opt/soft/elk/logstash/logstash-6.2.3
LS_HEAP_SIZE="500m"
LS_LOG_DIR="${LS_HOME}/logs"
LS_LOG_FILE="${LS_LOG_DIR}/$name.log"
LS_CONF_DIR=$LS_HOME/config/logstash.conf
LS_OPEN_FILES=16384
LS_NICE=19
LS_OPTS=""

[ -r /etc/default/$name ] && . /etc/default/$name
[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name

program=${LS_HOME}/bin/logstash
args=" -f ${LS_CONF_DIR}"
start() {
LS_JAVA_OPTS="${LS_JAVA_OPTS} -Djava.io.tmpdir=${LS_HOME}"
HOME=${LS_HOME}
export PATH HOME LS_HEAP_SIZE LS_JAVA_OPTS LS_USE_GC_LOGGING

# chown doesn't grab the suplimental groups when setting the user:group - so we have to do it for it.
# Boy, I hope we're root here.
SGROUPS=$(id -Gn "$LS_USER" | tr " " "," | sed 's/,$//'; echo '')

if [ ! -z $SGROUPS ]
then
EXTRA_GROUPS="--groups $SGROUPS"
fi

# set ulimit as (root, presumably) first, before we drop privileges
ulimit -n ${LS_OPEN_FILES}

# Run the program!
nice -n ${LS_NICE} chroot --userspec $LS_USER:$LS_GROUP $EXTRA_GROUPS / sh -c "
cd $LS_HOME
ulimit -n ${LS_OPEN_FILES}
exec \"$program\" $args
" > "${LS_LOG_DIR}/$name.stdout" 2> "${LS_LOG_DIR}/$name.err" &

# Generate the pidfile from here. If we instead made the forked process
# generate it there will be a race condition between the pidfile writing
# and a process possibly asking for status.
echo $! > $pidfile
echo "$name started."
return 0
}

stop() {
# Try a few times to kill TERM the program
if status ; then
pid=`cat "$pidfile"`
echo "Killing $name (pid $pid) with SIGTERM"
kill -TERM $pid
# Wait for it to exit.
for i in 1 2 3 4 5 ; do
echo "Waiting $name (pid $pid) to die..."
status || break
sleep 1
done
if status ; then
if [ "$KILL_ON_STOP_TIMEOUT" -eq 1 ] ; then
echo "Timeout reached. Killing $name (pid $pid) with SIGKILL. This may result in data loss."
kill -KILL $pid
echo "$name killed with SIGKILL."
else
echo "$name stop failed; still running."
fi
else
echo "$name stopped."
fi
fi
}

status() {
if [ -f "$pidfile" ] ; then
pid=`cat "$pidfile"`
if kill -0 $pid > /dev/null 2> /dev/null ; then
# process by this pid is running.
# It may not be our pid, but that's what you get with just pidfiles.
# TODO(sissel): Check if this process seems to be the same as the one we
# expect. It'd be nice to use flock here, but flock uses fork, not exec,
# so it makes it quite awkward to use in this case.
return 0
else
return 2 # program is dead but pid file exists
fi
else
return 3 # program is not running
fi
}

force_stop() {
if status ; then
stop
status && kill -KILL `cat "$pidfile"`
fi
}

case "$1" in
start)
status
code=$?
if [ $code -eq 0 ]; then
echo "$name is already running"
else
start
code=$?
fi
exit $code
;;
stop) stop ;;
force-stop) force_stop ;;
status)
status
code=$?
if [ $code -eq 0 ] ; then
echo "$name is running"
else
echo "$name is not running"
fi
exit $code
;;
restart)

stop && start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|force-stop|status|restart}" >&2
exit 3
;;
esac

exit $?

保存

添加自启动权限

chmod a+x /etc/init.d/logstash

使用

service logstash status/start/stop
查看nexus服务状态、启动服务、停止服务等

使用
chkconfig logstash on/off

三.Kibana

1.创建目录

2.下载安装包

wget -c https://artifacts.elastic.co/downloads/kibana/kibana-6.2.3-linux-x86_64.tar.gz

3.解压安装包

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

4.启动服务

5.开启端口

添加

firewall-cmd --zone=public --add-port=5601/tcp --permanent    (--permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd --reload
查看
firewall-cmd --zone= public --query-port=5601/tcp
查看所有打开的端口
firewall-cmd --zone=public --list-ports
6.设置外网可访问
修改config/kibaba.yml下的server.host为0.0.0.0

7.设置开机启动

vim /etc/init.d/kibana

#!/bin/bash

# chkconfig: 2345 98 02
# description: kibana

KIBANA_HOME=/usr/elk/kibana/kibana-6.2.3-linux-x86_64

case $1 in
start) $KIBANA_HOME/bin/kibana &;;
*) echo "require start";;
esac

保存

添加自启动权限

chmod a+x /etc/init.d/kibana

使用

service kibana status/start/stop
查看nexus服务状态、启动服务、停止服务等

使用
chkconfig kibana on/off

8.验证安装结果

 

从零开始搭建系统2.2——ELK安装及配置的更多相关文章

  1. 从零开始搭建系统2.8——HDFS安装及配置

    从零开始搭建系统2.8——HDFS安装及配置

  2. 从零开始搭建系统2.4——Jenkins安装及配置

    1.安装wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.reporpm --impo ...

  3. 从零开始搭建系统1.7——FTP安装及配置

    1.安装vsftp软件包 [root@localhost usr]# yum install -y vsftpd 2.先备份vsftpd的默认配置文件 [root@localhost usr]# cd ...

  4. 从零开始搭建系统1.3——Tomcat安装及配置

    首先安装jdk,手动解压JDK的压缩包,然后设置环境变量 1.卸载自带openjdk 查询OpenJDK rpm -qa|grep java 批量卸载所有名字包含jdk的已安装程序.命令行: rpm  ...

  5. 从零开始搭建系统1.2——Nginx安装及配置

    一.安装准备 首先由于nginx的一些模块依赖一些lib库,所以在安装nginx之前,必须先安装这些lib库,这些依赖库主要有g++.gcc.openssl-devel.pcre-devel和zlib ...

  6. 从零开始搭建系统2.5——Apollo安装及配置

    参见https://github.com/ctripcorp/apollo/wiki/Quick-Start安装即可

  7. 从零开始搭建系统2.1——Nexus安装及配置

    在安装配置Nexus时,请先确定您已经配置好jdk 1.创建目录 2.下载安装包 [root@localhost usr]# cd nexus 下载地址:https://www.sonatype.co ...

  8. 从零开始搭建系统1.4——MySql安装及配置

    安装环境:CentOS7 64位 ,安装MySQL5.7 1.创建mysql目录 2.在MySQL官网中下载YUM源rpm安装包:http://dev.mysql.com/downloads/repo ...

  9. 从零开始搭建系统1.5——Redis安装及配置

    1.在/usr/目录下创建redis目录 [root@localhost usr]# mkdir redis 2.下载安装包 wget http://download.redis.io/release ...

随机推荐

  1. python基础【第四篇】

    python第二节 1.while循环 Python 编程中 while 语句用于循环执行程序,即在某条件下,循环执行某段程序,以处理需要重复处理的相同任务.基本形式为: while 条件: 循环体 ...

  2. 开启linux下面vsftp自身的服务

    最近业务需求搞了一下sftp,配合samba感觉还是不错的. 上干货:笔者的环境是centos7.4 1.建立一个名为sftpusers的sftp用户组 groupadd sftpusers 2.建立 ...

  3. linux文本处理工具篇

    一.常用简单工具 cat [OPTION]... [FILE]...  -E:显示行的结束符$ -n:对显示出的每一行进行编号. -A:显示所有控制符 -s:压缩连续空行为一行 more:分页查看文件 ...

  4. 关于prototype与constructor的几点理解

    首先要明确一点,js中的prototype是每个函数创建时(并非执行时,而是函数存在于堆区后)自动创建一个默认对象,这一对象中可以动态的添加属性 在new对象后,可以通过“对象.属性名”的方式直接调用 ...

  5. P4151 [WC2011]最大XOR和路径 线性基

    题目传送门 题意:给出一幅无向图,求1到n的所有路径中最大异或和,一条边可以被重复经过. 思路: 参考了大佬的博客 #pragma GCC optimize (2) #pragma G++ optim ...

  6. ida x32 dbg 动态调试

    http://www.xrwcn.com/html/8.html 0x20019u 注册表 RegOpenKeyEx函数 LONG RegOpenKeyEx( HKEY hKey, // handle ...

  7. Qt 【“QWebView/private/qwebview interface p.h”: No such file or directory】

    这种情况下需要在pro工程文件中添加 QT += webkitwidgets 然后清理当前工程, 重新构建,在运行即可. 如果还不行,那么在#include <QWebView>这样替换成 ...

  8. Thread.Join理解

    Thread.Join:Blocks the calling thread until a thread terminates MainThread里面起了一个SubThread,从SubThread ...

  9. 小程序之rpx适配方案

    官网文档: 我的理解: rpx是自适应单位 计算方式: 1rpx = 设备屏幕宽度 / 750 注意:750是官网规定 为什么选择iPhone6为标准,作为开发模拟? 因为在iPhone6中,1px ...

  10. spring data jpa 配置文件1

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...