greed _1998
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
      • No invitee
    • Publish Note

      Publish Note

      Everyone on the web can find and read all notes of this public team.
      Once published, notes can be searched and viewed by anyone online.
      See published notes
      Please check the box to agree to the Community Guidelines.
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
No invitee
Publish Note

Publish Note

Everyone on the web can find and read all notes of this public team.
Once published, notes can be searched and viewed by anyone online.
See published notes
Please check the box to agree to the Community Guidelines.
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# MongoDBとTableauの連携方法 ## MongoDBとは NoSQLに分類される、ドキュメント指向データベースである。従来のRDBMSのように固定されたスキーマを持つのではなく、JSONのような構造的データ(ドキュメント)の集合をコレクションとして管理する。 | RDBMS | MongoDB | | -------- | ------------ | | テーブル | コレクション | | レコード | ドキュメント | ### [MongoDB Atlas](https://www.mongodb.com/ja-jp/atlas/database) MongoDBの開発元が直接提供するサービスであり、自前でMongoDBサーバ上にインストールすることなく、クラウドで使い始められるサービス。AWS, Azure, GCPの中から選んでクラスタをデプロイすることができる。 ここで言うクラスタとは、複数台のMongoDBインスタンスのまとまりを意味している。Atlasを使えば、ユーザはUI上でレプリケーションの台数、シャーディングの台数を選ぶだけで、簡単に冗長構成のMongoDBを利用できる。 #### プランの選択方法 大まかに以下の[三つのプラン](https://www.mongodb.com/pricing)がある。 - Serverless 事前にリソースをプロビジョニングすることなく、使った分だけ課金される。 - Dedicated 専用のサーバを確保でき、最も高機能である。使った時間に応じて課金される。 - Shared 共用のサーバ上で動く。Dadicated同様に時間課金制だが無料プランもある。 このうち下二つのプランでは、クラスタのグレード(Cluster Tier)を選ぶことができる。M○○の記号で表されており、〇〇の数字が大きいほど高額になるが、処理速度が向上し機能も充実する。DedicatedではM10~M700, SharedではM0~M5から選択できる。 ServerlessプランはまだPreview段階であり、[Tableauとの連携機能は使うことができない。](https://www.mongodb.com/docs/atlas/tutorial/connect-bic-tableau/#:~:text=Serverless%20instances%20are%20in%20preview%20and%20do%20not%20support%20this%20feature%20at%20this%20time.)また、Tableau機能を用いるために必要なBI Connector(後述)は[M10以上のクラスタのみで利用可能である](https://www.mongodb.com/docs/atlas/tutorial/connect-bic-tableau/#:~:text=The%20MongoDB%20Connector%20for%20Business%20Intelligence%20for%20Atlas%20(BI%20Connector)%20is%20only%20available%20for%20M10%20and%20larger%20clusters.)ため、今回はDedicatedプランの中からいずれかを選択する必要がある。DedicatedのM10クラスタは $0.08/時間($57/月)である。 ### [MongoDB Connector for BI](https://www.mongodb.com/ja-jp/products/bi-connector) (BI Connector) BIとは、Business Intelligenceの略である。Business Intelligenceとは、膨大な業務データを収集して分析し、その結果を可視化する仕組みのことである。そのようなツールを「BIツール」と呼ぶ。 Tableauを含む伝統的なBIツールは、SQLによって表形式のDBに対して使えるようにデザインされているため、NoSQLのMongoDBで用いるためには、BIツールの発行したSQLクエリをMongoDBクエリに変換する必要がある。これをMongoDB Connector for BIが担う。 BI Connectorの利用料金は、[クラスタの利用料金に追加で請求される。](https://www.mongodb.com/docs/atlas/billing/cluster-configuration-costs/?_ga=2.220428888.1519342913.1650884548-151388828.1650884548#bic)請求額についてはコンソールから確認できる。 Atlas上のクラスタでBI Connectorを使用する場合、M10, M20クラスタでは性能低下が現れる可能性があり、これを避けるには[M30へのアップグレードが推奨されている。](https://www.mongodb.com/docs/atlas/tutorial/connect-bic-tableau/#:~:text=Given%20the%20limited%20hardware%20resources%20on%20M10%20and%20M20%20cluster%20tiers%2C%20you%20may%20experience%20performance%20degradation%20of%20the%20cluster%20when%20enabling%20the%20BI%20Connector.%20If%20this%20occurs%2C%20upgrade%20to%20an%20M30%20or%20larger%20cluster) ## Tableauとは  Tableauとは、組織のデータを最大限活用することを可能にするビジュアル分析プラットフォームである。データの探索・管理を簡単に行うことができる。([参考](https://www.tableau.com/ja-jp/why-tableau/what-is-tableau)) Tableau 〇〇と言う名前の製品は複数存在する。 - Tableau Desktop ローカルのPCでデータ分析、可視化を行うツール。インストールして使う。 - Tableau Server 自社サーバにインストールして用いる。画面を編集することは可能だが、Tableau Desktopと比べて機能が制限されているため、Tableau Desktopで作成した画面を複数人で共有しブラウザ経由で閲覧する用途に用いることが多い。 - Tableau Online Tableauのクラウドサービス。Tableau ServerのSaaS版。自社でサーバ管理する必要がない。 - Tableau Reader 閲覧のみ。PCにインストールして無料で利用できる。 今回はTableau DesktopをローカルPCにダウンロードし、MongoDBとの連携を進める。 ## MongoDB Atlasの初期設定([参考](https://www.mongodb.com/docs/atlas/getting-started/)) ### Atlasアカウントの作成 [こちら](https://www.mongodb.com/docs/atlas/tutorial/create-atlas-account/)を参考に、Atlasアカウントを作成します。 * Google アカウントを用いた登録 * メールアドレスを用いた登録 のいずれかで登録を行います。登録完了後に、組織(Organization)とプロジェクト(Project)を作成しましょう。([参考1](https://www.mongodb.com/docs/atlas/tutorial/manage-organizations/#std-label-create-organization), [参考2](https://www.mongodb.com/docs/atlas/tutorial/manage-projects/#std-label-create-project)) ### ネットワークの設定 [こちら](https://www.mongodb.com/docs/atlas/security/add-ip-address-to-list/)を参考にして、Atlasにアクセス可能なIPアドレスを設定します。 ![](https://i.imgur.com/hgLYQp8.png) ### DBユーザの作成([参考](https://www.mongodb.com/docs/atlas/tutorial/create-mongodb-user-for-cluster/)) DBにアクセスするためのユーザを作成します。 ![](https://i.imgur.com/wOzVWUC.png) 今回は認証方式をパスワード方式とします。 ![](https://i.imgur.com/MPrh2nH.png) ここで設定したパスワードは後ほど用いるため忘れないようにしましょう。 また、今回ユーザの権限は「Read and write to any database」にしました。Tableauと連携したいDBにはreadとwriteの権限を持たせましょう。 ![](https://i.imgur.com/BLrLGg5.png) ### Clusterの立て方 ![](https://i.imgur.com/eZTkxD7.png) ![](https://i.imgur.com/8q2lKg7.png) ![](https://i.imgur.com/YxOkLmQ.png) ![](https://i.imgur.com/Pcf4nyN.png) 以上の設定が終わると、右下の「Create Cluster」ボタンを押します。 クラスタ名はあとで変更できないので、慎重に決めましょう。 請求情報を入力すると、Clusterの作成が始まります。(Clusterの作成には数分かかることがあります。) ### MongoDB BI Connctorの設定 ダッシュボードから、以下のようにクラスタ名の横のメニューから、Edit Configurationを開きます。 ![](https://i.imgur.com/lun0Z3V.png) Configurationの中から、Additional Configurationを開きます。 ![](https://i.imgur.com/BMeHPwj.png) Additional Configuration内の、Enable Business Intelligence Connectorを有効にします。この際に、Sample Reflesh Intervalの値を忘れずに設定する必要があります。これは、MongoDBがデータを自動でサンプリングしてスキーマ情報を作成する頻度の設定であり、0以外の値を設定する必要があります。([参考](https://www.mongodb.com/docs/bi-connector/current/reference/mongosqld/#std-option-mongosqld.--schemaRefreshIntervalSecs))今回は600秒(10分)としています。 ![](https://i.imgur.com/Y82P8uS.png) ### Tableauとの連携に必要な情報を取得 ![](https://i.imgur.com/G8bv6wl.png) ![](https://i.imgur.com/XDymvNJ.png) ![](https://i.imgur.com/swAKH7Z.png) ここに表示されている情報をTableau Desktop側で入力することで、データを連携することが可能になります。 ## Tableau Desktop の初期設定 [ここ](https://www.tableau.com/products/desktop)からTableau Desktopをダウンロードし、インストールする Tableau Desktopの画面上で「接続」の中から「MongoDB BI Connector」を選ぶ ![](https://i.imgur.com/PELndQt.png) ここで使っているデスクトップPCのOSごとに異なるドライバのインストールを求められるので、指示に従ってインストールする。 ![](https://i.imgur.com/t9fFg6i.png) ドライバをインストールすると、再度「接続」の中から「MongoDB BI Connector」を選んだ時に接続用の画面が表示されるようになる。 ## Tableau Desktop との連携方法 ([参考](https://help.tableau.com/current/pro/desktop/ja-jp/examples_mongodb.htm)) 接続方法の中からMongoDB BI コネクターを選択すると、接続用の画面が表示されます。ここに先ほどMongoDB Atlasで得たHostNameをサーバ欄に、Portをポート欄に、接続したいデータベース名をデータベース欄に、Userをユーザ名の欄に入力し、入力したユーザのパスワードをパスワード欄に入力します。 ![](https://i.imgur.com/HlFJ1PY.png) 入力した状態に間違いがなければ、以下のような画面に遷移します。これで連携が完了です。 ![](https://i.imgur.com/azmm7vM.png) ### エラー例 以下のようなエラーが出た場合、Atlas上でMongoDB BI ConnectorのSample Reflesh Intervalの設定が間違っている、または設定したばかりのためインターバルの時間が経過していない可能性があります。 ![](https://i.imgur.com/yki6CGl.png) ## まとめ・考察・その他 - Tableau Desktop との連携方法で検索すると、[MongoDB公式のTableau Desktopとの連携方法のドキュメント](https://www.mongodb.com/docs/bi-connector/current/connect/tableau-auth/#std-label-connect-tableau-auth)もヒットする。しかしながら、この手順でダウンロードすることになる[MongoDB公式レポジトリのODBCドライバ](https://github.com/mongodb/mongo-bi-connector-odbc-driver/releases/)の最新版は、最新のMacOS上では動作しない。(これはMongoDB Atlasのチャットサポートから問い合わせて確認済み。) - [Tableauの公式ドキュメント](https://help.tableau.com/current/pro/desktop/ja-jp/examples_mongodb.htm)ではMongoDB公式と違った方法が提案されており、こちらを試すと結果的にうまくいった。 - [BIコネクタの設定](https://hackmd.io/0SFeSMtITKq7fqHhu9b5aA?both#MongoDB-BI-Connctor%E3%81%AE%E8%A8%AD%E5%AE%9A)の際に設定した、Sample Reflesh Intervalの値を設定するところが一番のハマりポイント。連携方法の公式ドキュメントやさまざまなブログ等を見ても、この項目が重要であることが書かれていない。しかも、エラー内容が[上記エラー例](https://hackmd.io/0SFeSMtITKq7fqHhu9b5aA?both#%E3%82%A8%E3%83%A9%E3%83%BC%E4%BE%8B)の通り、権限がないというニュアンスで出てくるためタチが悪い。

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template is not available.
Upgrade
All
  • All
  • Team
No template found.

Create custom template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

How to use Slide mode

API Docs

Edit in VSCode

Install browser extension

Get in Touch

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Upgrade to Prime Plan

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

No updates to save
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully