CouchDB - 安裝



本章將教你如何在 Windows 和 Linux 系統中安裝 CouchDB。

在 Windows 中安裝 CouchDB

下載 CouchDB

CouchDB 的官方網站是 https://couchdb.apache.org。如果您點選提供的連結,您可以獲得 CouchDB 官方網站的首頁,如下所示。

Download CouchDB

如果您點選下載按鈕,將跳轉到一個頁面,其中提供了各種格式的 CouchDB 下載連結。以下快照說明了這一點。

CouchDB Formats

選擇 Windows 系統的下載連結,並選擇提供的映象之一開始下載。

安裝 CouchDB

CouchDB 將以名為 setup-couchdb-1.6.1_R16B02.exe 的安裝檔案形式下載到您的系統中。執行安裝檔案並繼續安裝。

安裝完成後,透過訪問以下連結:http://127.0.0.1:5984/ 開啟 CouchDB 的內建 Web 介面。如果一切順利,這將為您提供一個網頁,其中包含以下輸出。

{
   "couchdb":"Welcome","uuid":"c8d48ac61bb497f4692b346e0f400d60",
   "version":"1.6.1",
   "vendor":{
      "version":"1.6.1","name":"The Apache Software Foundation"
   }
}

您可以使用以下 URL 與 CouchDB Web 介面進行互動:

http://127.0.0.1:5984/_utils/

這將顯示 Futon 的索引頁面,Futon 是 CouchDB 的 Web 介面。

Web Interface

在 Linux 系統中安裝 CouchDB

對於許多 Linux 發行版系統,它們在內部提供了 CouchDB。要安裝此 CouchDB,請按照說明操作。

在 Ubuntu 和 Debian 上,您可以使用:

sudo aptitude install couchdb

在 Gentoo Linux 上,有一個 CouchDB ebuild 可用:

sudo emerge couchdb

如果您的 Linux 系統沒有 CouchDB,請按照下一節安裝 CouchDB 及其依賴項。

安裝 CouchDB 依賴項

以下是要在系統中獲取 CouchDB 需要安裝的依賴項列表:

  • Erlang OTP
  • ICU
  • OpenSSL
  • Mozilla SpiderMonkey
  • GNU Make
  • GNU 編譯器集合
  • libcurl
  • help2man
  • Python 文件
  • Python Sphinx

要安裝這些依賴項,請在終端中鍵入以下命令。這裡我們使用的是 Centos 6.5,以下命令將安裝與 Centos 6.5 相容的所需軟體。

$sudo yum install autoconf
$sudo yum install autoconf-archive
$sudo yum install automake
$sudo yum install curl-devel
$sudo yum install erlang-asn1
$sudo yum install erlang-erts
$sudo yum install erlang-eunit
$sudo yum install erlang-os_mon
$sudo yum install erlang-xmerl
$sudo yum install help2man
$sudo yum install js-devel
$sudo yum install libicu-devel
$sudo yum install libtool
$sudo yum install perl-Test-Harness

注意:對於所有這些命令,您需要使用 sudo。以下過程將普通使用者轉換為 sudoer。

  • 以管理員使用者的 root 身份登入

  • 使用以下命令開啟sudo檔案:

visudo
  • 然後按如下所示進行編輯,以授予您現有的使用者 sudoer 許可權:
Hadoop All=(All) All , and press esc : x to write the changes to the file. 

在系統中下載完所有依賴項後,請按照提供的說明下載 CouchDB。

下載 CouchDB

Apache 軟體基金會不會提供 CouchDB 的完整 .tar 檔案,因此您必須從原始碼安裝它。

建立一個新目錄來安裝 CouchDB,瀏覽到此建立的目錄並透過執行以下命令下載 CouchDB 原始碼:

$ cd
$ mkdir CouchDB
$ cd CouchDB/
$ wget
http://www.google.com/url?q=http%3A%2F%2Fwww.apache.org%2Fdist%2Fcouchdb%2Fsource%2F1.6.1%2Fapache-couchdb-1.6.1.tar.gz

這將把 CouchDB 原始檔下載到您的系統中。現在解壓縮 apache-couchdb-1.6.1.tar.gz,如下所示。

$ tar zxvf apache-couchdb-1.6.1.tar.gz

配置 CouchDB

要配置 CouchDB,請執行以下操作:

  • 瀏覽到 CouchDB 的主資料夾。
  • 以超級使用者身份登入。
  • 使用 ./configure 提示進行配置,如下所示:
$ cd apache-couchdb-1.6.1
$ su
Password:
# ./configure --with-erlang=/usr/lib64/erlang/usr/include/

它將為您提供如下所示的輸出,並以“您已配置 Apache CouchDB,是時候放鬆一下了”的結束行結尾。

# ./configure --with-erlang=/usr/lib64/erlang/usr/include/

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking how to create a ustar tar archive... gnutar
………………………………………………………..
……………………….
config.status: creating var/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: creating src/snappy/google-snappy/config.h
config.status: src/snappy/google-snappy/config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands

You have configured Apache CouchDB, time to relax.

Run `make && sudo make install' to install.

安裝 CouchDB

現在鍵入以下命令以在您的系統中安裝 CouchDB。

# make && sudo make install

它將在您的系統中安裝 CouchDB,並以“您已安裝 Apache CouchDB,是時候放鬆一下了”的結束行結尾。

啟動 CouchDB

要啟動 CouchDB,請瀏覽到 CouchDB 主資料夾並使用以下命令:

$ cd apache-couchdb-1.6.1
$ cd etc
$ couchdb start

它將啟動 CouchDB 並輸出以下內容:

Apache CouchDB 1.6.1 (LogLevel=info) is starting.
Apache CouchDB has started. Time to relax.
[info] [lt;0.31.0gt;] Apache CouchDB has started on http://127.0.0.1:5984/
[info] [lt;0.112.0gt;] 127.0.0.1 - - GET / 200
[info] [lt;0.112.0gt;] 127.0.0.1 - - GET /favicon.ico 200

驗證

由於 CouchDB 是一個 Web 介面,請嘗試在瀏覽器中鍵入以下主頁 URL。

http://127.0.0.1:5984/

它將產生以下輸出:

{
   "couchdb":"Welcome",
   "uuid":"8f0d59acd0e179f5e9f0075fa1f5e804",
   "version":"1.6.1",
   "vendor":{
      "name":"The Apache Software Foundation",
      "version":"1.6.1"
   }
}
廣告

© . All rights reserved.