Skip to content

Commit

Permalink
Adding util_ms.sh for CMC to replace util.sh
Browse files Browse the repository at this point in the history
FormatDisk now adds a 32Gib swap file
referencing byol_2019 in parameters.json
  • Loading branch information
sliburd committed May 3, 2019
1 parent d87d8aa commit 25a6c3b
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 5 deletions.
9 changes: 7 additions & 2 deletions extensions/server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,25 @@ echo "Running couchbase-cli node-init"
--node-init-hostname=$nodeDNS \
--node-init-data-path=/datadisk/data \
--node-init-index-path=/datadisk/index \
--node-init-analytics-path=/datadisk/analytics \
--user=$adminUsername \
--pass=$adminPassword

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

echo "Running couchbase-cli cluster-init"
./couchbase-cli cluster-init \
--cluster=$nodeDNS \
--cluster-ramsize=$dataRAM \
--cluster-index-ramsize=$indexRAM \
--index-storage-setting=memopt \
--cluster-analytics-ramsize=$indexRAM \
--cluster-fts-ramsize=$indexRAM \
--cluster-eventing-ramsize=$indexRAM \
--cluster-username=$adminUsername \
--cluster-password=$adminPassword \
--services=data,index,query,fts,eventing,analytics
Expand Down
106 changes: 106 additions & 0 deletions extensions/util_ms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/usr/bin/env bash

adjustTCPKeepalive ()
{
# Azure public IPs have some odd keep alive behaviour

echo "Setting TCP keepalive..."
sysctl -w net.ipv4.tcp_keepalive_time=120

echo "Setting TCP keepalive permanently..."
echo "net.ipv4.tcp_keepalive_time = 120
" >> /etc/sysctl.conf
}

formatDataDisk ()
{
# This script formats and mounts the drive on lun0 as /datadisk
# It also sets the swap file to 32GB on /mnt which is the temporary disk on /dev/sdb

SWAPFILE="/mnt/swapFile.swap"

echo "Creating and formating a new swap file ..."

fallocate -l 1g ${SWAPFILE}
chmod 600 ${SWAPFILE}
echo "Formating the swap file ..."
mkswap ${SWAPFILE}
echo "Enabling the swap file ..."
swapon ${SWAPFILE}
echo "${SWAPFILE} swap swap defaults 0 0" | sudo tee -a /etc/fstab

DISK="/dev/disk/azure/scsi1/lun0"
PARTITION="/dev/disk/azure/scsi1/lun0-part1"
MOUNTPOINT="/datadisk"

echo "Partitioning the disk."
echo "g
n
p
1
t
83
w"| fdisk ${DISK}

echo "Waiting for the symbolic link to be created..."
udevadm settle --exit-if-exists=$PARTITION

echo "Creating the filesystem."
mkfs -j -t ext4 ${PARTITION}

echo "Updating fstab"
LINE="${PARTITION}\t${MOUNTPOINT}\text4\tnoatime,nodiratime,nodev,noexec,nosuid\t1\t2"
echo -e ${LINE} >> /etc/fstab

echo "Mounting the disk"
mkdir -p $MOUNTPOINT
mount -a

echo "Changing permissions"
chown couchbase $MOUNTPOINT
chgrp couchbase $MOUNTPOINT
}

turnOffTransparentHugepages ()
{
echo "#!/bin/bash
### BEGIN INIT INFO
# Provides: disable-thp
# Required-Start: $local_fs
# Required-Stop:
# X-Start-Before: couchbase-server
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Disable THP
# Description: disables Transparent Huge Pages (THP) on boot
### END INIT INFO
echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled
echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag
" > /etc/init.d/disable-thp
chmod 755 /etc/init.d/disable-thp
service disable-thp start
update-rc.d disable-thp defaults
}

setSwappinessToZero ()
{
sysctl vm.swappiness=0
echo "
# Required for Couchbase
vm.swappiness = 0
" >> /etc/sysctl.conf
}

addCBGroup ()
{
$username = $1
$password = $2
path = ${3-'/opt/couchbase/bin/'}
cli=${path}couchbase-cli group-manage
ls $path
$cli --username $username --password $password --create --group-name
#runs in the directory where couchbase is installed
}
4 changes: 2 additions & 2 deletions generator/deployment_ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def generateServer(region, group, vnetName, createVnet, subnetName, groupName, r
"settings": {
"fileUris": [
"[concat(variables('extensionUrl'), 'server_generator.sh')]",
"[concat(variables('extensionUrl'), 'util.sh')]"
"[concat(variables('extensionUrl'), 'util_ms.sh')]"
]
},
"protectedSettings": {
Expand Down Expand Up @@ -641,7 +641,7 @@ def generateSyncGateway(region, group, vnetName, createVnet, subnetName):
"settings": {
"fileUris": [
"[concat(variables('extensionUrl'), 'syncGateway.sh')]",
"[concat(variables('extensionUrl'), 'util.sh')]"
"[concat(variables('extensionUrl'), 'util_ms.sh')]"
]
},
"protectedSettings": {
Expand Down
2 changes: 1 addition & 1 deletion generator/parameters/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"value": "longpass12---"
},
"license": {
"value": "byol"
"value": "byol_2019"
},
"uniqueString": {
"value": "n4f5pbg2ayvjc"
Expand Down

0 comments on commit 25a6c3b

Please sign in to comment.