Skip to content

Commit

Permalink
Files for beta simple test. More for allowing for analytic nodes to b…
Browse files Browse the repository at this point in the history
…e paramaterized in mainTemplateParamaters_beta.json
  • Loading branch information
sliburd committed Sep 13, 2018
1 parent 0a4fe31 commit ed5934e
Show file tree
Hide file tree
Showing 4 changed files with 606 additions and 0 deletions.
127 changes: 127 additions & 0 deletions extensions/server_beta.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/usr/bin/env bash

echo "Running server.sh"

version=$1
adminUsername=$2
adminPassword=$3
uniqueString=$4
location=$5
analyticsNodesMod=$6

echo "Using the settings:"
echo version \'$version\'
echo adminUsername \'$adminUsername\'
echo adminPassword \'$adminPassword\'
echo uniqueString \'$uniqueString\'
echo location \'$location\'

echo "Installing prerequisites..."
apt-get update
apt-get -y install python-httplib2
apt-get -y install jq

echo "Installing Couchbase Server..."
wget http://packages.couchbase.com/releases/${version}/couchbase-server-enterprise_${version}-ubuntu14.04_amd64.deb
dpkg -i couchbase-server-enterprise_${version}-ubuntu14.04_amd64.deb
apt-get update
apt-get -y install couchbase-server

echo "Calling util.sh..."
source util.sh
formatDataDisk
turnOffTransparentHugepages
setSwappinessToZero
adjustTCPKeepalive

echo "Configuring Couchbase Server..."

# We can get the index directly with this, but unsure how to test for sucess. Come back to later...
#nodeIndex = `curl -H Metadata:true "http://169.254.169.254/metadata/instance/compute/name?api-version=2017-04-02&format=text"`
# good example here https://github.com/bonggeek/Samples/blob/master/imds/imds.sh

nodeIndex="null"
while [[ $nodeIndex == "null" ]]
do
nodeIndex=`curl -H Metadata:true "http://169.254.169.254/metadata/instance/compute?api-version=2017-04-02" \
| jq ".name" \
| sed 's/.*_//' \
| sed 's/"//'`
done

nodeDNS='vm'$nodeIndex'.server-'$uniqueString'.'$location'.cloudapp.azure.com'
rallyDNS='vm0.server-'$uniqueString'.'$location'.cloudapp.azure.com'

echo "Adding an entry to /etc/hosts to simulate split brain DNS..."
echo "
# Simulate split brain DNS for Couchbase
127.0.0.1 ${nodeDNS}
" >> /etc/hosts

cd /opt/couchbase/bin/

echo "Running couchbase-cli node-init"
./couchbase-cli node-init \
--cluster=$nodeDNS \
--node-init-hostname=$nodeDNS \
--node-init-data-path=/datadisk/data \
--node-init-index-path=/datadisk/index \
--user=$adminUsername \
--pass=$adminPassword

if [[ $nodeIndex == "0" ]]
then
totalRAM=$(grep MemTotal /proc/meminfo | awk '{print $2}')
dataRAM=$((50 * $totalRAM / 100000))
indexRAM=$((15 * $totalRAM / 100000))

echo "Running couchbase-cli cluster-init"
./couchbase-cli cluster-init \
--cluster=$nodeDNS \
--cluster-ramsize=$dataRAM \
--cluster-index-ramsize=$indexRAM \
--cluster-username=$adminUsername \
--cluster-password=$adminPassword \
--services=data,index,query,fts,analytics
else
echo "Running couchbase-cli server-add"
output=""
while [[ $output != "Server $nodeDNS:8091 added" && ! $output =~ "Node is already part of cluster." ]]
do
if [[ (analyticsNodesMod % ($nodeIndex + 1)) -ne 0 ]]
then
output=`./couchbase-cli server-add \
--cluster=$rallyDNS \
--user=$adminUsername \
--pass=$adminPassword \
--server-add=$nodeDNS \
--server-add-username=$adminUsername \
--server-add-password=$adminPassword \
--services=data,index,query,fts`
else
output=`./couchbase-cli server-add \
--cluster=$rallyDNS \
--user=$adminUsername \
--pass=$adminPassword \
--server-add=$nodeDNS \
--server-add-username=$adminUsername \
--server-add-password=$adminPassword \
--services=analytics`
fi
echo server-add output \'$output\'
sleep 10
done

echo "Running couchbase-cli rebalance"
output=""
while [[ ! $output =~ "SUCCESS" ]]
do
output=`./couchbase-cli rebalance \
--cluster=$rallyDNS \
--user=$adminUsername \
--pass=$adminPassword`
echo rebalance output \'$output\'
sleep 10
done

fi
6 changes: 6 additions & 0 deletions simple/deploy_beta.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

RESOURCE_GROUP=$1

az group create --name $RESOURCE_GROUP --location westus --output table
az group deployment create --verbose --template-file mainTemplate_beta.json --parameters @mainTemplateParameters_beta.json --resource-group $RESOURCE_GROUP --output table
32 changes: 32 additions & 0 deletions simple/mainTemplateParameters_beta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"serverNodeCount": {
"value": 2
},
"analyticsNodeCount": {
"value": 2
},
"serverDiskSize": {
"value": 32
},
"serverVersion": {
"value": "6.0.0-beta"
},
"syncGatewayNodeCount": {
"value": 0
},
"syncGatewayVersion": {
"value": "2.1.0"
},
"vmSize": {
"value": "Standard_DS3_v2"
},
"adminUsername": {
"value": "couchbase"
},
"adminPassword": {
"value": "foo123!"
},
"license": {
"value": "byol"
}
}
Loading

0 comments on commit ed5934e

Please sign in to comment.