Sunteți pe pagina 1din 6

HOW-TO Setup CouchDB including CouchDB-Lucene using Ubuntu Server.

Purpose: I am working on a project that is implementing CouchDB (CBD) and CouchDB-Lucene (C-l). During the past couple days, I have been having an amount of difficulty installing and configuring everything. This is mainly due to my lack of understanding about the *nix environment. Environment: Ubuntu Server 10.04 with CouchDB 0.11.0 and CouchDB-Lucene 0.5. Notes: First, I am doing everything below as root by using the sudo su command. I understand that some people do not like doing this, some of you prefer to sudo every command. Please feel free. Second, within my /home, I refer to a directory lucas. This is my name, this is my user directory, yours might be different. Third, this is in no way intended to be a secure installation.

1) 2)

Download and Install Ubuntu Server 10.04 from www.ubuntu.com Install updates

apt-get update apt-get upgrade 3) Install some needed tools apt-get install wget openssh-server 4) Install CDB's dependencies apt-get build-dep couchdb apt-get install build-essential xulrunner-dev libicu-dev libcurl4-openssl-dev libtool 5) Download CouchDB from http://couchdb.apache.org/downloads.html Please check to ensure the mirror is actually a good mirror, you probably want to get the latest version of CDB, do not simply, mindlessly follow this command. mkdir /home/lucas/downloads cd /home/lucas/downloads wget http://mirror.olnevhost.net/pub/apache/couchdb/0.11.0/apache-couchdb-0.11.0.tar.gz 6) Configuration and Installation tar zxvf apache-couchdb-0.11.0.tar.gz cd apache-couchdb-0.11.0 ./configure --with-js-lib=/usr/lib/xulrunner-devel-1.9.2.3/lib --with-js-include=/usr/lib/xulrunner-devel1.9.2.3/include make make install The extra options in the configure line are due to lucid no longer having the libmoz-js package. This is

due to some conflicts. Hence, we use the xulrunner-dev and supply the above arguments to the configure command. 7) CouchDB post-install configuration vi /usr/local/etc/couchdb/local.ini Set: bind_address = 0.0.0.0 to listen on all interfaces. 8) Create user and do permissions work adduser couchdb mkdir -p /usr/local/var/lib/couchdb chown -R couchdb /usr/local/var/lib/couchdb mkdir -p /usr/local/var/log/couchdb chown -R couchdb /usr/local/var/log/couchdb mkdir -p /usr/local/var/run chown -R couchdb /usr/local/var/run 9) Run couchdb /usr/local/etc/init.d/couchdb start Please do a couchdb status and make sure you have an active process. 10) Link the init.d file & update cd /etc/init.d ln -s /usr/local/etc/init.d/couchdb update-rc.d couchdb defaults 11) CouchDB-Lucene time setup prerequisites apt-get install get-core maven2 cd /home/lucas/downloads git clone git://github.com/rnewson/couchdb-lucene.git 12) Install java apt-get install default-jdk 13) Run Maven2 cd couchdb-lucene mvn 14) Did you do it right? When I got to here, Maven2 produced the following output.

[INFO] [assembly:assembly {execution: default-cli}] [INFO] Reading assembly descriptor: src/main/assembly/dist.xml [INFO] Building zip: /home/lucas/downloads/couchdb-lucene/target/couchdb-lucene0.6-SNAPSHOT-dist.zip [INFO] Building tar : /home/lucas/downloads/couchdb-lucene/target/couchdb-lucene0.6-SNAPSHOT-dist.tar.gz [INFO] -----------------------------------------------------------------------[INFO] BUILD SUCCESSFUL [INFO] -----------------------------------------------------------------------[INFO] Total time: 3 minutes [INFO] Finished at: Thu May 06 06:56:46 CDT 2010 [INFO] Final Memory: 21M/52M [INFO] ------------------------------------------------------------------------

15) Configure C-l apt-get install unzip cp couchdb-lucene-0.6-SNAPSHOT-dist.zip /srv unzip couchdb-lucene-0.6-SNAPSHOT-dist.zip mv couchdb-lucene-0.6-SNAPSHOT couchdb-lucene rm couchdb-lucene-0.6-SNAPSHOT-dist.zip vi /usr/local/etc/couchdb/local.ini Set the following appropriately
[couchdb] os_process_timeout=60000 [external] fti=/usr/bin/python /srv/couchdb-lucene/tools/couchdb-external-hook.py [httpd_db_handlers] fti = {couch_httpd_external, handle_external_req, <<fti>>}

16) Test cd /srv/couchdb-lucene ./bin/run Mine says:


2010-05-06 07:11:28,164 INFO [Main] Index output goes to: /srv/couchdblucene/indexes 2010-05-06 07:11:28,258 INFO [Main] Accepting connections with SelectChannelConnector@localhost:5985

C-l is running in your terminal window now, as you. You can verify this by opening another connection and doing a ps -u root | grep java. This should show you the java process that C-l is running. If you see it, you are on the right path! 17) Create the init.d script vi /usr/local/etc/init.d/couchdb-lucene

#!/bin/sh COUCHDB_LUCENE_DIR="/srv/couchdb-lucene" ### BEGIN INIT INFO # Provides: # Required-Start: # Required-Stop: # Default-Start: # Default-Stop: # Short-Description: # Description: ### END INIT INFO couchdb &local_fs $remote_fs &local_fs &remote_fs 2 3 4 5 0 1 6 CouchDB-Lucene init script CouchDB-Lucene init script for search provider.

#PATH should only incluce /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="lucene server for CouchDB" NAME="couchdb-lucene" DAEMON=/usr/bin/java JAVA_OPTS="-server -Xmx1g" CLASS=com.github.rnewson.couchdb.lucene.Main CLASSPATH="$COUCHDB_LUCENE_DIR/conf" for JAR in `ls $COUCHDB_LUCENE_DIR/lib/*.jar` do CLASSPATH="$CLASSPATH:$JAR" done PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/usr/local/etc/init.d/couchdb-lucene #the user that will run the script USER=couchdb #NO NEED TO MODIFY THE LINES BELOW # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # # Function that starts the daemon/service # do_start() { start-stop-daemon --start --oknodo --make-pidfile --pidfile $PIDFILE --background --chuid $USER --exec $DAEMON -- $JAVA_OPTS -cp $CLASSPATH $CLASS } # # Function that stops the daemon/service # do_stop() { start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE RETVAL="$?" rm -f $PIDFILE

return "$RETVAL"

case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; restart) # # If the "reload" option is implemented then remove the # 'force-reload' alias # log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2 exit 3 ;; esac :

18) Edit /srv/couchdb-lucene/conf/log4.xml Change: <param name=file value=logs/couchdb-lucene.log/> To: <param name=file value=/srv/couchdb-lucene/logs/couchdb-lucene.log/> 19) Edit /srv/couchdb-lucene/conf

Change: dir=indexes To: dir=/srv/couchdb-lucene/indexes 20) Set permissions chmod 755 /usr/local/etc/init.d/couchdb-lucene chown -R couchdb:couchdb /srv/couchdb-lucene/indexes chmod -R 777 /srv/couchdb-lucene/indexes chown -R couchdb:couchdb /srv/couchdb-lucene/logs chmod -R 777 /srv/couchdb-lucene/logs 21) Link the init.d & update cd /etc/init.d ln -s /usr/local/etc/init.d/couchdb-lucene update-rc.d couchdb-lucene defaults

S-ar putea să vă placă și