port
The port number | protocol | effect |
---|---|---|
5984 | tcp | Vertebral standard ports for all cluster HTTP API requests |
5986 | tcp | For administrators to manage nodes and slices |
4369 | tcp | Erlang port mapping to daemon |
basic configuration
couchdb Configuration
curl
Address: http://localhost:5984/_node/<name@host>/_config/couchdb/
followed by the parameters.
- attachment_stream-buffer_size
buffer pool size, the bigger the better read performance, but increase the response time of the write operation. - database_dir
database file address - default_security
default security leveladmin_local
.everyone
: anyone can read and write.admin_only
: Only the admin can read and write.admin_local
: Fragmented database can be read and written to anyone, but only fragments admin can be read and written. - delayed_commits
submitted latefalse
to ensure synchronization.true
can improve performance. - file_compression
file compression defaultsnappy
.none
: No compression.snappy
: Use Google's Snappy.deflate_N
: Usezlib
, N is the compression level from 1 (fastest, lowest compression ratio) to 9 (slowest speed, highest compression rate). - fsync_options
whether the file in the buffer zone refresh sync with the operating system to your hard drive. generally do not need to modify.fsync_options=[before_header,after_header,on_file_open]
- max_dbs_open
while the maximum number of open database defaults to 100. - os_process_timeout
processing timeout default 5000ms - uri_file
This parameter specifies the file that contains the complete database used to access CouchDB instanceURI
. Default:/var/run/couchdb/couchdb.uri
- users_db_suffix
user database suffix, default_users
. - util_driver_dir
binary driver's position. - uuid
unique identifier of the server instance CouchDb - view_index_dir
position CouchDB view index file. Defaults:/var/lib/couchdb
- maintenance_mode
two kinds of maintenance modes CouchDb node may be usedtrue
: the node in the cluster and does not respond to requests from other nodes/_up
. endpoint will return 404 responsenolb
:/_up
endpoint will return 404 response.false
: normal response to the node 200. - max_document_size
maximum size of the document defaults to 4GB
operating
Node operation
See all the nodes
curl -u admin:adminpw -X GET http://localhost:5984/_membership
{
"all_nodes":[ # 当前节点所知道的节点
"[email protected]"],
"cluster_nodes":[ #当前节点所连接的节点
"[email protected]"],
}
Adding a node
curl -u admin:adminpw -X PUT http://localhost:5986/_nodes/[email protected] -d {}
To delete a node
#首先获取关于文档的revision
curl -u admin:adminpw -X GET "http://xxx.xxx.xxx.xxx:5986/_nodes/[email protected]"
{"_id":"[email protected]","_rev":"1-967a00dff5e02add41820138abb3284d"}
#删除节点
curl -u admin:adminpw -X DELETE http://localhost:5986/_nodes/[email protected]?rev=1-967a00dff5e02add41820138abb3284d
Database operations
Create a database
Name of the database does not support uppercase characters, only supports [az], [0-9], as well as special characters:_ $ ( ) + - /
#创建一个数据库名字为db_name q=4说明该数据库分为4个部分(片) n=2说明数据库有一个副本。
curl -u admin:adminpw -X PUT http://localhost:5984/db_name?q=4&n=2
Delete Database
curl -u admin:adminpw -X DELETE http://localhost:5984/db_name