centos7安裝部署安裝Elasticsearch
前言
為什么要使用“Elastic Stack”
它到底是什么?它是一組快速且高度可擴(kuò)展的組件(Elasticsearch、Kibana、Beats、Logstash 等),
它們共同使您能夠安全地從任何來源以任何格式獲取數(shù)據(jù),
然后對其進(jìn)行搜索、分析和可視化。
官網(wǎng)地址:
https://www.elastic.co/cn/
tar包地址
https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-17-3
一、安裝環(huán)境?
jdk1.8、elasticsearch-7.17.3-linux-x86_64
二、安裝及啟動步驟
1、解壓 elasticsearch-7.17.3-linux-x86_64.tar
1:切換到/opt/software 目錄
cd /opt/software
2:創(chuàng)建es目錄
mkdir es
3:將elasticsearch-7.17.3-linux-x86_64.tar上傳至 /opt/software/es
4:解壓縮es安裝包
tar -zxvf elasticsearch-7.17.3-linux-x86_64.tar
5、修改配置文件
cd /opt/software/es/elasticsearch-7.17.3 /config
vim elasticsearch.yml --編輯es配置文件
單機(jī)如下圖配置所示 --##EDIT下為修改部分
# ======================== 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 ------------------------------------
#節(jié)點信息
# Use a descriptive name for the node:
##EDIT
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:
#關(guān)閉自檢程序
##EDIT
bootstrap.memory_lock: 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 -----------------------------------
#網(wǎng)絡(luò)配置
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
##EDIT
network.host: 本機(jī)ip
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
##EDIT
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#自發(fā)現(xiàn)配置新節(jié)點向集群報到的主機(jī)名
# 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:
##EDIT
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
#
# ---------------------------------- Security ----------------------------------
#
# *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don’t have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features.
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html
#增加跨域配置
##EDIT
http.cors.enabled: true
http.cors.allow-origin: "*"
6、修改jvm.options配置文件
################################################################
##
## JVM configuration
##
################################################################
##
## WARNING: DO NOT EDIT THIS FILE. If you want to override the
## JVM options in this file, or set any additional options, you
## should create one or more files in the jvm.options.d
## directory containing your adjustments.
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/7.17/jvm-options.html
## for more information.
##
################################################################
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## and the min and max should be set to the same value. For
## example, to set the heap to 4 GB, create a new file in the
## jvm.options.d directory containing these lines:
##EDIT
-Xms512m
-Xmx512m
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/7.17/heap-size.html
## for more information
##
################################################################
################################################################
## Expert settings
################################################################
##
## All settings below here are considered expert settings. Do
## not adjust them unless you understand what you are doing. Do
## not edit them in this file; instead, create a new file in the
## jvm.options.d directory containing your adjustments.
##
################################################################
## GC configuration
8-13:-XX:+UseConcMarkSweepGC
8-13:-XX:CMSInitiatingOccupancyFraction=75
8-13:-XX:+UseCMSInitiatingOccupancyOnly
## G1GC Configuration
# NOTE: G1 GC is only supported on JDK version 10 or later
# to use G1GC, uncomment the next two lines and update the version on the
# following three lines to your version of the JDK
# 10-13:-XX:-UseConcMarkSweepGC
# 10-13:-XX:-UseCMSInitiatingOccupancyOnly
14-:-XX:+UseG1GC
## JVM temporary directory
-Djava.io.tmpdir=${ES_TMPDIR}
## heap dumps
# generate a heap dump when an allocation from the Java heap fails; heap dumps
# are created in the working directory of the JVM unless an alternative path is
# specified
-XX:+HeapDumpOnOutOfMemoryError
# exit right after heap dump on out of memory error. Recommended to also use
# on java 8 for supported versions (8u92+).
9-:-XX:+ExitOnOutOfMemoryError
# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=data
# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log
## JDK 8 GC logging
8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringDistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:logs/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m
# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
7、創(chuàng)建用戶并賦予權(quán)限,不能再root用戶下啟動
useradd 用戶名
passwd 用戶名 隨后會提示輸入密碼
賦予權(quán)限
cd /opt/software/es
chown -R 用戶名:用戶名 ./ —chown將指定文件的擁有者改為指定的用戶或組,
usermod -g root 用戶 —將當(dāng)前用戶添加至root組
8、elasticsearch 啟動的時候要求當(dāng)前用戶最大線程數(shù)至少為 4096 個線程,修改當(dāng)前用戶最大線程數(shù)
如下所示
顯示 當(dāng)前用戶擁有線程數(shù) ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 3834 -----此處為當(dāng)前用戶線程數(shù)
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 3834
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
修改線程數(shù)
vim /etc/security/limits.conf
文件末尾加入 如下三行文章來源:http://www.zghlxwxcb.cn/news/detail-604677.html
用戶名 soft nofile 65536
用戶名 hard nofile 65536
用戶名 - nproc 65535
2、 前臺啟動elasticsearch
cd /opt/software/es/elasticsearch-7.17.3/bin
./elasticsearch --前臺啟動es
http://ip:9200 --訪問es網(wǎng)址
如下
{
"name" : "node-1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "933ymxObQnKVmo3j6jXp0g",
"version" : {
"number" : "7.17.3",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "5ad023604c8d7416c9eb6c0eadb62b14e766caff",
"build_date" : "2022-04-19T08:11:19.070913226Z",
"build_snapshot" : false,
"lucene_version" : "8.11.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
前臺啟動成功
3、 后臺啟動elasticsearch
后臺啟動文章來源地址http://www.zghlxwxcb.cn/news/detail-604677.html
./bin/elasticsearch -d
到了這里,關(guān)于linux centos7安裝部署安裝Elasticsearch并后臺啟動的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!