Server operation

Below are all the cmdlets needed to get all the information on the CouchDB server.

To get the version and other info on the server, run:

Get-CouchDBServer

To get list of running tasks, including the task type, name, status and process ID:

Get-CouchDBActiveTask -Authorization "admin:password"

To get list of all the databases in the CouchDB instance:

Get-CouchDBDatabase

To get information of a list of the specified databases in the CouchDB instance:

Get-CouchDBDatabaseInfo -Keys test,test1,test2

To get the status of the node or cluster, run this:

Get-CouchDBClusterSetup -Authorization "admin:password"

To get a list of all database events in the CouchDB instance:

Get-CouchDBDatabaseUpdates -Authorization "admin:password"

For other parameter see the table below:

PARAMETER DESCRIPTION
Feed
Option:

normal: Returns all historical DB changes, then closes the connection. Default.

longpoll: Closes the connection after the first event.

continuous: Send a line of JSON per event. Keeps the socket open until timeout.

eventsource: Like, continuous, but sends the events in EventSource format.

Timeout Number of seconds until CouchDB closes the connection. Default is 60.
Heartbeat Period in milliseconds after which an empty line is sent in the results. Only applicable for longpoll, continuous, and eventsource feeds. Overrides any timeout to keep the feed alive indefinitely. Default is 60000.
Since Return only updates since the specified sequence ID. May be the string “now” to begin showing only new updates.

To displays the nodes that are part of the cluster:

Get-CouchDBNode -Authorization "admin:password"

To get the statistics for the running server:

Measure-CouchDBStatistics -Authorization "admin:password"
Measure-CouchDBStatistics -System -Authorization "admin:password"

To restart server:

Note

This task required privileged access on operating system

Restart-CouchDBServer

And check health:

Get-CouchDBServer -Status

To get one or more Universally Unique Identifiers (UUIDs) from the CouchDB instance:

New-CouchDBUuids

Read the log

To read entire log.

Read-CouchDBLog

Note

The default path on Windows is C:\CouchDB\couch.log, while on Unix it is /var/log/couchdb/couch.log. Otherwise, if the log is in a custom path, specify the path using the -Path parameter.

This example is used to read only the last 15 lines of log.

Read-CouchDBLog -Tail 15

Instead this to stay in append on the log for the level of warning.

Read-CouchDBLog -Level warning -Follow

Level

Each entry in the log has its own color, so as to identify the line of interest “at a glance”.

debug : Detailed debug logging.

info : Informative logging. Includes HTTP requests headlines, startup of an external processes etc.

notice

warning : Warning messages are alerts about edge situations that may lead to errors.

error : Error level includes only things that go wrong, like crash reports and HTTP error responses (5xx codes).

critical

alert

emergency

Clear the log

Clear entire and rotate (save a copy in the same folder) log.

Clear-CouchDBLog -Rotate

Replication

The replication is an incremental one way process involving two databases (a source and a destination).

Get replica

To get a replication document.

Get-CouchDBReplication -Authorization "admin:password"

To get a list of replication jobs.

Get-CouchDBReplicationScheduler -Authorization "admin:password"

And to get a list of replication document states.

Get-CouchDBReplicationDocument -Authorization "admin:password"

Create replica

Creation of the replicator database and replication agent is automatically in the same time.

New-CouchDBReplication -SourceDatabase test -TargetDatabase test_dump -Continuous -Authorization "admin:password"

Note

The Authorization parameter refers to source database. It is preferable that the destination database is not password protected, otherwise an inaccessibility error will return.

Now that we have a replicated document, let’s take a look at the change.

Get-CouchDBDatabaseChanges -Database test_dump

Modify replica

To change the replication agent settings (continuous: true | false).

$replica = Get-CouchDBReplication -Authorization "admin:password"
Write-Output $replica.rows.id[1] $replica.rows.value[1].rev
# continuous: false
Set-CouchDBReplication -Document $replica.rows.id[1] -Revision $replica.rows.value[1].rev -Authorization "admin:password"
# continuous: true
Set-CouchDBReplication -Document $replica.rows.id[1] -Revision $replica.rows.value[1].rev -Continuous -Authorization "admin:password"

Remove replica

To remove the replication agent.

Remove-CouchDBReplication -Document localhost-test_localhost-test_dump -Authorization -Authorization "admin:password"

Replication request

Request, configure, or stop, a replication operation.

Request-CouchDBReplication -SourceDatabase test -TargetDatabase test_dump -Documents "Hitchhikers","Hitchhikers_Guide" -Authorization "admin:password"