EMQX 支持导入和导出的数据包括:
- EMQX 配置重写的内容:
- 认证与授权配置
- 规则、连接器与 Sink/Source
- 监听器、网关配置
- 其他 EMQX 配置
- 内置数据库 (Mnesia) 的数据
- Dashboard 用户和 REST API 密钥
- 客户端认证凭证(内置数据库密码认证、增强认证)
- PSK 认证数据
- 授权规则
- 黑名单数据
- 存储在 EMQX 数据目录(
node.data_dir
)中的 SSL/TLS 证书 - 存储在 EMQX 数据目录中的授权 acl.conf 文件
一、进入容器
docker exec -it stand-alone-emqx bash
二、进入bin目录、执行导出命令(找到可执行文件)
emqx@wiat-22:/opt/emqx$ cd bin/
emqx@wiat-22:/opt/emqx/bin$ ls
emqx emqx-5.6.1 emqx.cmd emqx_cluster_rescue emqx_ctl emqx_ctl-5.6.1 emqx_ctl.cmd install_upgrade.escript install_upgrade.escript-5.6.1 no_dot_erlang.boot node_dump nodetool nodetool-5.6.1
#导出命令
emqx@wiat-22:/opt/emqx/bin$ ./emqx ctl data export
Exporting data to "data/backup/emqx-export-2024-06-22-16-09-06.703.tar.gz"...
Exporting cluster configuration...
Exporting additional files from EMQX data_dir: "data"...
Exporting built-in database...
Exporting emqx_authn_mnesia database table...
Exporting emqx_authn_scram_mnesia database table...
Exporting emqx_acl database table...
Exporting emqx_retainer_message database table...
Exporting emqx_admin database table...
Exporting emqx_psk database table...
Exporting emqx_app database table...
Exporting emqx_banned_rules database table...
Exporting emqx_banned database table...
Data has been successfully exported to data/backup/emqx-export-2024-06-22-16-09-06.703.tar.gz.
三、进入backup目录把导出的数据迁移到另一台emqx(在另一台emqx data目录下新建tmp文件夹,把数据放进去)
四、进入21的emqx容器里
# 进入容器
root@wiat-21:/docker/software/stand-alone-emqx# docker exec -it stand-alone-emqx bash
# 进入bin目录
emqx@wiat-21:/opt/emqx$ cd bin/
# 导入命令
emqx@wiat-21:/opt/emqx/bin$ ./emqx ctl data import /opt/emqx/data/tmp/emqx-export-2024-06-22-16-09-06.703.tar.gz
Importing data from "/opt/emqx/data/tmp/emqx-export-2024-06-22-16-09-06.703.tar.gz"...
Importing cluster configuration...
Config key path "authorization.sources.file" was present before import and has been overwritten.
Importing built-in database...
Importing emqx_banned database table...
Importing emqx_banned_rules database table...
Importing emqx_app database table...
Importing emqx_psk database table...
Importing emqx_admin database table...
Importing emqx_retainer_message database table...
Importing emqx_acl database table...
Importing emqx_authn_scram_mnesia database table...
Importing emqx_authn_mnesia database table...
Data has been imported successfully.
五:结果