0
点赞
收藏
分享

微信扫一扫

elasticsearch搭建

毅会 2022-05-01 阅读 54

下载

地址:https://www.elastic.co/cn/elastic-stack/

解压

unzip elasticsearch-6.3.0.zip

改配置

进入解压目录后 vi config elasticsearch.yml

config下elasticsearch.yml

#----------------------cluster -----------------------------------
#
# Use a descriptive name for your cluster:
# 
# 集群名称
cluster.name: log_cluster
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
# 节点名称
node.name: node_02
# 是否可以为主节点
node.master: true
# 是否可以为数据节点
node.data: true
# 允许在对文档进行索引之前进行预处理
node.ingest: true
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# 数据存储目录,默认在es目录下data
#path.data: /path/to/data
#
# Path to log files:
#
# 日志存储目录,默认在es目录下logs
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# 锁定物理内存地址,防止es内存被交换出去,也就是避免es使用swap交换分区,频繁的交换,会导致IOPS变高
bootstrap.memory_lock: false
# 禁止检测SecComp
bootstrap.system_call_filter: false
# 当前机器ip地址,0.0.0.0 代表当前
network.host: 192.168.2.98
# 是否使用http协议对外提供服务,默认为true,开启
http.enabled: true
# 设置对外服务的http端口,默认为9200
http.port: 9200
# 设置节点间交互的tcp端口,默认是9300
transport.tcp.port: 9300
# 设置是否压缩tcp传输时的数据,默认为false,不压缩
transport.tcp.compress: true
#
# For more information, consult the network module documentation.
http.cors.enabled: true
http.cors.allow-origin: "*"
#
# --------------------------------- Discovery ----------------------------------
# 
# 设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点
discovery.zen.ping.unicast.hosts: ["192.168.2.72:9300","192.168.2.98:9300","192.168.2.169:9300"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
# 设置这个参数来保证集群中的节点可以知道其它N个有master资格的节点。默认为1,(total number of master-eligible nodes / 2 + 1)
discovery.zen.minimum_master_nodes: 1
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
# ---------------------------------- Cache  -----------------------------------

# 启用脚本 默认painless
cluster.routing.allocation.same_shard.host: true
#
# TODO 集群搭建好后配置
#
#
# #超时时间
discovery.zen.ping_timeout: 5s
discovery.zen.fd.ping_timeout: 5s
#
# #禁止自动创建索引
#action.auto_create_index: false
#
# # 一个集群中的N个节点启动后,才允许进行恢复处理 
gateway.recover_after_nodes: 1
# #
# # 设置初始化恢复过程的超时时间,超时时间从上一个配置中配置的N个节点启动后算起 
gateway.recover_after_time: 5m 
# #
# # 设置这个集群中期望有多少个节点.一旦这N个节点启动(并且recover_after_nodes也符合), 
# # 立即开始恢复过程(不等待recover_after_time超时) 
gateway.expected_nodes: 2
# # 线程池  
thread_pool.search.size: 100  
thread_pool.search.queue_size: 1000 
## 写入配置
#indices.memory.index_buffer_size: 2048mb
thread_pool.write.queue_size: 1000
indices.memory.index_buffer_size: 20%
indices.memory.min_index_buffer_size: 100mb
##index.refresh_interval: 40s


vi config elasticsearch.yml

config下jvm.options

## JVM configuration

################################################################
## IMPORTANT: JVM heap size
################################################################
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms30g
-Xmx30g

################################################################
## Expert settings
################################################################
##
## All settings below this section are considered
## expert settings. Don't tamper with them unless
## you understand what you are doing
##
################################################################

## GC configuration
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly

## optimizations

# pre-touch memory pages used by the JVM during initialization
-XX:+AlwaysPreTouch

## basic

# explicitly set the stack size
-Xss1m

# set to headless, just in case
-Djava.awt.headless=true

# ensure UTF-8 encoding by default (e.g. filenames)
-Dfile.encoding=UTF-8

# use our provided JNA always versus the system one
-Djna.nosys=true

# turn off a JDK optimization that throws away stack traces for common
# exceptions because stack traces are important for debugging
-XX:-OmitStackTraceInFastThrow

# flags to configure Netty
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0

# log4j 2
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true

-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
-XX:+HeapDumpOnOutOfMemoryError

# 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
# due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise
# time/date parsing will break in an incompatible way for some date patterns and locals
9-:-Djava.locale.providers=COMPAT

ik分词器

下载:https://github.com/medcl/elasticsearch-analysis-ik/blob/master/README.md

解压到plugins下创建的ik文件夹下,ik文件夹可以自定义命名

在这里插入图片描述

在这里插入图片描述

启动

进入目录使用 ./bin/elasticsearch -d 后台启动
使用 tail -f logs/log_cluster.log 查看启动状态

在这里插入图片描述

举报

相关推荐

0 条评论