当前位置:主页 > 软件编程 > JAVA代码 >

Elasticsearch配置文件示例示范

时间:2022-12-29 10:51:25 | 栏目:JAVA代码 | 点击:

一 前言

在elasticsearch\config目录下,有三个核心的配置文件:

这里以elasticsearch6.5.4版本为例,并且由于版本不同,配置也不太也一样,仅作参考!

二 elasticsearch.yml

2.1 Cluster

cluster.name: my-application
transport.tcp.port: 9300
cluster.routing.allocation.same_shard.host:true
cluster.routing.allocation.node_initial_primaries_recoveries: 4
cluster.routing.allocation.node_concurrent_recoveries: 4

2.2 Node

node.name: node-1
node.attr.rack: r1
node.master: true
node.data: true
index.number_of_shards: 5
index.number_of_replicas: 1
indices.recovery.max_size_per_ser: 0
indices.recovery.concurrent_streams: 5
indices.recovery.max_size_per_ser: 0
indices.recovery.concurrent_streams: 5

2.3 Paths

path.data: /path/to/data
# path.data: /path/to/data1,/path/to/data1
path.work: /path/to/work
path.logs: /path/to/logs
path.logs: /path/to/logs
path.plugins: /path/to/plugins

2.4 Network

network.host: 192.168.0.1

上面的设置可以拆分为两个参数。

network.bind_host: 192.168.0.1 	# 设置绑定的ip地址,ipv4或ipv6都可以
network.publish_host: 192.168.0.1  # 设置其它节点和该节点交互的ip地址,如果不设置它会自动判断,值必须是个真实的ip地址
http.port: 9200

2.5 Discovery

discovery.zen.ping.multicast.enabled: true
discovery.zen.ping.unicast.hosts: ["host1", "host2"]
discovery.zen.ping.unicast.hosts: ["10.0.0.1", "10.0.0.3:9300", "10.0.0.6[9300-9400]"]
discovery.zen.ping.timeout: 3s

2.6 Memory

bootstrap.memory_lock: true
bootstrap.mlockall: true

2.7 Gateway

transport.tcp.compress: true
http.max_content_length: 100mb
http.enabled: false
gateway.type: local
gateway.recover_after_nodes: 3
gateway.recover_after_time: 5m
gateway.expected_nodes: 2

2.8 Various

action.destructive_requires_name: true

三 jvm.options

-Xms1g     # 设置最小堆为1g
-Xmx1g		# 设置最大堆为1g

四 log4j2.properties

这个配置文件,我们一般不修改其配置。

您可能感兴趣的文章:

相关文章