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获取每日涨跌停股票统计,封闭时间和打开次数

    接口:limit_list 描述:获取每日涨跌停股票统计,包括封闭时间和打开次数等数据,帮助用户快速定位近期强(弱)势股,以及研究超短线策略. 限量:单次最大1000,总量不限制 积分:用户积2000 ...

  2. 35-python基础-python3-字符串修改大小写的方法-title()方法-lower()方法-upper()方法

    1-title()-注:不是原地修改,有返回值 以首字母大写的方式显示每个单词,即将每个单词的首字母都改为大写. 2-lower()和upper()-注:不是原地修改,有返回值 将字符串改为全部小写或 ...

  3. linux 下安装chrome的rpm包

    1. 下载chrome的rpm包,假设叫cho. 2.执行命令 rpm -ivh cho 3.报错提示需要lsb>=4.0,执行命令 yum install lsb 等待安装完毕. 4. 重新执 ...

  4. Python之向函数传递元组和字典

    也可以在函数定义时加上这两个参数用以接收多余的参数哦~

  5. bat批处理----copy和xcopy区别

    copy和xcopy区别:两者都可以赋值文件 1.copy不能在有子目录存在的文件中拷贝文件的同时重命名此文件名 2.copy命令能合并两个文件,而xcopy不能

  6. 根据ThinkPHP官方文档学习opensns框架

    根据ThinkPHP官方文档学习opensns框架 1.解读Application下各个Controller文件夹下的作用 控制器类的命名方式是:控制器名(驼峰法,首字母大写)+Controller ...

  7. ASP.NET MVC SignalR 简单聊天推送笔记

    介绍:(抄袭于网络) ASP.NET SignalR 是为 ASP.NET 开发人员提供的一个库,可以简化开发人员将实时 Web 功能添加到应用程序的过程.实时 Web 功能是指这样一种功能:当所连接 ...

  8. git的一些简单用法

    1.工作区暂存区和仓库区 工作区 对于添加.修改.删除文件的操作,都发生在工作区中 暂存区 暂存区指将工作区中的操作完成小阶段的存储,是版本库的一部分 仓库区 仓库区表示个人开发的一个小阶段的完成 仓 ...

  9. Java中有几种类型的流?

    (1)字节流 InputStream/OutputStream ①FileInputStream/FileOutputStream:文件字节流,用于文件的读写操作 ②BufferedInputStre ...

  10. CSIC_716_20191213【内置函数exec、元类】

    In memory of the more than 300 thousand Chinese murdered exec( 字符类型的代码,全局变量,局部变量 ).其中,全局变量和局部变量可以写成字 ...