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

 



 


 



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