当前位置:网站首页>[Learn Rust together | Advanced articles | RMQTT library] RMQTT message server - installation and cluster configuration
[Learn Rust together | Advanced articles | RMQTT library] RMQTT message server - installation and cluster configuration
2022-08-10 08:12:00 【Guang long yu】
文章目录
RMQTT Broker 简介
RMQTT 是一款完全开源,高度可伸缩,高可用的分布式 MQTT 消息服务器,适用于 IoT、M2M 和移动应用程序,Millions of concurrent clients can be processed on a single service node.
RMQTT 目前支持的操作系统:
- Linux
- macOS
- Windows Server
安装
安装分为zipUnzip installation and source code compilation installation,我们分开介绍.
ZIP 压缩包安装(Linux、MacOS、Windows)
需从 GitHub Release page to get binary packages for the corresponding operating system.
- 从GitHub Release 下载zip包.
$ wget "https://github.com/rmqtt/rmqtt/releases/download/v0.2.3/rmqtt-0.2.3-x86_64-unknown-linux-musl.zip"
- 解压从GitHub Release 下载的zip包.
$ unzip rmqtt-0.2.3-x86_64-unknown-linux-musl.zip -d /app/
- 修改权限
$ cd /app/rmqtt
$ chmod +x bin/rmqttd
- 启动服务
$ cd /app/rmqtt
$ sh start.sh
- 查看服务
$ netstat -tlnp|grep 1883
tcp 0 0 0.0.0.0:1883 0.0.0.0:* LISTEN 3312/./bin/rmqttd
tcp 0 0 0.0.0.0:11883 0.0.0.0:* LISTEN 3312/./bin/rmqttd
创建static集群
基于RAFTA cluster of distributed consensus algorithms
- Prepare three service nodes,Unzip the compressed package to the program directory,比如:/app/rmqtt
- 修改配置文件(rmqtt.toml)
- 设置节点ID, node.id值设置为:1、2或3
- 配置RPC服务端监听端口,rpc.server_addr = “0.0.0.0:5363”
- Starts at the same time when the service starts"rmqtt-cluster-raft"插件
$ cd /app/rmqtt
$ vi etc/rmqtt.toml
##--------------------------------------------------------------------
## Node
##--------------------------------------------------------------------
#Node id
node.id = 1
##--------------------------------------------------------------------
## RPC
##--------------------------------------------------------------------
rpc.server_addr = "0.0.0.0:5363"
##--------------------------------------------------------------------
## Plugins
##--------------------------------------------------------------------
#Plug in configuration file directory
plugins.dir = "./etc/plugins"
#Plug in started by default, when the mqtt server is started
plugins.default_startups = [
"rmqtt-cluster-raft"
# "rmqtt-auth-http",
# "rmqtt-web-hook"
]
- 修改插件配置
$ vi etc/plugins/rmqtt-cluster-raft.toml
##--------------------------------------------------------------------
## rmqtt-cluster-raft
##--------------------------------------------------------------------
#grpc message type
message_type = 198
#Node GRPC service address list
node_grpc_addrs = ["[email protected]:5363", "[email protected]:5363", "[email protected]:5363"]
#Raft peer address list
raft_peer_addrs = ["[email protected]:6363", "[email protected]:6363", "[email protected]:6363"]
- 修改权限&启动服务
$ cd /app/rmqtt
$ chmod +x bin/rmqttd
$ sh start.sh
源码编译安装
安装rust编译环境
以Centos7为例,Skip this process if the build environment already exists.注意:Toolchain required1.56及之后版本,1.59If a connection error is reported in and later versions, the system development environment needs to be upgraded.
安装 Rustup
先打开 Rustup 的官网:https://rustup.rs ,Then download or run the command as prompted.
Linux 下执行:
$ curl https://sh.rustup.rs -sSf | sh
执行source $HOME/.cargo/env 让环境变量生效
$ source $HOME/.cargo/env
- 配置crate.io镜像
可以在$HOME/.cargo/下建立一个config文件,加入如下配置:
$ vi $HOME/.cargo/config
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'tuna'
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"
[net]
git-fetch-with-cli = true
如果tunaAlso too slow to usesjtu或ustcReplace and retry
安装openssl开发包
确保已经安装了openssl的开发包,如果已经安装跳过
For example,
libssl-devon Ubuntu oropenssl-develon Fedora.
CentOS:
$ yum install openssl-devel -y
Ubuntu:
$ apt install pkg-config -y
$ apt-get install libssl-dev -y
编译
- 获取源码
$ git clone https://github.com/rmqtt/rmqtt.git
- 切换到最近的 Tag
$ cd rmqtt
$ git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
- 构建
$ cargo build --release
启动RMQTT Broker
- Copy programs and configuration files
$ mkdir -p /app/rmqtt/bin && mkdir -p /app/rmqtt/etc/plugins
$ cp target/release/rmqttd /app/rmqtt/bin/
$ cp rmqtt.toml /app/rmqtt/etc/
$ cp rmqtt-plugins/*.toml /app/rmqtt/etc/plugins/
$ cp rmqtt-bin/rmqtt.pem /app/rmqtt/etc/
$ cp rmqtt-bin/rmqtt.key /app/rmqtt/etc/
- 修改配置(rmqtt.toml)
- 将plugins.dir = “rmqtt-plugins/” 改为 plugins.dir = “/app/rmqtt/etc/plugins”
- Open the plugin as needed,If the plugin is enabled,可在/etc/plugins/Modify the plugin configuration below
- 如果需要启动TLS,可修改listener.tls.external配置
vi /app/rmqtt/etc/rmqtt.toml
##--------------------------------------------------------------------
## Plugins
##--------------------------------------------------------------------
#Plug in configuration file directory
plugins.dir = "/app/rmqtt/etc/plugins"
#Plug in started by default, when the mqtt server is started
plugins.default_startups = [
# "rmqtt-cluster-raft"
# "rmqtt-cluster-broadcast",
# "rmqtt-auth-http",
# "rmqtt-web-hook"
]
##--------------------------------------------------------------------
## MQTT/TLS - External TLS Listener for MQTT Protocol
listener.tls.external.addr = "0.0.0.0:8883"
listener.tls.external.cert = "/app/rmqtt/etc/rmqtt.pem"
listener.tls.external.key = "/app/rmqtt/etc/rmqtt.key"
- 启动服务
$ cd /app/rmqtt
./bin/rmqttd "./etc/rmqtt.toml"
解决编译失败问题
如果使用1.59version and later toolchains,There may be a problem that the version of the dependent library is too low and the link fails,解决办法:
- 使用1.58version toolchain
#安装1.58版本工具链
$ rustup install 1.58
#Switch the current toolchain to1.58
$ rustup default 1.58
#重新编译
$ cargo build --release
边栏推荐
- Process management (dynamic)
- 图像处理用什么神经网络,神经网络提取图片特征
- 机器人控制器编程实践指导书旧版-实践二 传感器(模拟量)
- 概率分布及其应用
- 全连接神经网络结构图,神经网络示意图怎么画
- 人工神经网络模型的特点,人工神经网络模型定义
- CV+Deep Learning - network architecture Pytorch recurrence series - classification (3: MobileNet, ShuffleNet)
- MySQL database monthly growth problem
- 【Unity入门计划】制作RubyAdventure03-使用碰撞体&触发器实现世界交互
- VMware ESX Server常用命令行
猜你喜欢

明明加了唯一索引,为什么还是产生重复数据?

机器人控制器编程实践指导书旧版-实践一 LED灯(数字量)

神经网络的三种训练方法,神经网络训练全过程

预测股票涨跌看什么指标,如何预测明天股票走势

ATH10 sensor reads temperature and humidity

iwemeta元宇宙:一个娃娃卖9999元,泡泡玛特认为一点也不贵

浅谈C语言整型数据的存储

张驰课堂:老板会武术,谁也挡不住!六西格玛培训的魅力

DGIOT supports industrial equipment rental and remote control

2022-08-01 Advanced Network Engineering (23) Advanced VLAN Technology - VLAN Aggregation, MUX VLAN
随机推荐
解决win10win7win8系统找不到指定的模块,注册不了大漠插件的问题
每日一题,数组字符串的匹配问题
FFT模板
[In-depth study of 4G/5G/6G topic-56]: L3 signaling control-5-radio bearer management
【Unity入门计划】制作RubyAdventure03-使用碰撞体&触发器实现世界交互
navicat for mysql 连接时报错:1251-Client does not support authentication protocol requested by server
Uni applet Tencent map polygon background transparency
卷积神经网络卷积层公式,卷积神经网络运算公式
Introduction to the C language to realize bubble sort
Add spark related dependencies and packaging plugins (sixth bullet)
概率分布及其应用
预测股票涨跌看什么指标,如何预测明天股票走势
问下cdc mysql to doris.不显示具体行数,怎么办?
人工神经网络模型的特点,人工神经网络模型定义
2022-08-01 Advanced Network Engineering (23) Advanced VLAN Technology - VLAN Aggregation, MUX VLAN
foreach遍历删除元素问题总结
NPU架构与算力分析
SQL建表问题,帮我看看好吗朋友们~大家人。!
幂函数 指数函数 对数函数
PLSQL学习第四天