在elasticsearch部署的时候,一般我们修改下clustername和nodename后,其他的配置项我们保持默认的就可以启动起来。但是这样的一个环境在生产中一般是不会被允许的,因此我们在生产环境中还是会涉及到其他参数的配置,下面我们以elasticsearch7.x的版本介绍下7.x版本可以配置的参数有哪些?
序号 | 配置项 | 说明 |
1 | cluster.name: ES | ES集群名称,同一个集群内的所有节点集群名称必须保持一致 |
2 | node.name: slave2 | ES集群内的节点名称,同一个集群内的节点名称要具备唯一性 |
3 | node.master: true | 允许节点是否可以成为一个master节点,ES是默认集群中的第一台机器成为master,如果这台机器停止就会重新选举 |
4 | node.data: false | 允许该节点存储索引数据(默认开启) |
5 | path.data: | ES是搜索引擎,会创建文档,建立索引,此路径是索引的存放目录.可以指定多个存储位置 |
6 | path.logs: | elasticsearch专门的日志存储位置 |
7 | bootstrap.memory_lock: true | 在ES运行起来后锁定ES所能使用的堆内存大小,锁定内存大小一般为可用内存的一半左右;锁定内存后就不会使用交换分区。如果不打开此项,当系统物理内存空间不足,ES将使用交换分区,ES如果使用交换分区,那么ES的性能将会变得很差 |
8 | network.host: 0.0.0.0 | es的HTTP端口和集群通信端口就会监听在此地址上 |
9 | network.tcp.no_delay: true | 是否启用tcp无延迟,true为启用tcp不延迟,默认为false启用tcp延迟 |
10 | truenetwork.tcp.keep_alive: true | 是否启用TCP保持活动状态,默认为true |
11 | network.tcp.reuse_address: true | 是否应该重复使用地址。默认true,在Windows机器上默认为false |
12 | network.tcp.send_buffer_size: 128mb | tcp发送缓冲区大小,默认不设置 |
13 | network.tcp.receive_buffer_size: 128mb | tcp接收缓冲区大小,默认不设置 |
14 | transport.tcp.port: 9301 | 设置集群节点通信的TCP端口,默认就是9300 |
15 | transport.tcp.compress: true | 设置是否压缩TCP传输时的数据,默认为false |
16 | http.max_content_length: 200mb | 设置http请求内容的最大容量,默认是100mb |
17 | http.cors.enabled: true | 是否开启跨域访问 |
18 | http.cors.allow-origin: "*" | 开启跨域访问后的地址限制,*表示无限制 |
19 | http.port: 9201 | 定义ES对外调用的http端口,默认是9200 |
20 | discovery.seed_hosts: ["127.0.0.1:9301","127.0.0.1:9302","127.0.0.1:9303"] | Elasticsearch7新增参数,写入候选主节点的设备地址,来开启服务时就可以被选为主节点,由discovery.zen.ping.unicast.hosts:参数改变而来 |
21 | cluster.initial_master_nodes: ["127.0.0.1:9301","127.0.0.1:9302"] | Elasticsearch7新增参数,写入候选主节点的设备地址,来开启服务时就可以被选为主节点 |
22 | cluster.fault_detection.leader_check.interval: 15s | Elasticsearch7新增参数,设置每个节点在选中的主节点的检查之间等待的时间。默认为1秒 |
23 | discovery.cluster_formation_warning_timeout: 30s | Elasticsearch7新增参数,启动后30秒内,如果集群未形成,那么将会记录一条警告信息,警告信息未master not fount开始,默认为10秒 |
24 | cluster.join.timeout: 30s | Elasticsearch7新增参数,节点发送请求加入集群后,在认为请求失败后,再次发送请求的等待时间,默认为60秒 |
25 | cluster.publish.timeout: 90s | Elasticsearch7新增参数,设置主节点等待每个集群状态完全更新后发布到所有节点的时间,默认为30秒 |
26 | cluster.routing.allocation.cluster_concurrent_rebalance: 32 | 集群内同时启动的数据任务个数,默认是2个 |
27 | cluster.routing.allocation.node_concurrent_recoveries: 32 | 添加或删除节点及负载均衡时并发恢复的线程个数,默认4个 |
28 | cluster.routing.allocation.node_initial_primaries_recoveries: 32 | 初始化数据恢复时,并发恢复线程的个数,默认4个 |
以上就是在elasticsearch集群配置的时候,${elasticsearch_home}/config/elasticsearch.yml文件中可以配置的项。下面再给一个初始化的默认的模板,大家根据实际情况进行调整即可。
cluster.name: elastic_cluster node.name: elastic_node1 node.master: true node.data: true path.data: /usr/local/elastic_node1/data path.logs: /usr/local/elastic_node1/logs bootstrap.memory_lock: true network.host: 127.0.0.1 network.tcp.no_delay: true network.tcp.keep_alive: true network.tcp.reuse_address: true network.tcp.send_buffer_size: 256mb network.tcp.receive_buffer_size: 256mb transport.tcp.port: 9302 transport.tcp.compress: true http.max_content_length: 200mb http.cors.enabled: true http.cors.allow-origin: "*" http.port: 9202 discovery.seed_hosts: ["127.0.0.1:9301","127.0.0.1:9302","127.0.0.1:9303"] cluster.initial_master_nodes: ["127.0.0.1:9301","127.0.0.1:9302","127.0.0.1:9303"] cluster.fault_detection.leader_check.interval: 15s discovery.cluster_formation_warning_timeout: 30s cluster.join.timeout: 30s cluster.publish.timeout: 90s cluster.routing.allocation.cluster_concurrent_rebalance: 16 cluster.routing.allocation.node_concurrent_recoveries: 16 cluster.routing.allocation.node_initial_primaries_recoveries: 16
备注:
1、此默认配置模板仅供参考,在真实环境中,建议根据实际情况进行调整。
还没有评论,来说两句吧...