ELK-kafka 部署

一、准备工作

  • 准备安装包

ELK下载地址:https://www.elastic.co/downloads

zookeeper下载地址:https://www.apache.org/dyn/closer.cgi/zookeeper/

kafka下载地址:http://kafka.apache.org/downloads

目前开发环境准备的安装包如下:

elasticsearch-7.0.0-linux-x86_64.tar.gz

logstash-7.0.0.tar.gz

kibana-7.0.0-linux-x86_64.tar.gz

kafka_2.11-2.2.0.tgz

zookeeper-3.4.12.tar.gz

将安装包上传到对应的服务器,比如172.18.5.47

二、安装ES(172.18.5.47)

elasticsearch官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html

1、创建用户
因为elasticsearch不能使用root用户启动,所以需要先创建一个用户,并对用户进行授权,使用root用户登录,执行以下命令

useradd elasticsearch #创建用户
passwd elasticsearch #设置用户密码,输入与用户名一样的密码

2、安装unzip
yum install -y unzip

3、修改系统参数
vi /etc/security/limits.conf
增加以下内容

  • soft nofile 65536
  • hard nofile 131072
  • soft nproc 2048
  • hard nproc 4096
    vi /etc/security/limits.d/90-nproc.conf
    修改如下内容:
  • soft nproc 1024
    修改为
  • soft nproc 4096

vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
4、上传文件
使用elasticsearch用户登录,将之前下载好的elasticsearch-7.0.0-linux-x86_64.tar.gz上传

5、创建数据与日志目录
在elasticsearch用户的根目录执行以下命令

mkdir {log,data}
6、解压安装包、修改配置
解压安装包

tar -zxvf elasticsearch-7.0.0-linux-x86_64.tar.gz
进入

elasticsearch-7.0.0/config目录,config目录下有三个文件:
elasticsearch.yml # els的配置文件
jvm.options # JVM相关的配置,内存大小等等
log4j2.properties # 日志系统定义
开发环境修改后的配置如下:

easticsearch.yml

#cluster.name: erong-cluster                                        #集群名称

node.name: node-47                                             #节点名称,仅仅是描述名称,用于在日志中区分

path.data: /kduser/elasticsearch/data                                                            #数据的默认存放路径

path.logs: /kduser/elasticsearch/log                                                             #日志默认存放路径

network.host: 172.18.5.47                                                                    #当前节点的IP地址

http.port: 9200                                                                                #对外提供服务的端口,9300为集群服务的端口

#cluster.initial_master_nodes: ["node-1"]

#discovery.zen.ping.unicast.hosts: ["172.18.5.47"]          #集群个节点IP地址

#discovery.zen.minimum_master_nodes: 2                                                          #为了避免脑裂,集群节点数最少为 半数+1

#bootstrap.system_call_filter: false                                                            #禁止系统调用过滤器

xpack.license.self_generated.type: basic

7.X系列还需要修改
可以配置:cluster.initial_master_nodes

jvm.options中默认内存为1G,开发环境可以不修改,生产时需要根据服务器内存调整大小

-Xms1g # JVM最大、最小使用内存
-Xmx1g
8、启动easticsearch
后台启动

./elasticsearch -d
9、访问测试
使用访问:http://172.18.5.47:9200,出现如下信息,说明访问成功

安装时遇到的问题

问题一: [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536])

解决:切换到root用户,进入/etc/security目录下修改配置文件
vi /etc/security/limits.conf
增加以下内容

  • soft nofile 65536
  • hard nofile 131072
  • soft nproc 2048
  • hard nproc 4096

“*”表示给所有用户起作用

修改以上配置后需要重新登录即可是

注:要使 limits.conf 文件配置生效,必须要确保 pam_limits.so 文件被加入到启动文件中。查看 /etc/pam.d/login 文件中有:
ls /lib/security/pam_limits.so

问题二: max number of threads [2048] for user [es] is too low, increase to at least [4096]

解决:切换到root用户,进入limits.d目录下修改配置文件。

vi /etc/security/limits.d/90-nproc.conf
修改如下内容:

  • soft nproc 1024
    修改为
  • soft nproc 4096
    注:修改以上配置后需要重启服务器

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

解决:切换到root用户修改配置sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p

问题四:ERROR: bootstrap checks failed

system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

原因:
这是在因为Centos6不支持SecComp,而ES5.2.0默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。

解决:
在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

猜你喜欢

转载自www.cnblogs.com/gloria-liu/p/12201793.html