ElasticSearch7.14 安装和使用Kibana连接的记录

elasticsearch部分:

在云服务器上安装ElasticSearch7.14 ,下载页面:https://www.elastic.co/cn/downloads/elasticsearch

 

 

 

 

 

 

下载后解压,启动es服务时不能以root用户启动,需要新建一个普通用户。

修改配置文件 elasticsearch.yml

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 192.168.0.1
network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

 

遇到的问题1:

[es@iZwz9b3oj2864l4ivl0qirZ bin]$ ./elasticsearch
could not find java in bundled JDK at /home/es7/elasticsearch-7.14.0/jdk/bin/java

解决:

给es用户(自己新建的一个非root用户)授予文件夹的权限:

chown -R es:es /home/es7/elasticsearch-7.14.0

 

 

遇到的问题2:

ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: 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

解决:https://blog.csdn.net/qq_43655835/article/details/104637625

就是配置文件的最后一处红色部分的配置。

此时启动es服务,在本地通过服务器地址+9200端口可以访问

{
  "name" : "node-1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "yrsPwHnoSeqnXV6WirSOKQ",
  "version" : {
    "number" : "7.14.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "dd5a0a2acaa2045ff9624f3729fc8a6f40835aa1",
    "build_date" : "2021-07-29T20:49:32.864135063Z",
    "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"
}

 

 

kibana部分

下载kibana到windows,修改 config目录下的 kibana.yml 文件

将 elasticsearch.hosts: 里的ip改为云服务器的ip

接着运行bat文件,发现 一直报错:Action failed with 'Request timed out'. Retrying attempt

百思不得其解,初始以为是  kibana.yml 的配置文件改错了,经排查发现不是

突然看到es的控制台一直有输出东西,好像是在找集群的其他节点?而且找不到,为什么会这样呢?明明只有一个节点,是不是这个原因导致了kibana连接es失败了呢?

恰好看到这篇文章:https://www.cnblogs.com/simendavid/p/15606122.html

猜测是遇到问题2时的解决方案导致的,于是回去再看,原来自己配置elasticsearch.yml 文件时没有配置 

node.name: node-1

但是后面的配置又用到了
cluster.initial_master_nodes: ["node-1"]

解决:给elasticsearch.yml配置文件加上
node.name: node-1



使用部分
在若依框架的基础上引入es7.14的依赖,但不知为何一直下不下来,最后只能自己把jar下下来,再安装到maven本地仓库
参考:将下载到本地的JAR包手动添加到Maven仓库

至于会安装到哪里,取决于你的maven配置

mvn install:install-file -Dfile="D:\es\elasticsearch-rest-high-level-client-7.14.0.jar" -DgroupId=org.elasticsearch.client -DartifactId=elasticsearch-rest-high-level-client -Dversion=7.14.0 -Dpackaging=jar


mvn install:install-file -Dfile="D:\es\elasticsearch-7.14.0.jar" -DgroupId=org.elasticsearch -DartifactId=elasticsearch -Dversion=7.14.0 -Dpackaging=jar

 



 


 



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章