CentOS7安裝ElasticSearch

CentOS7
在這裏插入圖片描述
ElasticSearch7.8
官網下載,https://www.elastic.co/cn/downloads/
在這裏插入圖片描述
在這裏插入圖片描述
上傳到
在這裏插入圖片描述
解壓
cd /soft/elastic
tar -zxvf elasticsearch-7.8.0-linux-x86_64.tar.gz
mv elasticsearch-7.8.0-linux-x86_64 /home/elasticsearch
在這裏插入圖片描述
adduser news
cd /home
mkdir -p elastic/data
mkdir -p elastic/logs
chown -R news elasticsearch
chown -R news elastic
接下來非常重要
cd /home/elasticsearch/conf/
vim 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.data: /home/elastic/data
#
# Path to log files:
#
#path.logs: /path/to/logs
path.logs: /home/elastic/logs
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
# 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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: 0.0.0.0
# Set a custom port for HTTP:
#
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"]
discovery.zen.ping.unicast.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.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
gateway.recover_after_nodes: 1
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#my
action.destructive_requires_name: true
xpack.ml.enabled: false

接下來配置一些內核參數

vim /etc/security/limits.conf

到文件末尾添加如下內容

esuser hard nofile 65536
esuser soft nofile 65536
esuser soft memlock unlimited
esuser hard memlock unlimited

爲了防止報錯[65530] is too low, increase to at least [262144]
修改vim /etc/sysctl.conf 文件,在末尾添加 vm.max_map_count
使生效:sysctl -p
vim /etc/security/limits.d/def.conf文件尾添加

  • soft nofile 204800
  • hard nofile 204800
    讓news用戶具有和root一樣的權限,visudo,添加如下,保存並退出。
    在這裏插入圖片描述

錯誤:JVM is using the client VM [Java HotSpot™ Client VM] but should be using a server VM for the best performance

修改文件
JAVA_HOME\jre\lib\i386\jvm.cfg
-server KNOWN //原來在第二行
-client IF_SERVER_CLASS -server
-minimal KNOWN

錯誤
unable to load JNA native support library, native methods will be disabled.
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/linux-x86/libjnidispatch.so) not found

解決辦法
直接刪除或備份Elasticsearch-a.b.c/lib目錄下面的jna文件:
mv jna-4.5.1.jar jna-4.5.1.jar.bak
在lib目錄下載:
wget http://repo1.maven.org/maven2/net/java/dev/jna/jna/5.0.0/jna-5.0.0.jar
在這裏插入圖片描述
執行如下命令

在這裏插入圖片描述
沒有報錯,如果報錯,要去找到日誌,拖到windows下查看,效果明顯。
日誌目錄 /home/elastic/logs

打開瀏覽器
在這裏插入圖片描述

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