CentOS7安装ELK 7.x(1)—安装程序

ELK是一套日志可视化工具,三个组件分别是Elasticsearch、Logstash、Kibana。
Elasticsearch是一个搜索和分析引擎。
Logstash是服务器端数据处理管道,能够同时从多个来源采集数据,转换数据,然后将数据发送到诸如Elasticsearch等“存储库”中。
Kibana则可以让用户在Elasticsearch中使用图形和图表对数据进行可视化。
现在这套工具也叫Elastic Stack,因为引入了Beats工具。

官方网站:https://www.elastic.co/cn/
下载页面:https://www.elastic.co/cn/downloads/
看下来感觉ELK这套东西是同一个公司的产品

一、服务端需要安装elasticsearch+kibana

1、下载elasticsearch

cd /tmp
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-linux-x86_64.tar.gz
tar -zxvf elasticsearch-7.14.1-linux-x86_64.tar.gz
mv /tmp/elasticsearch-7.14.1 /appserver/elasticsearch

2、下载kibana

cd /tmp
wget https://artifacts.elastic.co/downloads/kibana/kibana-7.14.1-linux-x86_64.tar.gz
tar -zxvf kibana-7.14.1-linux-x86_64.tar.gz
mv /tmp/kibana-7.14.1-linux-x86_64 /appserver/kibana

3、简单的启动elasticsearch

./bin/elasticsearch

前台运行,日志默认打印在stdout和<clustername>.log中,启动后访问端口9200,使用Ctrl-C退出

提示:

warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/appserver/jdk1.8.0_231/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
uncaught exception in thread [main]
java.lang.RuntimeException: can not run elasticsearch as root

第一个问题是ES7.x需要jdk11,可以用ES自带的JDK
第二个问题是ES不能用root用户启动,需要新建一个用户

解决:
1)使用自带jdk
看了elasticsearch自带jdk的版本是openjdk version "16.0.2"

在/etc/profile添加:

ES_JAVA_HOME=/appserver/elasticsearch/jdk
PATH=$PATH:$ES_JAVA_HOME
export ES_JAVA_HOME PATH CLASSPATH

使设置生效:

source /etc/profile

2)建立一个elk用户用来运行程序,使用root登录后切换

useradd elk
passwd elk

3)重新启动

chown -R elk:elk /appserver/elasticsearch
su - elk
cd /appserver/elasticsearch
./bin/elasticsearch

4)此时9200端口还不能访问,因为默认是localhost访问
 http://server-ip:9200 

4、简单的启动kibana

./bin/kibana

前台运行,日志默认打印在stdout,使用Ctrl-C退出
也用elk用户启动

chown -R elk:elk /appserver/kibana
su - elk
cd /appserver/kibana
./bin/kibana

5、elasticsearch目录结构

类型说明默认位置设置参数
homeElasticsearch的家目录或者$ES_HOME解压后的目录位置
bin启动脚本,包括elasticsearch启动一个节点,elasticsearch-plugin安装插件$ES_HOME/bin
conf配置文件$ES_HOME/configelasticsearch.yml:设置Elasticsearch
jvm.options:设置Elasticsearch JVM参数
log4j2.properties:设置Elasticsearch logging
data本地的数据文件$ES_HOME/datapath.data
logs本地的日志文件$ES_HOME/logspath.logs
plugins本地插件,每个插件在一个子目录里$ES_HOME/plugins
repo共享文件系统存储库位置。可以容纳多个位置。文件系统存储库可以放置在此处指定的任何目录的任何子目录中path.repo

6、kibana目录结构

类型说明默认位置设置参数
homeKibana的家目录或者$KIBANA_HOME解压后的目录位置
bin启动脚本,包括kibana启动服务,kibana-plugin安装插件$KIBANA_HOME\bin
config配置文件$KIBANA_HOME\configkibana.yml
data本地数据文件位置$KIBANA_HOME\data
plugins本地插件,每个插件在一个子目录里$KIBANA_HOME\data

7、 配置elasticsearch.yml

#集群名称
cluster.name: my-cluster
#节点名称
node.name: node-1
#服务监听地址
network.host: 0.0.0.0
#服务监听端口
http.port: 9200

8、配置jvm.options

-Xms512m
-Xmx512m

9、重新启动配置elasticsearch又报错

ERROR: [3] bootstrap checks failed. You must address the points described in the following [3] lines before starting Elasticsearch.
bootstrap check failure [1] of [3]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
bootstrap check failure [2] of [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
bootstrap check failure [3] of [3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
ERROR: Elasticsearch did not exit normally - check the logs at /appserver/elasticsearch/logs/my-cluster.log

解决:
1)vi /etc/security/limits.conf
添加:

* soft nofile 65536
* hard nofile 65536

用户退出重新登录后生效

2)vi /etc/sysctl.conf
添加:

vm.max_map_count=262144

sysctl -p生效

3)在elasticsearch.yml里修改

#集群发现方式
cluster.initial_master_nodes: ["node-1"]

后台启动elasticsearch

./bin/elasticsearch -d

重新启动elasticsearch后,访问9200端口,可通:

{
  "name" : "node-1",
  "cluster_name" : "my-cluster",
  "cluster_uuid" : "4xPDsTg2QXSgnSwd_5uHIA",
  "version" : {
    "number" : "7.14.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "66b55ebfa59c92c15db3f69a335d500018b3331e",
    "build_date" : "2021-08-26T09:01:05.390870785Z",
    "build_snapshot" : false,
    "lucene_version" : "8.9.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

http://server-ip:9200/_cat/health?v

epoch      timestamp cluster    status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1631499040 02:10:40  my-cluster green           1         1     10  10    0    0        0             0                  -                100.0%

10、配置kibana.yml

#服务端口
server.port: 5601
#服务地址
server.host: "0.0.0.0"
#传输的最大数据量
server.maxPayload: 1048576
#服务名称
server.name: "your-hostname"
#elasticsearch的地址
elasticsearch.hosts: ["http://localhost:9200"]
#中文界面
#i18n.locale: "zh-CN"
kibana.index: ".kibana"

访问http://server-ip:5601

参考资料:
Get Started with Elasticsearch, Kibana, and the Elastic Stack | Elastic
Install Elasticsearch from archive on Linux or MacOS | Elasticsearch Guide [7.14] | Elastic
Install Kibana from archive on Linux or macOS | Kibana Guide [7.14] | Elastic
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值