2.2. 套接字绑定
套接字绑定将端点连接器映射到网络接口和端口。默认情况下,Data Grid 服务器包含一个套接字绑定配置,侦听 localhost 接口 127.0.0.1
,用于 REST 和 Hot Rod 端点的端口 11222
。如果启用 Memcached 端点,则默认套接字绑定将 Data Grid Server 配置为绑定到端口 11221
。
默认的套接字绑定
<server xmlns="urn:infinispan:server:13.0"> <socket-bindings default-interface="public" port-offset="${infinispan.socket.binding.port-offset:0}"> <socket-binding name="default" port="${infinispan.bind.port:11222}"/> <socket-binding name="memcached" port="11221"/> </socket-bindings> </server>
配置元素或属性 | 描述 |
---|---|
| 包含所有网络接口和端口的 root 元素,数据网格服务器端点可以绑定和侦听客户端连接。 |
| 声明 Data Grid 服务器默认侦听的网络接口。 |
| 指定 Data Grid Server 适用于套接字绑定的端口声明的偏移。 |
| 配置 Data Grid Server,以绑定到网络接口上的端口。 |
自定义套接字绑定声明
以下示例配置会将名为"private" 的接口
声明添加名为"private"和将 Data Grid Server 绑定到私有 IP 地址的 socket-binding
声明:
XML
<server xmlns="urn:infinispan:server:13.0"> <interfaces> <interface name="public"> <inet-address value="${infinispan.bind.address:127.0.0.1}"/> </interface> <interface name="private"> <inet-address value="10.1.2.3"/> </interface> </interfaces> <socket-bindings default-interface="public" port-offset="${infinispan.socket.binding.port-offset:0}"> <socket-binding name="private_binding" interface="private" port="49152"/> </socket-bindings> <endpoints socket-binding="private_binding" security-realm="default"/> </server>
JSON
{ "server": { "interfaces": [{ "name": "private", "inet-address": { "value": "10.1.2.3" } }, { "name": "public", "inet-address": { "value": "127.0.0.1" } }], "socket-bindings": { "port-offset": "0", "default-interface": "public", "socket-binding": [{ "name": "private_binding", "port": "1234", "interface": "private" }] }, "endpoints": { "endpoint": { "socket-binding": "private_binding", "security-realm": "default" } } } }
YAML
server: interfaces: - name: "private" inetAddress: value: "10.1.2.3" - name: "public" inetAddress: value: "127.0.0.1" socketBindings: portOffset: "0" defaultInterface: "public" socketBinding: - name: "private_binding" port: "49152" interface: "private" endpoints: endpoint: socketBinding: "private_binding" securityRealm: "default"