This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 167
RSocket Broker Gossip
linux_china edited this page Apr 29, 2021
·
1 revision
主要是介绍一下如何在阿里云上部署一个RSocket Broker Gossip集群。
- 接入需要安全验证
- RSocket Broker集群能从互联网访问,方便办公、合作伙伴能够接入
- 数量: 2,最好是3台ECS组合为一个集群,2台是最低配置
- 操作系统:Ubuntu 20.04
- 硬件配置: 请根据实际的业务情况镜像调整,建议内存要在8G+
- 交换机: 最好将RSocket Broker放在独立的交换机下,方便后续的安全控制
- 外部IP关联(EIP): 假设IP地址为 139.196.223.1和139.196.223.2
- 安全组:允许来自互联网的 9999 端口访问
ECS实例启动后,登录到ECS服务器进行进行对应的环境设置:
- 调用iptables命令运行以下端口访问
iptables -A INPUT -p tcp --dport 9997 -j ACCEPT
iptables -A INPUT -p tcp --dport 9998 -j ACCEPT
iptables -A INPUT -p tcp --dport 9999 -j ACCEPT
iptables -A INPUT -p tcp --dport 42254 -j ACCEPT
- 安装Java运行环境
apt update
apt upgrade
apt install openjdk-8-jdk
- 设置Alibaba RSocket Broker应用需要的环境变量:
export RSOCKET_BROKER_EXTERNAL_DOMAIN="139.196.223.1"
export RSOCKET_BROKER_AUTH_REQUIRED="true"
export RSOCKET_BROKER_TOPOLOGY="gossip"
export RSOCKET_BROKER_SEEDS="172.27.166.1,172.27.166.2"
注意:请不要搞错ECS实例绑定外部IP地址。
- JWT安全验证
由于我们开启了RSocket Broker的安全验证, 我们需要需要将jwt_rsa.key 和 jwt_rsa.pub 两个文件拷贝到所有ECS实例登录用户的~/.rsocket目录下。
这两个文件的生成步骤如下:
# generate a 2048-bit RSA private key
$ openssl genrsa -out jwt_private_key.pem 2048
# convert private Key to PKCS#8 format (so Java can read it)
$ openssl pkcs8 -topk8 -inform PEM -outform DER -in jwt_private_key.pem -out jwt_rsa.key -nocrypt
# output public key portion in DER format (so Java can read it)
$ openssl rsa -in jwt_private_key.pem -pubout -outform DER -out jwt_rsa.pub
接下来就是将alibaba-rsocket-broker.jar拷贝到所有的ECS实例上,然后执行:
java -jar alibaba-rsocket-broker.jar &
注意:根据你的ECS配置,设置好对应的JAVA_OPTS。
最简单的方法就是clone https://github.com/alibaba-rsocket-broker/rsocket-broker-simple-example
然后调整一下application.properties文件配置即可,如下:
rsocket.brokers=tcp://139.196.223.1:9999,tcp://139.196.223.2:9999
### Please fill jwt-token for production env
rsocket.jwt-token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.xxxx.yyyy
- Binary: byte stream
- Async message
- Multi transports
- Reactive Semantics
- request/response
- request/stream
- fire-and-forget
- channel
- TCP+TLS
- WebSocket+TLS
- UDP(Aeron)
- RDMA