Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create CouchDB Cluster
#!/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
@redgeoff
Copy link
Author

redgeoff commented Sep 22, 2018

Loading

@digglesby
Copy link

digglesby commented Apr 20, 2019

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.

Loading

@Chenjing-Yu
Copy link

Chenjing-Yu commented May 9, 2019

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?

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment