CouchDB Internals

Here are few Anecdotes about files and thier meaning on CouchDB server

Log files:

CouchDB’s main log file, containing all HTTP requests coming from Futun interface (web interface) or from you custom-application which communication with Couch through it’s API \ CURL commands

/usr/local/var/log/couchdb/couchdb.log

this log can be truncated while couchDB is up and running.

echo ” ” >  /usr/local/var/log/couchdb/couchdb.log

* Tip:

if you dont know where your logfile located  (maybe you have some custom installation)

you will be able to fine it here

cat /usr/local/etc/couchdb/default.ini

search for [log] section.

[log]
file = /usr/local/var/log/couchdb/couch.log
level = info
include_sasl = true

*Tip – if dont know where is your configuration file locate

run

couchdb -c

Datafiles and Views

Data file’s location will be always on your “data_dir” variable  which defined though CouchDB’s installation

you can check wehre is your datadir

Futon (Web) Interface -> Configuration  (http://your-server:5984/_utils/config.html

Search for data_dir  option on the left pane.

the defaulr directory is

/usr/local/var/lib/couchdb

inside  the data dir, every database is represented as a single file with .couch extention.

db-name.couch

Example:

[root@my-server couchdb]# ls -l
total 11581032
-rw-r–r– 1 couchdb couchdb 63103099 May 3 09:29 db1.couch
-rw-r–r– 1 couchdb couchdb 33235064 May 3 09:29 db2.couch
-rw-r–r– 1 couchdb couchdb 366506098 Feb 22 06:11 db3.couch
-rw-r–r– 1 couchdb couchdb 8281 Feb 8 2012 _replicator.couch
-rw-r–r– 1 couchdb couchdb 8290 Dec 31 14:40 _users.couch

And , Where are the the “views” ?

Inside the data dir , for each database couchDB creates a “hidden” folder name

 .db-name_design

Notice- that the folder name begins with “.”  which means that the folder is hidden.

we will be able to see al these folders by typing

ls -la

inside  /usr/local/var/lib/couchdb

[root@my-server couchdb]# ls -la

total 11581068
drwxr-xr-x 9 couchdb couchdb 4096 May 3 05:57 .
drwxr-xr-x 3 root root 4096 May 10 2012 ..
-rw-r–r– 1 couchdb couchdb 63103099 May 3 09:29 db1.couch
drwxr-xr-x 2 couchdb couchdb 4096 May 2 2012 .db1_design
-rw-r–r– 1 couchdb couchdb 172146 Feb 25 15:36 db2.couch
drwxr-xr-x 2 couchdb couchdb 4096 May 2 2012 .db2_design
-rw-r–r– 1 couchdb couchdb 8290 Dec 31 14:40 _users.couch

each database has it’s own _design foler.

the _design foler contains files which are the calculated views on your system.

each view represented as  <signature>.view

Example

[root@my-server .db1_design]# ls -la
total 22112
drwxr-xr-x 2 couchdb couchdb 4096 Apr 28 15:01 .
drwxr-xr-x 8 couchdb couchdb 4096 Apr 30 09:56 ..
-rw-r–r– 1 couchdb couchdb 22630517 May 2 04:56 e2bf9be9033e7101e52655ea1a8088f3.view

If you have multiple views on the same database, you can find out which signature belongs to each view bu running

http://127.0.0.1:5984/your-db/_design/your-view/_info

The output will be in a Jason format:

{"name":"your-view","view_index":
{"signature":"e2bf9be9033e7101e52655ea1a8088f3",
"language":"javascript","disk_size":22630517,"data_size":15932013,
"updater_running":false,
"compact_running":false,"waiting_commit":false,"waiting_clients":0,
"update_seq":395782,"purge_seq":0}}

*Tip:  by typing

du -h /usr/local/var/lib/couchdb

you will be able to know what is the size of each view on your system.

Processes:

CouchDB’s main process : (Should run under couchdb user, it’s parent process is init (PID=1))

/usr/local/bin/couchdb

Parameters

-a   config files (you can have as many as you want)

-a config1.ini  -a config2.ini

you can add more config files while couchDB is running

couchdb -a  my_new_configfile.ini

The following process responsible for creating views on your system (the Indexer)

/usr/local/bin/couchjs

which means, that if you want to stop a view calculation while its running , just run:

killall couchjs

Warning: it will kill all views calculations, as you cannot kill a single view calculation (yet).

Best !

Advertisements
Tagged with: , , , , ,
Posted in CouchDB

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: