如何在 CentOS 6 上安装 Apache CouchDB
本文解释了如何在基于 RHEL 的系统上安装 CouchDB。例如,CentOS、Red Hat、Oracle Enterprise Linux 等。
有两种安装 CouchDB 的方法。您可以从 EPEL 存储库安装它,或从 CouchDB 源代码安装。
方法一:从 EPEL 安装
首先,如前所述,启用 EPEL 存储库。
验证 couchdb 是否可用于 yum 安装。
# yum info couchdb
Name : couchdb
Arch : x86_64
Version : 1.0.3
Release : 2.el6
Size : 1.7 M
Repo : epel
Summary : A document database server, accessible via a RESTful JSON API
安装沙发数据库。根据您的系统,这可能会安装许多依赖包。在我的系统上,它总共安装了 36 个软件包。
# yum install couchdb
修改 local.ini 文件并为 bind_address 添加一行,并将 ip-address 指定为安装 couchdb 的系统。
# vi /etc/couchdb/local.ini
[httpd]
;port = 5984
;bind_address = 127.0.0.1
bind_address = 192.168.101.38
启动 couchdb 服务
# service couchdb start
Starting couchdb: [ OK ]
# service couchdb status
couchdb (pid 29915) is running...
通过访问 URL:http://{your-ip-address}:5984 验证 couchdb 是否工作,它应该显示一个包含以下消息的网页。
{“couchdb”:“欢迎”,“版本”:“1.0.3”}
转到:http://{your-ip-address}:5984/_utils/,您可以从中创建和管理 couchdb 数据库。
方法二:从 CouchDB 源码安装
如果您想自己从源代码安装它,首先您应该满足所有依赖项。
从 CentOS 存储库安装以下标准软件包。
# yum info gcc libtool xulrunner-devel libicu-devel openssl-devel
安装二郎
从这里下载最新版本的 Erland 。或者,您可以使用如下所示的 wget 直接下载。
cd /usr/src
wget http://www.erlang.org/download/otp_src_R15B01.tar.gz
tar xvfz otp_src_R15B01.tar.gz
我们将在 /opt/couchdb 目录下安装 couchdb 及其所有依赖项。因此,在安装 erlang 时,将前缀指定为 /opt/couchdb/erlang,如下所示。
cd otp_src_R15B01
./configure --prefix=/opt/couchdb/erlang --without-termcap --without-javac --enable-smp-support --disable-hipe
make
make install
安装curl
从这里下载最新版本的 Curl 。或者,您可以使用如下所示的 wget 直接下载。
cd /usr/src
wget http://curl.haxx.se/download/curl-7.26.0.tar.gz
tar xvfz curl-7.25.0.tar.gz
就像 Erlang 一样,我们也将在 /opt/couchdb 目录下安装 Curl。因此,在安装 curl 时,将前缀指定为 /opt/couchdb/curl,如下所示。
cd curl-7.25.0
./configure --prefix=/opt/couchdb/curl
make
make install
引擎
从这里下载最新版本的 SpiderMonkey JS 。或者,您可以使用如下所示的 wget 直接下载。
cd /usr/src
wget http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
tar xvfz js185-1.0.0.tar.gz
请注意,您必须 cd 到 js-1.8.5 下的“js/src”子目录来执行 ./configure 并按如下所示进行安装 spidermonkey js 引擎。
cd js-1.8.5/js/src
./configure
make
make install
您将看到安装在 /usr/local/lib 下的 libmozjs185.so.1.0.0 和 libmozjs185-1.0.a
# ls -ltr /usr/local/lib
-rwxr-xr-x. 1 root root 3671764 May 30 09:39 libmozjs185.so.1.0.0
-rwxr-xr-x. 1 root root 5523616 May 30 09:39 libmozjs185-1.0.a
lrwxrwxrwx. 1 root root 35 May 30 09:40 libmozjs185.so.1.0 -> /usr/local/lib/libmozjs185.so.1.0.0
lrwxrwxrwx. 1 root root 33 May 30 09:40 libmozjs185.so -> /usr/local/lib/libmozjs185.so.1.0
注意:如果没有安装 spidermonkey JS 库,您将在尝试执行下一步中提到的 ./configure 时收到以下错误消息。
checking for JS_NewObject in -lmozjs185... no
configure: error: Could not find the js library.
Is the Mozilla SpiderMonkey library installed?
安装 CouchDB
从这里下载最新版本的 Couchdb 。或者,您可以使用如下所示的 wget 直接下载。
cd /usr/src
wget http://apache.mirrors.pair.com/couchdb/releases/1.2.0/apache-couchdb-1.2.0.tar.gz
tar xvfz apache-couchdb-1.2.0.tar.gz
在安装 couchdb 时,您应该设置 ERL、ERLC、CURL_CONFIG 环境变量,如下所示。这些在 couchdb 的 ./config 期间是必需的。
就像先决条件一样,我们将在 /opt/couchdb 目录下安装 couchdb。因此,将前缀指定为 /opt/couchdb/couchdb,如下所示。
cd apache-couchdb-1.2.0
export ERL=/opt/couchdb/erlang/bin/erl
export ERLC=/opt/couchdb/erlang/bin/erlc
export CURL_CONFIG=/opt/couchdb/curl/bin/curl-config
export LDFLAGS=-L/opt/couchdb/curl/lib
./configure --prefix=/opt/couchdb/couchdb --with-erlang=/opt/couchdb/erlang/lib/erlang/usr/include/ --enable-js-trunk
make
make install
注意:只有在您安装了 SpiderMonkey JS 引擎的最新版本(任何比 js185-1.0.0 更新的版本)时,您才会使用 –enable-js-trunk。我建议您使用 –enable-js-trunk 选项。
如果您没有使用最新版本的 spidermonekey JS 引擎,您可能需要使用标志 –with-js-include 和 –with-js-lib 并将其指向适当的位置,如下所示。
./configure --prefix=/opt/couchdb/couchdb --with-erlang=/opt/couchdb/erlang/lib/erlang/usr/include/ --with-js-include=/usr/include/xulrunner-2 / --with-js-lib=/usr/lib64/xulrunner-devel-2/lib/
注意:如果你已经安装了最新版本的spidermonkey js,并且你没有使用--enable-js-trunk,你会在couchdb的“make”过程中得到如下错误信息:
cc1: warnings being treated as errors
In file included from couch_js/main.c:20:
couch_js/sm170.c: In function req_status:
couch_js/sm170.c:105: error: implicit declaration of function INT_FITS_IN_JSVAL
couch_js/sm170.c: In function evalcx:
couch_js/sm170.c:138: error: implicit declaration of function JS_GetStringChars
couch_js/sm170.c:138: error: assignment makes pointer from integer without a cast
couch_js/sm170.c: In function seal:
couch_js/sm170.c:220: error: implicit declaration of function JS_SealObject
couch_js/sm170.c: At top level:
couch_js/sm170.c:236: error: initialization from incompatible pointer type
设置 CouchDB 启动服务
创建 couchdb 启动程序所需的 couchdb 用户。
# adduser couchdb
更改 var 目录的所有权,couchdb 将在其中写入日志和一些其他信息。
# chown -R couchdb /opt/couchdb/couchdb/var/
在 /etc/init.d 下为 couchdb 服务创建一个链接
# ln -s /opt/couchdb/couchdb/etc/rc.d/couchdb /etc/init.d/couchdb
最后启动 couchdb 服务。
# service couchdb start
Starting database server couchdb
通过访问 URL:http://{your-ip-address}:5984 验证 couchdb 是否工作,它应该显示一个包含以下消息的网页。
{“couchdb”:“欢迎”,“版本”:“1.0.3”}
转到:http://{your-ip-address}:5984/_utils/,您可以从中创建和管理 coucbdb 数据库。
本系列的下一篇文章将解释如何创建 CouchDB 数据库并执行一些基本的数据操作。
- 点赞
- 收藏
- 关注作者
评论(0)