当前位置:网站首页>Bifrost micro synchronous database implementation services across the library data synchronization
Bifrost micro synchronous database implementation services across the library data synchronization
2022-08-10 05:48:00 【development old man】
Bifrost
Bifrost Various data can be synchronized,类似于 Canal
当前支持的数据库
- Redis
- MongoDB
- ClickHouse(DDL suppoted)
- MySQL(DDL supported)
- Memcache
- RabbitMQ
- ActiveMQ
- Kafka
- ElasticSearch
- Http 自定义服务
- Hprose RPC 自定义服务
使用场景
- in a microservice scenario,Because the database is also split according to business modules,There are some dimension tables in different business logic,Order tables, etc. may be queried across tables in different microservices,此时如果使用 feign Or the data can be obtained through the interface and then combined with the local table to query,When there is a lot of associated data,System query efficiency will be very low,may also fail,A better way at this time is to pass some tables that need to be used in other microservice databases Bifrost Synchronized to this microservice database,The synchronized data table can only be used for query,Data cannot be modified and deleted,确保数据一致性;
- 实现 MySQL 同 Redis、MQ、Kafka The data in the storage is synchronized in real time;
MySQL 同步到 MySQL
The scene here is the general IP1 上的数据库 test 中的 user 表同步到 IP2 on the database test_bifrost 库中的 user 表;
安装/配置
此处通过 Docker 进行安装
拉取镜像
# docker pull jc3wish/bifrost
配置
Create and save configuration and data folders
# mkdir -p /home/data/dockerfile/bifrost
# cd /home/data/dockerfile/bifrost
创建配置文件
# vim Bifrost.ini
[user]
#登 入 用 户 名 和 密 码
#用 户 名 在 前 , = 号 后 面 是 密 码
Bifrost=Bifrost123
BifrostMonitor=Bifrost123
[groups]
#administrator 管 理 人 员 可 以 添 加 删 除 等 操 作
#monitor 只 能 查 看 数 据
Bifrost=administrator
BifrostMonitor=monitor
[Bifrostd]
#log写 到 入 的 文 件 夹 , 默 认 为 启 动 文 件 所 在 文 件 夹 下 的 logs目 录
#log_dir=/data/log/
#监 听 端 口 ,默 认 0.0.0.0:21036
listen=0.0.0.0:21036
#通 过 界 面 配 置 的 信 息 保 存 文 件 夹 ,默 认 为 启 动 文 件 所 在 文 件 夹 下 的 data目 录
data_dir=./
#设 置 同 步 给 第 三 方 服 务 的 队 列 大 小 , 默 认 5000
toserver_queue_size=5000
#通 道 队 列 的 大 小 , 默 认 1000
channel_queue_size=1000
#是 否 支 持 动 态 加 plugin so 插 件 , 默 认 为 false
#这 个 参 数 只 在 linux 下 有 效 , 其 他 平 台 全 部 为 false
dynamic_plugin=false
#是 否 支 持 https
tls=true
#server.key 及 server.crt 相 对 于 Bifrost 的 路 径 , 也 可 以 填 绝 对 路 径
tls_key_file=./etc/server.key
tls_crt_file=./etc/server.crt
#采 用 什 么 方 式 存 储 ,默 认 文 件 方 式
#meta_storage_type=redis
#存 储 介 质 的 连 接 地 址
#meta_storage_path=127.0.0.1:6379
#用 于 区 别 实 例 的 名 字
#cluster_name=bifrostTestClusterName
生成 https 证书
# mkdir etc
# cd etc
# openssl genrsa -out server.key 2048
# openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
生成证书文件:server.crt 和 server.key
运行 Docker
# docker run -d -p21036:21036 -v /etc/localtime:/etc/localtime -v /home/data/dockerfile/bifrost:/linux/data jc3wish/bifrost
端口为 21036
添加 DNS
(named The service has been installed before)
将 bifrost.zsoft.com 到 安装主机IP The parsing was added to named 服务的 zsoft.com.zone 配置文件中,并重启 named 服务;
页面访问
用浏览器访问 https://bifrost.zsoft.com 打开管理页面
用户名、The password is configured in the configuration file:Bifrost / Bifrost123
配置数据同步
Log in to the backend of the web page https://bifrost.zsoft.com
本例实现 IP1 上的 test 库的 user 表同步到 IP2 上的 test_bifrost 库的 user 表;
创建数据源
点击页面上方“数据源”,进入数据源配置页面;
Add new DB:
- Name:user|test|80 // 表示 80 服务器上的 test 数据库的 user 表
- ConnUri:root:[email protected](IP1:3306)/test // IP1 是数据库 test 所在机器的 IP 地址
- 其他不变
点击“提交”
创建目标库
After the data source is created, the system will automatically jump to create“List of target libraries”页(点击页面顶端的“List of target libraries”button to enter this page as well);
Add new Server:
- ToServerKey:user|test_bifrost|82
- Plugin:mysql - v1.7.3
- ConnUri:root:[email protected](IP2:3306)/test_bifrost // IP2 is the server where the target library is located IP
- MinConn:0
- MaxConn:20
- Notes:同步 80 服务器的 test 库的 user 表
点击“提交”
配置数据同步
切换到“数据源”页面,在已经创建好的 user|test|80 The last click on the data source“Setting”按钮;
左侧选择 test 数据库,在中间 Table List 中点击 user 表后的 “ADD” 按钮,点击“保存”,Then click Show user,在右侧进行配置:
- ToServerKey:mysql -- user|test_bifrost|82
- 同步模式:普通模式
- Fields:Tick the columns you want to sync,I check them all here
- 选择数据库:test_bifrost
- 选择表:user
- BatchSize:500
- Null Convert to default value:False
- MustBeSuccess:True
- FilterQuery:False
- FilterUpdate:True
点击“提交”
在“数据源”页面,在配置好的 user|test|80 项的 ConnStatus 中点击“Start”,状态变为“running”;
此时在 IP1 服务器的 test 库的 user 表添加一条数据:
INSERT INTO user values('1004', now(), now(), '赵六','pic04',1);
在 IP2 服务器的 test_bifrost 库的 user You will see in the table that the data has been synchronized!
边栏推荐
猜你喜欢
链读好文:Jeff Garzik 推出 Web3 制作公司
matlab中的常用的类型转换
非会员更改有道云笔记背景
链读精选:星巴克着眼于数字收藏品并更好地吸引客户
ResNet的基础:残差块的原理
【yolov5训练错误】WARNING: Ignoring corrupted image
ORACLE系统表空间SYSTEM占满无法扩充表空间问题解决过程
深度学习中数据到底要不要归一化?实测数据来说明!
tinymce富文本编辑器
The complex "metaverse" will be interpreted for you, and the Link Reading APP will be launched soon!
随机推荐
Link reading good article: What is the difference between hot encrypted storage and cold encrypted storage?
redis常见的面试题
R中设置图形参数--函数par()详解
利用 crontab 拷贝大文件
Chain Reading | The latest and most complete digital collection calendar-07.28
【el和template区别】
Reprint fstream, detailed usage of ifstream
pytorch框架学习(2)使用GPU训练
Collection工具类
链读|最新最全的数字藏品发售日历-07.29
先人一步,不再错过,链读APP即将上线!
Models corresponding to each architecture instruction set
利用PyQt5制作YOLOv5的GUI界面
pytorch框架学习(9)torchvision.transform
转载fstream,ifstream的详细用法
图纸怎么折?(A0,A1,A2,A3の图纸如何折成A4大小)
Mockito基本使用指南
The latest and most complete digital collection sales calendar-07.27
Canal 报错 Could not find first log file name in binary log index file
el-cascader级联选择器的子菜单双击两次才显示被选中的内容