Created
September 22, 2018 20:45
-
-
Save redgeoff/5099f46ae63acbd8da1137e2ed436a7c to your computer and use it in GitHub Desktop.
Create CouchDB Cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: create-cluster.sh user password port local-port space-separated-ips | |
user=$1 | |
password=$2 | |
port=$3 | |
localPort=$4 | |
ips=$5 | |
firstIp=1 | |
for ip in $ips; do | |
if [ "$firstIp" == "1" ]; then | |
echo "First IP=$ip" | |
firstIp=$ip | |
else | |
echo "Registering membership for $ip" | |
curl -X PUT http://$user:$password@$firstIp:$localPort/_nodes/couchdb@$ip -d {} | |
fi | |
done | |
# Create system DBs | |
echo "Creating _users" | |
curl -X PUT http://$user:$password@$firstIp:$port/_users | |
echo "Creating _replicator" | |
curl -X PUT http://$user:$password@$firstIp:$port/_replicator | |
echo "Creating _global_changes" | |
curl -X PUT http://$user:$password@$firstIp:$port/_global_changes |
Hey thanks for this and your article on CouchDB clusters!
I found a slight bug with this script where if you provide a password with an @ character is confuses curl, but if you use curl -X PUT --user $user:$password http://$firstIp:$localPort/_nodes/couchdb@$ip -d {}
it fixes the issue.
This article helped me a lot!
One more question:
Do we have any tutorial about adding another CouchDB container in the docker, mounting on another volume, and then adding it into the cluster created above?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: used by Running a CouchDB 2 Cluster in Production on AWS with Docker