Mongo Connector for BI 的安装与链接以及注意事项

大数据~~MongoDB 专栏收录该内容
13 篇文章 0 订阅

官网地址:https://www.mongodb.com/products/bi-connector

它目前包含两个组件:

  1. mongosqld:mongosqld接受来自SQL客户端的传入请求,并将这些请求代理到mongod或mongos实例。
  2. mongodrdl: 根据一个或多个MongoDB的集合(collection,类似于表),生成一个Schema,交将它写入.drdl文件中

 


安装

安装包下载地址:https://www.mongodb.com/download-center#bi-connector,可以下载不同系统平台的安装包

 

windows:

安装完成后,安装目录的文件,里面会有两个可执行文件,mongosqld.exe和mongodrdl.exe,分别对应它两个组件mongosqld和mongodrdl

 

Linux系统的安装是将文件下载至服务器,并使用命令安装已经下载的软件包 

 

1:生成DRDL 文件

mongodrdl

命令行参数参考官网地址:https://docs.mongodb.com/bi-connector/current/reference/mongodrdl/

 

 

在命令行中生成drdl

mongodrdl --host localhost --port 27017 --db tqsapi

 

 

将drdl文件保存至指定的地址

mongodrdl --host localhost --port 27017 --db tqsapi --out d:\demo.drdl

 

 

mongodrdl连接至mongo atlas,首先需要找到mongo atlas的所有服务器,参考地址:https://stackoverflow.com/questions/42891840/generating-drdl-file-for-mongodb-atlas-for-use-with-mongodb-bi-connector

命令如下,

--host对应到服务器的IP和端口,

-u对应到授权的用户

-p对应到授权的用户密码

-d对应到DB名称

--ssl --authenticationDatabase=admin 暂时不知道意义

mongodrdl --host 服务器1:27017,服务器2:27017,服务器3:27017 -u weschen -p 123456789 --ssl --authenticationDatabase=admin -d tqsapi

 

 

连接至远程集群中的所有服务器,发现是不可用的,错误地址:https://stackoverflow.com/questions/46499140/no-servers-available-mongodb-generating-schema-definition-file

mongodrdl --host 服务器1:27017,服务器2:27017,服务器3:27017 -u weschen -p 123456789 --ssl --authenticationDatabase=admin -d tqsapi --out d:\test.drdl

 

 

2:运行mongosqld

mongosqld也可以与mongodrdl配合使用,mongodrdl生成.drdl文件,而mongosqld直接使用该文件生成schema ,官风应该是可行的,在本机一直在等待,没有回应

mongosqld --schema d:\demo.drdl 

3:example-mongosqld-config.yml配置文件

## This is a example configuration file for mongosqld.

## The full documentation is available at:
## https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#configuration-file

## Network options - configure how mongosqld should accept connections.
## https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#network-options
net:
  bindIp: "0.0.0.0" # To bind to multiple IP addresses, enter a list of comma separated values.
  port: 3307
  # unixDomainSocket:
  #   enabled: false
  #   pathPrefix: "/var"
  #   filePermissions: "0600"
  ssl:
    mode: "disabled"
    # allowInvalidCertificates: false
    # PEMKeyFile: <string>
    # PEMKeyPassword: <string>
    # CAFile: <string>
    # minimumTLSVersion: TLS1_1

## MongoDB options - configure how mongosqld should connect to your MongoDB cluster.
## https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#mongodb-host-options
mongodb:
  # versionCompatibility: <string>
  net:
    uri: "mongodb://localhost:27017" # https://docs.mongodb.com/manual/reference/connection-string/#mongodb-uri
    ssl:
      enabled: false
    ## https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#mongodb-tls-ssl-options
    #   allowInvalidCertificates: false
    #   allowInvalidHostnames: false
    #   PEMKeyFile: <string>
    #   PEMKeyPassword: <string>
    #   CAFile: <string>
    #   CRLFile: <string>
    #   FIPSMode: false
    #   minimumTLSVersion: TLSv1_1
    # auth:
    #   username: <string>
    #   password: <string>
    #   source: <string> # This is the name of the database to authenticate against.
    #   mechanism: SCRAM-SHA-1
    #   gssapiServiceName: mongodb

# Security options - configure mongosqld's authentication (disabled by default).
## Enable security options if your MongoDB cluster requires authentication.
## https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#security-options
# security:
#   enabled: <boolean>
#   defaultMechanism: "SCRAM-SHA-1"
#   defaultSource: "admin"
#   gssapi:
#     hostname: <string>
#     serviceName: "mongosql"

## Logging options
## https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#logging-options
systemLog:
  ## The path to the file where log output will be written to.
  ## Defaults to stderr.
  # path: <string>
  quiet: false
  ## 0|1|2 - Verbosity of the log output, this is overridden if `quiet` is true.
  verbosity: 1
  # logAppend: false
  logRotate: "rename" # "rename"|"reopen"

## Schema options
## These configuration options define how the mongosqld should sample your MongoDB
## data so that it can be used by the relational application.
## https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#data-sampling-options
schema:
  ## If you've generated a DRDL schema file using mongodrdl, you can supply the
  ## path for mongosqld to use that schema DRDL file.
  # path: <string>
  # maxVarcharLength: <integer>
  sample:
    mode: "read" # "read"|"write"
    size: 1000 # The amount of random documents we sample from each collection.
    namespaces: ["*.*"]
    ## Use the `refreshIntervalSecs` option to specify an interval in seconds for
    ## mongosqld to resample data and regenerate the schema. The default value for
    ## this option is 0, which means that mongosqld does not automatically resample data.
    refreshIntervalSecs: 0
    # prejoin: false
    # uuidSubtype3Encoding: "old" # <[old|csharp|java]>

## Process management options
## https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#process-management-options
processManagement:
  service:
    name: "mongosql"
    displayName: "MongoSQL Service"
    description: "MongoSQL accesses MongoDB data with SQL"

## Runtime options
## https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#runtime-options
# runtime:
#   memory:
#     ## A value of `0` indicates there is no enforced maximum.
#     maxPerStage: 0
#     maxPerServer: 0
#     maxPerConnection: 0

 

4:程序配置

在配置文件中写入相应的配置  使用过程中和Mysql一样

 
spring.datasource.driver-class-name=com.mysql.jdbc.Driver 

spring.datasource.url=jdbc:mysql://192.168.1.212:3307?source=test&mechanism=PLAIN&useSSL=false&authenticationPlugins=org.mongodb.mongosql.auth.plugin.MongoSqlAuthenticationPlugin


port=8088
 


5:注意事项

    1:安装的BI 要与mongoserver数据库在同一台机子上

    2:BI的配置文件将bindIp 修改为0.0.0.0

   3: 生成drdl的时候  如果mongo数据库有身份权限验证 不能使用管理员生成文件 要用普通用户 角色为dbOwer

  4: 启动mongosqd的时候会默认加载example-mongosqld-config.yml配置文件  需要修改配置选项在里面修改即可

 

 

 

 

 

  • 0
    点赞
  • 2
    评论
  • 2
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

相关推荐
©️2020 CSDN 皮肤主题: 书香水墨 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值