背景
为了让mongodb能使用标准化的sql语句查询,我们使用官方的mongo-bi做一层转换,这一步是统一数仓的关键。
目前该方案不具可行性,原因:
- bi-connect连接mongodb数据源必须开启ssl,这就导致外部客户端连接bi-connect必须useSSL=true,而StarRocks的catalogs未支持SSL
- 不稳定,从BI的外连接看,经常报错
下载安装
bi-connector支持不同平台安装部署,这里针对Linux环境安装部署配置进行记录。
通过官网下载:https://www.mongodb.com/try/download/bi-connector
我这里下载的文件版本为mongodb-bi-linux-x86_64-rhel70-v2.14.12.tgz
下载后解压到/opt/mongodb-bi目录
创建证书
当MongoDB启用认证时,bi-connector必须要配置使用证书,才能通过bi-connector连接mongodb
这里先创建证书
1 2 3 4 5
| #执行创建 SSL 证书 mkdir -p /opt/mongodb-bi/certs cd /opt/mongodb-bi/certs openssl req -nodes -newkey rsa:2048 -keyout dakeweBI.key -out dakeweBI.crt -x509 -days 365 -subj "/C=US/ST=dakeweBI/L=dakeweBI/O=dakeweBI Security/OU=IT Department/CN=kayakwise.com" cat dakeweBI.crt dakeweBI.key > dakeweBI.pem
|
安装 MongoDB BI Connector
1
| sudo install -m755 bin/mongo* /usr/bin/
|
配置 MongoDB BI 配置文件
1 2 3
| mkdir -p /opt/mongodb-bi/conf/ mkdir -p /opt/mongodb-bi/logs/ mkdir -p /opt/mongodb-bi/schemas
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| net: bindIp: "0.0.0.0" port: 3307 ssl: mode: allowSSL PEMKeyFile: '/opt/mongodb-bi/certs/dakeweBI.pem' allowInvalidCertificates: true minimumTLSVersion: TLS1_0 mongodb: net: uri: "mongodb://192.168.103.113:27011" ssl: enabled: false auth: username: root password: 'XXX' source: admin mechanism: SCRAM-SHA-1 security: enabled: true defaultMechanism: "SCRAM-SHA-1" defaultSource: "admin" systemLog: path: /opt/mongodb-bi/logs/mongosqld.log verbosity: 2 logAppend: true schema: path: /opt/mongodb-bi/schemas maxVarcharLength: 65535 processManagement: service: name: "mongosql" displayName: "MongoSQL Service" description: "MongoSQL accesses MongoDB data with SQL"
|
安装 MongoDB BI Connector 服务
1 2 3 4 5
| mongosqld install --config /opt/mongodb-bi/conf/mongosqld-config.yml #重新加载 systemctl daemon-reload #设置开机自启 systemctl enable mongosql.service
|
启动
1 2 3 4 5 6
| #执行生成 schema mongodrdl --host 192.168.103.113:27011 --username root --password XXX --db assistant --authenticationDatabase admin --authenticationMechanism SCRAM-SHA-1 --out /opt/mongodb-bi/schemas/schemas.drdl # 临时启动 mongosqld --config=/opt/mongodb-bi/conf/mongosqld-config.yml # 常驻启动 systemctl start mongosql.service
|
连接查询
其他相关命令
1 2 3 4 5 6 7 8 9 10 11
| systemctl start mongosql.service systemctl status mongosql.service systemctl stop mongosql.service systemctl disable mongosql.service journalctl -u mongosql.service rm /etc/systemd/system/mongosql.service rm /etc/systemd/system/mongosql.service rm /usr/lib/systemd/system/mongosql.service rm /usr/lib/systemd/system/mongosql.service systemctl daemon-reload systemctl reset-failed
|