Update couchdb to 3.2.0 and remove / workaround
Created by: YC
Workaround can be removed due to https://github.com/apache/couchdb/commit/44a13d5aeb5b1766c23f00e035915d79ab478a61.
Tested using instructions from README:
#!/bin/bash
export declare -a nodes=(172.17.0.4 172.17.0.3 172.17.0.2)
export masternode=`echo ${nodes} | cut -f1 -d' '`
export declare -a othernodes=`echo ${nodes[@]} | sed s/${masternode}//`
export size=${#nodes[@]}
export user='admin'
export pass='admin'
export VERSION='3.2.0'
export cookie='a192aeb9904e6590849337933b000c99'
docker pull ibmcom/couchdb3:${VERSION}
for node in "${nodes[@]}"
do
if [ ! -z $(docker ps --all --filter "name=couchdb${node}" --quiet) ]
then
docker stop $(docker ps --all --filter "name=couchdb${node}" --quiet)
docker rm $(docker ps --all --filter "name=couchdb${node}" --quiet)
fi
done
for node in "${nodes[@]}"
do
docker create\
--name couchdb${node}\
--env COUCHDB_USER=${user}\
--env COUCHDB_PASSWORD=${pass}\
--env COUCHDB_SECRET=${cookie}\
--env ERL_FLAGS="-setcookie \"${cookie}\" -name \"couchdb@${node}\""\
ibmcom/couchdb3:${VERSION}
done
declare -a conts=(`docker ps --all | grep couchdb | cut -f1 -d' ' | xargs -n${size} -d'\n'`)
for cont in "${conts[@]}"; do docker start ${cont}; done
sleep 10
for node in ${othernodes}
do
curl -XPOST "http://${user}:${pass}@${masternode}:5984/_cluster_setup" \
--header "Content-Type: application/json"\
--data "{\"action\": \"enable_cluster\", \"bind_address\":\"0.0.0.0\",\
\"username\": \"${user}\", \"password\":\"${pass}\", \"port\": \"5984\",\
\"remote_node\": \"${node}\", \"node_count\": \"$(echo ${nodes[@]} | wc -w)\",\
\"remote_current_user\":\"${user}\", \"remote_current_password\":\"${pass}\"}"
done
for node in ${othernodes}
do
curl -XPOST "http://${user}:${pass}@${masternode}:5984/_cluster_setup"\
--header "Content-Type: application/json"\
--data "{\"action\": \"add_node\", \"host\":\"${node}\",\
\"port\": \"5984\", \"username\": \"${user}\", \"password\":\"${pass}\"}"
done
curl -XPOST "http://${user}:${pass}@${masternode}:5984/_cluster_setup"\
--header "Content-Type: application/json" --data "{\"action\": \"finish_cluster\"}"
for node in "${nodes[@]}"; do curl -X GET "http://${user}:${pass}@${node}:5984/_membership"; done
For comparison, VERSION='3.1.1'
:
{"error":"setup_error","reason":"Cluster setup unable to sync admin passwords"}
{"all_nodes":["couchdb@172.17.0.2","couchdb@172.17.0.3","couchdb@172.17.0.4"],"cluster_nodes":["couchdb@172.17.0.2","couchdb@172.17.0.3","couchdb@172.17.0.4"]}
{"all_nodes":["couchdb@172.17.0.3","couchdb@172.17.0.4"],"cluster_nodes":["couchdb@172.17.0.3"]}
{"all_nodes":["couchdb@172.17.0.2","couchdb@172.17.0.4"],"cluster_nodes":["couchdb@172.17.0.2"]}
VERSION='3.2.0'
:
{"ok":true}
{"all_nodes":["couchdb@172.17.0.2","couchdb@172.17.0.3","couchdb@172.17.0.4"],"cluster_nodes":["couchdb@172.17.0.2","couchdb@172.17.0.3","couchdb@172.17.0.4"]}
{"all_nodes":["couchdb@172.17.0.2","couchdb@172.17.0.3","couchdb@172.17.0.4"],"cluster_nodes":["couchdb@172.17.0.2","couchdb@172.17.0.3","couchdb@172.17.0.4"]}
{"all_nodes":["couchdb@172.17.0.2","couchdb@172.17.0.3","couchdb@172.17.0.4"],"cluster_nodes":["couchdb@172.17.0.2","couchdb@172.17.0.3","couchdb@172.17.0.4"]}