14

What is command to clean CouchDB please ? And if I want to disable and re-start my CouchDB what is command?

Thanks

Teddy
  • 18,357
  • 2
  • 30
  • 42
Mehdi
  • 2,160
  • 6
  • 36
  • 53

6 Answers6

19

CouchDB can be started/stopped/restarted from the /etc/init.d/couchdb or /etc/rc.d/couchdb startup script.

(This startup script file might be located somewhere else on your system.)

You would do something like this:

  1. To stop: /etc/init.d/couchdb stop
  2. To restart: /etc/init.d/couchdb restart

As far as cleaning goes, I think you mean compaction. This is easiest to do via Futon, which is located here by default: http://localhost:5984/_utils

Login to Futon as an admin, navigate to your database, and there will be links to compact the database.

Teddy
  • 18,357
  • 2
  • 30
  • 42
  • 1
    You're also supposed to be able to restart the server with a POST to `http://admin:password@localhost:5984/_restart` With my Homebrew OSX install of CouchDB 1.2.1 I've only had success doing this half the time. It either it works fine or it shuts off and crashes before it can restart. – fet Jul 03 '13 at 16:35
  • 1
    using this method works - but don't forget if you're running this on windows as a service, you have to open services.msc and restart the apache couchdb service before the changes take effect – tim Apr 16 '15 at 00:36
  • Thanks @tim. I am not even sure if we had CouchDB on Windows when I posted this response. – Teddy Apr 18 '15 at 17:29
  • Just as a reminder, you will probably also want to compact your views (or have compaction rules in place in the config). You can compact views via the API. – Larry Anderson Jul 11 '16 at 15:06
  • Use `service couchdb restart` and `service couchdb status` for the preferred way. – sjas Dec 06 '16 at 11:48
15

This can be somewhat dependent on OS and its version. On Ubuntu 14.04, for example (which is transitioning away from sysvinit), /etc/init.d/couchdb commands don't work for me. I have to do:

sudo service couchdb restart

So use the curl method posted by user2744667 (with root/admin privileges), or use the standard method for restarting daemons/services for your OS.

Finally, as a last resort, you could kill the process. This is not the recommended way to do it, and it is not "clean" as you indicated in the question. You will likely find that CouchDB is agressive about respawning itself. But if you are in a homicidal mood, all that kill-ing could be just the thing.

labyrinth
  • 13,397
  • 7
  • 35
  • 44
14

You can restart CouchDb as per the documentation here

Example with curl:

curl -X POST http://localhost:5984/_restart -H"Content-Type: application/json"
Mark Pearl
  • 7,573
  • 10
  • 47
  • 57
jgskin
  • 140
  • 1
  • 4
  • This is a great method to use if you don't have web access to `localhost` on the server. ie, in my case, after modifying configs to bind CouchDB to any address, I needed to restart and could not otherwise find a `couchdb` service to restart. Remoting in and `curl`'ing to restart then allowed the config changes to kick in and further admin to be done via a remote browser interface. – ljs.dev Jul 19 '15 at 21:53
  • This works because CouchDB runs in the Erlang runtime, POSTing to _restart invokes a call to Erlang's init:restart(), which unloads and restarts the CouchDB app in the runtime. – James Green Sep 29 '15 at 12:29
14

On Windows, you don't need to run a GUI like services.msc ... Typing this is usually faster:

c:\> net stop "Apache CouchDb"
c:\> net start "Apache CouchDb"
Tony O'Hagan
  • 21,638
  • 3
  • 67
  • 78
6

on Windows, if you installed it as a service, open services.msc, find the Apache couchDB service, and restart.

tim
  • 3,823
  • 5
  • 34
  • 39
0

As I write this, the most recent existing answers are seven years old. Here's some fresher ways of doing this.

On Windows, CouchDB uses nssm.exe for managing the service. A copy of that executable is at <couch-installation-dir>\bin\nssm.exe. If you installed Couch to C:\CouchDB then restarting it is:

C:\CouchDB\bin\nssm restart "Apache CouchDB"

It doesn't have to be that nssm.exe, of course.

Still on Windows, using PowerShell you can restart the service the normal PowerShell way:

ps1 $ restart-service "Apache CouchDB"

Couch being Couch, there's also a plain old HTTP way to trigger a restart. If you have an admin user called admin with password xx then you can do this:

curl http://admin:xx@127.0.0.1:5984/_node/couchdb@localhost/_restart -X POST

The node may not be called couchdb@localhost. To find out, use:

$ curl http://admin:admin@127.0.0.1:5984/_membership/

{"all_nodes":["couchdb@localhost"],"cluster_nodes":["couchdb@localhost"]}
Andrew E
  • 7,697
  • 3
  • 42
  • 38