04.local_gateway和network相关设置

1. cluster restart的一些相关设置

  es local gateway是一个功能模块,负责在整个集群重新启动时存储cluster state和shard 数据。主要作用是控制整个集群重启后的恢复时机。
试想下这种场景:
集群中有9个节点,假设都为master eligible 节点。那么集群重启后需要满足5个节点连接,就可以选举出master。并可以进行recovery操作(将replica copy变为primary copy并且reallocate replica)。
如果接下来剩余的节点陆续启动并加入集群,此时recovery或者在进行中,或者已经完成,因为这些节点已经存在了正在recovery的数据,就会造成不必要的recovery(当然es有自己的优化算法,比如如果recovery的shard在节点离开集群后,留在集群中的对应的shard没有数据变更,那么此节点的shard与集群中其他节点的shard是sync的,就会终止recovery操作)。
当节点加入集群后,又会造成不必要的Rebalance操作。为了解决这个问题,引入了gateway相关的配置。主要有如下参数:

上面这几个参数是hard limit。必须要满足的。下来几个参数是在满足上面几个参数要求的基础上生效。

1. gateway.expected_nodes:

The number of (data or master) nodes that are expected to be in the cluster. Recovery of local shards will start as soon as the expected number of nodes have joined the cluster. Defaults to 0。
设置当指定数量的data或者master节点加入集群后,才进行恢复操作。默认值为0。此参数应该要大于等于上面的gateway.recover_after_nodes参数值。

2. gateway.expected_master_nodes:

The number of master nodes that are expected to be in the cluster. Recovery of local shards will start as soon as the expected number of master nodes have joined the cluster. Defaults to 0。
设置当指定数量的master节点加入集群后,才进行恢复操作。默认值为0。此参数应该要大于等于上面的gateway.recover_after_master_nodes参数值。

3. gateway.expected_data_nodes:

The number of data nodes that are expected to be in the cluster. Recovery of local shards will start as soon as the expected number of data nodes have joined the cluster. Defaults to 0。
设置当指定数量的data节点加入集群后,才进行恢复操作。默认值为0。此参数应该要大于等于上面的gateway.recover_after_data_nodes参数值。

4. gateway.recover_after_time:

If the expected number of nodes is not achieved, the recovery process waits for the configured amount of time before trying to recover regardless. Defaults to 5m if one of the expected_nodes settings is configured.
如果上面的expected相关的三个参数不满足,那么会等待一定的时间,默认是5min。 如果5分钟之后还没有达到上面的条件那么只要满足下面的任何一个条件后就会进行recovery.

5.gateway.recover_after_nodes:

Recover as long as this many data or master nodes have joined the cluster.
设置当指定数量的data或者master(node.master: true)节点加入集群后才开始进行恢复操作。即使在此之前已选举出了master节点。

6.gateway.recover_after_master_nodes:

Recover as long as this many master nodes have joined the cluster.
设置当指定数量的master(node.master: true)节点加入集群后才进行恢复操作。即使在此之前已选举出了master节点。

7. gateway.recover_after_data_nodes:

Recover as long as this many data nodes have joined the cluster.
设置当指定数量的data节点加入集群后才进行恢复操作。即使在此之前已选举出了master节点。

gateway相关参数仅适用于集群完全重启。如果只是节点重启可使用延迟恢复参数进行设置

同时,如果一个node重新join到cluster当中,那些在当前node上存在但是cluster中并不存在的shard会直接被加入到cluster当中去,这种情况只是发生在所有的master都挂掉了,新启动了一个node座位master,这个时候他没有相关的cluster数据,这样的话集群的恢复更加容易一些。

2. network相关设置

这一篇内容不多,主要是讲网络相关的设置

  1. network.host: 这个设置了node会bind的ip和publish到别的node的ip
  2. discovery.seed_hosts: join cluster的时候使用的其他的node的ip
  3. http.port: 堆外提供http访问的port
  4. transport.port: 集群node之间使用的tcp通信的端口

其中network.host可以分为两部分
network.bind_host: 绑定的ip,可以有多个
network.publish_host: 往集群中其他node publish的ip,只能有一个

后面可以试验一下,如果直接将network.host 设置为 0.0.0.0会有什么样的效果

2. transport的设置

transport模块用于集群内节点之间的内部通信。从一个节点到另一个节点的每个调用都使用transport模块(例如,当一个节点处理HTTP GET请求,而实际上应由另一个保存数据的节点处理时)。传输模块还用于Elasticsearch Java API中的TransportClient。

传输机制本质上是完全异步的,这意味着没有阻塞线程在等待响应。使用异步通信的好处是首先解决了C10k问题,同时也是分散(广播)/收集操作(例如Elasticsearch中的搜索)的理想解决方案。

transport.port : 默认9300-9400
transport.publish_port : 这个默认情况下和transport.port保持一致,是其他节点请求当前节点时使用的当前node的port,只有在节点使用了代理的时候可能需要特殊配置这个值。
transport.host: transport bind和publish使用的host,默认是network.host
transport.bind_host: 单独设置bind host,默认是 transport.host
transport.publish_host: 单独设置publish host,默认是 transport.host
transport.connect_timeout: 新的connection create的超时时间,默认是30s
transport.compress: 默认是false,在node之间通信的时候进行压缩
transport.ping_schedule: 定时ping以防连接不可用,默认为5s,可以通过设置tcp的keep-alive来更好的保持tcp连接的活性。

参考这里

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#!/bin/sh # Set the name of the primary network interface primary_interface="eth0" # Set the name of the secondary network interface secondary_interface="wlan0" # Set the IP address range of the local network local_network="192.168.1.0/24" primary_interface_table="eth0_table" # Keep running the script indefinitely while true; do # Check if the primary interface is up and connected to the local network if ip addr show $primary_interface up | grep -q $local_network; then # Add a new routing table for the primary interface echo "200 $primary_interface_table" >> /etc/iproute2/rt_tables # Add default route for primary interface to the new routing table primary_gateway=$(ip route show | grep "default" | grep "$primary_interface" | awk '{print $3}') ip route add default via $primary_gateway dev $primary_interface table $primary_interface_table # Add a rule to route all traffic from primary interface through the new routing table primary_ip=$(ip addr show $primary_interface | grep "inet\b" | awk '{print $2}' | cut -d/ -f1) ip rule add from $primary_ip table $primary_interface_table # Remove any existing default route for the secondary interface ip route del default dev $secondary_interface else # Remove any existing routing table for the primary interface existing_table=$(grep -n " $primary_interface_table" /etc/iproute2/rt_tables | cut -f1 -d:) if [ ! -z "$existing_table" ]; then sed -i "${existing_table}d" /etc/iproute2/rt_tables ip route flush table $primary_interface_table ip rule del table $primary_interface_table fi # Add default route for the secondary interface secondary_gateway=$(ip route show | grep "default" | grep "$secondary_interface" | awk '{print $3}') ip route add default via $secondary_gateway dev $secondary_interface fi # Wait for 1 second before checking the network interfaces again sleep 1 done 运行上述脚本,提示ip: RTNETLINK answers: File exists, 请问如何修正
最新发布
05-31

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值