Files
elasticsearch/docs/配置/网络.md
2022-09-14 10:22:53 +00:00

105 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 网络
每个ES节点有两个不同的网络通信接口
- 客户端通过节点的9200端口使用 Elasticsearch REST API 通信,称为 http interface
- 集群节点间的是通过9300端口称为 transport interface它也可以用于集群之间的通讯集群与集群的通讯 remote clusters
如果在一个简单的网络中,可以直接使用 network.* 这类配置同时设置 http interface 和 transport interface
默认地Elasticsearch 监听本地的 localhost 地址,不能被远程访问,表示在本地开发环境。为了组成多节点集群,或被远程客户端访问,需要调整监听的网络配置,包括 network.host 参数。
> 注意网络配置,永远不要把未保护/未认证的节点暴露在互联网上。如果这样互联网任意的人都可以下载修改删除ES中的数据。
## 基本网络设置
```yaml
# 同时配置 http interface 和 transport interface 的网络监听地址
# 默认值是_local_表示任意操作系统上的环回地址表示仅本地访问
network.host: _local_
# http interface通信端口可以设置成单个值或范围如果是范围那么就是起始值
# 默认值是9200-9300
http.port: 9200-9300
# transport interface 通讯端口可以设置成单个值或范围如果是范围那么就是起始值在master节点上要设置成单个值
# 默认值是9300-9400
transport.port: 9300-9400
```
## 绑定和发布
Elasticsearch 使用网络接口地址有不同的目的binding 和 publishing 大多数场景不区分这两者,但是复杂场景对这两者有不同的目的和不同的配置。
当一个应用比如ES需要收网络通讯报文它需要向操作系统通知从哪个/哪些网络接口接收,这个/这些接口就叫 binding addressesES通常可以绑定多个网络接口但通常都是一个。如果有必要的话可以使得 http interface和 transport interface分别绑定不同的接口。
每个节点间和客户端之间的通讯也有一个地址这个就叫发布地址。每个节点只能有一个http interface publishing address/ transport publishing interface 这个地址可以是任意值不一定非要是运行ES的操作系统上的IP的值比如在代理场景中。
## 单个地址
最简单的就是单个地址的方式,使用 network.host 指明地址就好,
## 多个地址
```yaml
network.bind_host
network.publish_host
```
## 高级TCP设置
## 高级HTTP设置
```yaml
# HTTP interface通信的地址
# 默认等于network.host设置的值
http.host: network.host
http.bind_host
http.publish_host
http.publish_port
```