Couchdb 简明教程

CouchDB - Installation

本章教您如何在 Windows 和 Linux 系统中安装 CouchDB。

This chapter teaches you how to install CouchDB in windows as well as Linux systems.

Installing CouchDB in Windows

Download CouchDB

CouchDB 的官方网站是 https://couchdb.apache.org 。如果您单击给定的链接,您可以获得如下所示的 CouchDB 官方网站主页。

The official website for CouchDB is https://couchdb.apache.org. If you click the given link, you can get the home page of the CouchDB official website as shown below.

download couchdb

如果您单击下载按钮,则会转到一个页面,其中提供了各种格式的 CouchDB 下载链接。以下快照对此进行了说明。

If you click on the download button that will lead to a page where download links of CouchDB in various formats are provided. The following snapshot illustrates the same.

couchdb formats

为 Windows 系统选择下载链接,并选择提供的其中一个镜像以开始下载。

Choose the download link for windows systems and select one of the provided mirrors to start your download.

Installing CouchDB

CouchDB 将以名为 setup-couchdb-1.6.1_R16B02.exe. 的安装文件形式下载到您的系统。运行安装文件并继续安装。

CouchDB will be downloaded to your system in the form of setup file named setup-couchdb-1.6.1_R16B02.exe. Run the setup file and proceed with the installation.

安装后,通过访问以下 * link: [role="bare"]http://127.0.0.1:5984/.* 打开 CouchDB 的内置 Web 界面。如果一切顺利,这将给您一个包含以下输出的网页。

After installation, open built-in web interface of CouchDB by visiting the following link: [role="bare"]http://127.0.0.1:5984/. If everything goes fine, this will give you a web page, which have the following output.

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

您可以使用以下 URL 与 CouchDB Web 界面进行交互 −

You can interact with the CouchDB web interface by using the following url −

http://127.0.0.1:5984/_utils/

这会向您展示 Futon 的索引页面,它是 CouchDB 的 Web 界面。

This shows you the index page of Futon, which is the web interface of CouchDB.

web interface

Installing CouchDB in Linux Systems

对于许多以 Linux 为基础的系统,它们内部提供了 CouchDB。若要安装此 CouchDB,请遵循说明。

For many of the Linux flavored systems, they provide CouchDB internally. To install this CouchDB follow the instructions.

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

On Ubuntu and Debian you can use −

sudo aptitude install couchdb

在 Gentoo Linux 上有一个可用的 CouchDB ebuild −

On Gentoo Linux there is a CouchDB ebuild available −

sudo emerge couchdb

如果你的 Linux 系统没有 CouchDB,请遵循下一部分来安装 CouchDB 及其依赖项。

If your Linux system does not have CouchDB, follow the next section to install CouchDB and its dependencies.

Installing CouchDB Dependencies

以下是需要安装以获取系统中的 CouchDB 的依赖项列表−

Following is the list of dependencies that are to be installed to get CouchDB in your system−

  1. Erlang OTP

  2. ICU

  3. OpenSSL

  4. Mozilla SpiderMonkey

  5. GNU Make

  6. GNU Compiler Collection

  7. libcurl

  8. help2man

  9. Python for docs

  10. Python Sphinx

要安装这些依赖项,请在终端中键入以下命令。这里我们使用 Centos 6.5,并且以下命令将安装与 Centos 6.5 兼容的所需软件。

To install these dependencies, type the following commands in the terminal. Here we are using Centos 6.5 and the following commands will install the required softwares compatible to 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

Note − 对于所有这些命令,你需要使用 sudo。以下过程将普通用户转换为 sudoer。

Note − For all these commands you need to use sudo. The following procedure converts a normal user to a sudoer.

  1. Login as root in admin user

  2. Open sudo file using the following command −

visudo
  1. Then edit as shown below to give your existing user the sudoer privileges −

Hadoop All=(All) All , and press esc : x to write the changes to the file.

在你的系统中下载完所有依赖项后,按照给定的说明下载 CouchDB。

After downloading all the dependencies in your system, download CouchDB following the given instructions.

Downloading CouchDB

Apache 软件基金会将不会提供 CouchDB 的完整 .tar 文件,所以你必须从源码安装它。

Apache software foundation will not provide the complete .tar file for CouchDB, so you have to install it from the source.

创建一个新目录来安装 CouchDB,浏览到这样的已创建目录并通过执行以下命令下载 CouchDB 源码 −

Create a new directory to install CouchDB, browse to such created directory and download CouchDB source by executing the following commands −

$ 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 ,如下所示。

This will download CouchDB source file into your system. Now unzip the apache-couchdb-1.6.1.tar.gz as shown below.

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

Configuring CouchDB

要配置 CouchDB,请执行以下操作 −

To configure CouchDB, do the following −

  1. Browse to the home folder of CouchDB.

  2. Login as superuser.

  3. Configure using ./configure prompt as shown below −

$ cd apache-couchdb-1.6.1
$ su
Password:
# ./configure --with-erlang=/usr/lib64/erlang/usr/include/

它给你如下所示的输出,其中一行总结说 − You have configured Apache CouchDB, time to relax

It gives you the following output similar to that shown below with a concluding line saying − You have configured Apache CouchDB, time to relax.

# ./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.

Installing CouchDB

现在键入以下命令以在你的系统中安装 CouchDB。

Now type the following command to install CouchDB in your system.

# make && sudo make install

它在你的系统中安装 CouchDB,其中一行总结说 − You have installed Apache CouchDB, time to relax

It installs CouchDB in your system with a concluding line saying − You have installed Apache CouchDB, time to relax.

Starting CouchDB

要启动 CouchDB,请浏览到 CouchDB 主文件夹并使用以下命令 −

To start CouchDB, browse to the CouchDB home folder and use the following command −

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

CouchDB 的输出:−

It starts CouchDB giving the following output: −

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

Verification

由于 CouchDB 是一个网络界面,试着用浏览器中输入以下主页 URL:

Since CouchDB is a web interface, try to type the following homepage url in the browser.

http://127.0.0.1:5984/

产出如下所示 −

It produces the following output −

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