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基础【第九篇】

    补充知识 1.字符串方法的补充 s = str() s.format() # 格式化输出 "连接符".join("连接的对象") # 拼接 s.find() # ...

  2. Debug模式的三种配置方法

    使用`app.config.from_object`的方式加载配置文件: 1. 导入`import config`.2. 使用`app.config.from_object(config)`. ### ...

  3. Red Hat 操作系统 rpm 卸载软件提示"error: %preun( ) scriptlet failed, exit status 1"

    在linux里安装程序有两种方法,一种是源程序安装,按照安装包里的readme或者install文件指示,一步步地进行,通常是configure, make, install三部曲.另一种就是rpm包 ...

  4. Cloudflare-为自己的网站&博客保驾护航

    官网: https://www.cloudflare.com/zh-cn/ Cloudflare是什么? 优化功能,提升网站性能,提供SSL服务,提供安全防护,托管服务:为企业,非营利组织,博客等提供 ...

  5. Java web 应用自启动 shell脚本自动重启

    之前公司的内部管理系统jenkins自动构建代码有时候会失效,导致服务停掉. 于是乎就搞了一个自动启动脚本. oa.jar就是监测的服务 startup.sh 的内容是运行jar包的命令 java - ...

  6. Sed的查,删,增,改

    sed的查,删,增,改 1.sed的查找 2.sed的删除 3.sed的上下左右增加文件内容 4.sed的改

  7. struct解决socket黏包问题 (指令传输)

    服务端代码如下 import struct import subprocess import socket server = socket.socket() server.bind(()) serve ...

  8. 36.两个链表的第一个公共结点(python)

    题目描述 输入两个链表,找出它们的第一个公共结点. class Solution: def FindFirstCommonNode(self, pHead1, pHead2): # write cod ...

  9. npm转淘宝镜像

    1.临时使用 npm --registry https://registry.npm.taobao.org install express 2.持久使用 npm config set registry ...

  10. leetcode-168周赛-1298-你能从盒子中获得的最大糖果数

    题目描述: 方法一:bfs class Solution: def maxCandies(self, status: List[int], candies: List[int], keys: List ...