前置作業,安裝PostgreSQL,此次安裝版本為10.9。

  1. sudo apt-get install m4,安裝 m4
  2. sudo apt-get install autoconf,安裝autoconf
  3. sudo apt-get install automake,安裝automake
  4. sudo apt-get install libtool,安裝libtool
  5. sudo apt-get install pkg-config,安裝pkg-config

安裝 libbson

  1. git clone -b r1.4 https://github.com/mongodb/libbson
  2. cd libbson
  3. git checkout 1.3.1
  4. ./autogen.sh
  5. make && sudo make install

安裝mongo-c

  1. wget https://github.com/mongodb/mongo-c-driver/releases/download/1.6.2/mongo-c-driver-1.6.2.tar.gz
  2. tar xzf mongo-c-driver-1.6.2.tar.gz
  3. cd mongo-c-driver-1.6.2
  4. ./configure disable-automatic-init-and-cleanup
  5. make && sudo make install

安裝json-c

  1. git clone https://github.com/json-c/json-c.git
  2. cd json-c
  3. sh autogen.sh
  4. ./configure
  5. sudo make install
  6. make check
  7. make USE_VALGRIND=0 check

Mongo_FDW

  1. git clone https://github.com/EnterpriseDB/mongo_fdw.git
  2. cd mongo_fdw
  3. sudo bash autogen.sh --with-master,執行autogen.sh 選擇with-master 參數
  4. make && sudo make install
  5. sudo ldconfig ,重新載入設定

於PostgreSQL建立mongo_fdw 擴充功能

  1. sudo -u postgres psql
  2. 輸入CREATE EXTENSION mongo_fdw;

後記:

先前在Ubuntu16 上安裝mongo_fdw 時,很多套件在設定時會遇到問題,這次除了libbson 還是安裝較舊的版本,其他套件都是取最新版來安裝,建議直接在Ubunu18 來安裝mongo_fdw,可以省下很多設定上除錯的時間。

Jason Fang

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store