So today we had the following issue with our CouchDB environment.
First we were requsted to copy an exsiting environment of couchDB to another servers.
Few basic steps
1. Stop CouchDB (Optional)
2. tar -czvf /usr/local/var/lib/couchdb couchdbs
3. copy the tar file to destination server
4. untar tar -xzvf couchdbs to the same folder /usr/local/var/lib/couchdb
5. make sure that all .couch files are owned by couchdb user.
6. make sure on more critical thing (we will talk about it later)
after copying the data files and setting permissions, we can access the dbs from our web UI .
Now, while trying to access the following view
I ‘ve encountered the error below :
So after looking in couchdb,log (which is located on /usr/local/var/log/couchdb)
I saw this line – reporting something is wrong with accessing to my view file (which is stored under hidden directory .<view_name> )
[Sun, 28 Apr 2013 16:07:05 GMT] [error] [<0.4679.0>] Failed to open view file ‘/usr/local/var/lib/couchdb/.<view_name>/e2bf9be9033e7101e52655ea1a8088f3.view‘: unknown POSIX
a quick permissions check on /usr/local/var/libcouchdb revealed that the hidden folder .<view_name> was owned by root and by couchdb user.
chown -R /usr/local/var/lig/couchdb/
and then the view worked fine !
In order to do it carefully, I deleted the view document’s revision, and recreated the view.
1. Getting the document’s revision
2. curl -X DELETE http://127.0.0.1:5984/<db_name>/_design/<view_name>?rev=REV-ID
3. Recreate the view
curl -X PUT http://127.0.0.1:5984/<db_name>/_design/<view_name> -d @<view_name>.json