ElasticSearch 详细配置

1. 主要配置详解 node

默认配置 linux

含义 bootstrap

cluster.name: elasticsearch 服务器

配置es的集群名称,默认是elasticsearches会自动发如今同一网段下的es,若是在同一网段下有多个集群,就能够用这个属性来区分不一样的集群。 网络

node.name: "Franz Kafka" 并发

节点名,默认随机指定一个name列表中名字,该列表在esjar包中config文件夹里name.txt文件中,其中有不少做者添加的有趣名字。 app

node.master: true 负载均衡

指定该节点是否有资格被选举成为master node,默认是truees默认集群中的第一台机器为master,若是这台机挂了就会从新选举master jvm

node.data: true elasticsearch

指定该节点是否存储索引数据,默认为true

index.number_of_shards: 5

设置默认索引分片个数,默认为5片。

index.number_of_replicas: 1

设置默认索引副本个数,默认为1个副本。

path.conf: /path/to/conf

设置配置文件的存储路径,默认是es根目录下的config文件夹。

path.data: /path/to/data

设置索引数据的存储路径,默认是es根目录下的data文件夹,能够设置多个存储路径,用逗号隔开,例:
path.data: /path/to/data1,/path/to/data2

path.work: /path/to/work

设置临时文件的存储路径,默认是es根目录下的work文件夹。

path.logs: /path/to/logs

设置日志文件的存储路径,默认是es根目录下的logs文件夹

path.plugins: /path/to/plugins

设置插件的存放路径,默认是es根目录下的plugins文件夹

bootstrap.mlockall: true

设置为true来锁住内存。由于当jvm开始swappinges的效率会下降,因此要保证它不swap,能够把ES_MIN_MEMES_MAX_MEM两个环境变量设置成同一个值,而且保证机器有足够的内存分配给es。同时也要容许elasticsearch的进程能够锁住内存,linux下能够经过`ulimit -l unlimited`命令。

network.bind_host: 192.168.0.1

设置绑定的ip地址,能够是ipv4ipv6的,默认为192.168.0.1

network.publish_host: 192.168.0.1

设置其它节点和该节点交互的ip地址,若是不设置它会自动判断,值必须是个真实的ip地址。

network.host: 192.168.0.1

这个参数是用来同时设置bind_hostpublish_host上面两个参数。

transport.tcp.port: 9300

设置节点间交互的tcp端口,默认是9300

transport.tcp.compress: true

设置是否压缩tcp传输时的数据,默认为true,压缩。

http.port: 9200

设置对外服务的http端口,默认为9200

http.max_content_length: 100mb

设置内容的最大容量,默认100mb

http.enabled: false

是否使用http协议对外提供服务,默认为false,不开启。

gateway.type: local

gateway的类型,默认为local即为本地文件系统,能够设置为本地文件系统,分布式文件系统,hadoopHDFS,和amazons3服务器等。

gateway.recover_after_nodes: 1

设置集群中N个节点启动时进行数据恢复,默认为1

gateway.recover_after_time: 5m

设置初始化数据恢复进程的超时时间,默认是5分钟。

gateway.expected_nodes: 2

设置这个集群中节点的数量,默认为2,一旦这N个节点启动,就会当即进行数据恢复。

cluster.routing.allocation.node_initial_primaries_recoveries: 4

初始化数据恢复时,并发恢复线程的个数,默认为4

cluster.routing.allocation.node_concurrent_recoveries: 2

添加删除节点或负载均衡时并发恢复线程的个数,默认为2

indices.recovery.max_size_per_sec: 0

设置数据恢复时限制的带宽,如入100mb,默认为0,即无限制。

indices.recovery.concurrent_streams: 5

设置这个参数来限制从其它分片恢复数据时最大同时打开并发流的个数,默认为5

discovery.zen.minimum_master_nodes: 1

设置这个参数来保证集群中的节点能够知道其它N个有master资格的节点。默认为1,对于大的集群来讲,能够设置大一点的值(2-4

discovery.zen.ping.timeout: 3s

设置集群中自动发现其它节点时ping链接超时时间,默认为3秒,对于比较差的网络环境能够高点的值来防止自动发现时出错。

discovery.zen.ping.multicast.enabled: false

设置是否打开多播发现节点,默认是false

discovery.zen.ping.unicast.hosts: ["host1", "host2:port", "host3[portX-portY]"]

设置集群中master节点的初始列表,能够经过这些节点来自动发现新加入集群的节点。

index.search.slowlog.level: TRACE
index.search.slowlog.threshold.query.warn: 10s
index.search.slowlog.threshold.query.info: 5s
index.search.slowlog.threshold.query.debug: 2s
index.search.slowlog.threshold.query.trace: 500ms

index.search.slowlog.threshold.fetch.warn: 1s
index.search.slowlog.threshold.fetch.info: 800ms
index.search.slowlog.threshold.fetch.debug:500ms
index.search.slowlog.threshold.fetch.trace: 200ms

 

 

 

查询时的慢日志参数设