我正在尝试以编程方式设置一个集群,为此我已经按照文档(此处为https://docs.couchdb.org/en/stable/setup/cluster.html#the-cluster-setup-api)进行了操作,并创建了一个快速的python脚本来为我完成这一操作。
然后,我会得到以下输出:X1 M0 N1 X.所以我决定试试Fauxton接口(它很好用),看看有什么超出了界限。
对python脚本进行了一些更改,以完全匹配Fauxton发送到群集的内容...但如果手动界面(通过Fauxton)工作正常,在复制引擎盖下发生的情况时,我仍然会收到“无法同步”错误...这让我现在抓狂...
使用以下启动脚本:
for i in {1..3}; \
do echo "$i"5984:5984; \
docker run -d --rm -p "$i"5984:5984 \
-e NODENAME=box0$i.couch -e ERL_FLAGS='-setcookie "brumbrum"' \
-e COUCHDB_USER=admin -e COUCHDB_PASSWORD=admin \
--name box0$i --network couch \
couchdb:3.1.1; \
done
它使用couchdb的3.1.1版本生成了三个新的Docker容器。https://github.com/wasperen/couchdb_clusterify/blob/main/clusterize.py
谢谢你的帮助。但是不管怎样:新年快乐!
只需按照文档中的步骤进行操作,即可获得相同的结果:
root@75c127f35ad6:~# curl -X POST -H "Content-Type: application/json" http://admin:admin@box01.couch:5984/_cluster_setup -d '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"admin", "node_count":"3"}'
{"error":"bad_request","reason":"Cluster is already enabled"}
root@75c127f35ad6:~# curl -X POST -H "Content-Type: application/json" http://admin:admin@box01.couch:5984/_cluster_setup -d '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"admin", "port": 5984, "node_count": "3", "remote_node": "box02.couch", "remote_current_user": "admin", "remote_current_password": "admin" }'
{"ok":true}
root@75c127f35ad6:~# curl -X POST -H "Content-Type: application/json" http://admin:admin@box01.couch:5984/_cluster_setup -d '{"action": "add_node", "host":"box02.couch", "port": 5984, "username": "admin", "password":"admin"}'
{"ok":true}
root@75c127f35ad6:~# curl -X POST -H "Content-Type: application/json" http://admin:admin@box01.couch:5984/_cluster_setup -d '{"action": "enable_cluster", "bind_address":"0.0.0.0", "username": "admin", "password":"admin", "port": 5984, "node_count": "3", "remote_node": "box03.couch", "remote_current_user": "admin", "remote_current_password": "admin" }'
{"ok":true}
root@75c127f35ad6:~# curl -X POST -H "Content-Type: application/json" http://admin:admin@box01.couch:5984/_cluster_setup -d '{"action": "add_node", "host":"box03.couch", "port": 5984, "username": "admin", "password":"admin"}'
{"ok":true}
root@75c127f35ad6:~# curl -X POST -H "Content-Type: application/json" http://admin:admin@box01.couch:5984/_cluster_setup -d '{"action": "finish_cluster"}'
{"error":"setup_error","reason":"Cluster setup unable to sync admin passwords"}
使用Fauxton用户界面(在box 01上),从浏览器日志中看到以下内容:
POST http://localhost:15984//_cluster_setup
DATA {"action":"enable_cluster","username":"admin","password":"admin","bind_address":"0.0.0.0","port":5984,"node_count":3,"singlenode":false}
RESPONSE 400 {"error":"bad_request","reason":"Cluster is already enabled"}
POST http://localhost:15984//_cluster_setup
DATA {"action":"enable_cluster","username":"admin","password":"admin","bind_address":"0.0.0.0","port":5984,"node_count":3,"remote_node":"box02.couch","remote_current_user":"admin","remote_current_password":"admin"}
RESPONSE 201 {"ok":true}
POST http://localhost:15984//_cluster_setup
DATA {"action":"add_node","username":"admin","password":"admin","host":"box02.couch","port":5984,"singlenode":false}
RESPONSE 201 {"ok":true}
POST http://localhost:15984//_cluster_setup
DATA {"action":"enable_cluster","username":"admin","password":"admin","bind_address":"0.0.0.0","port":5984,"node_count":3,"remote_node":"box03.couch","remote_current_user":"admin","remote_current_password":"admin"}
RESPONSE 201 {"ok":true}
POST http://localhost:15984//_cluster_setup
DATA {"action":"add_node","username":"admin","password":"admin","host":"box03.couch","port":5984,"singlenode":false}
RESPONSE 201 {"ok":true}
POST http://localhost:15984//_cluster_setup
DATA {"action":"finish_cluster"}
RESPONSE 201 {"ok":true}
GET http://localhost:15984/_membership
RESPONSE 200 {"all_nodes":["couchdb@box01.couch","couchdb@box02.couch","couchdb@box03.couch"],"cluster_nodes":["couchdb@box01.couch","couchdb@box02.couch","couchdb@box03.couch"]}
2条答案
按热度按时间ohtdti5x1#
我认为CouchDB 3.x中可能有一个bug,当使用基本身份验证时,它不接受finish_cluster操作。如果您首先通过**_session**端点获得一个会话cookie,然后使用该cookie进行身份验证,它似乎工作得非常好。
6pp0gazn2#
我检查了你的代码,它看起来都很好,似乎你只是在这里遇到这个问题:https://github.com/apache/couchdb/issues/2858。它可以通过向集群协调器节点发送GET请求来解决。