Skip to content

Commit 25a6c3b

Browse files
committed
Adding util_ms.sh for CMC to replace util.sh
FormatDisk now adds a 32Gib swap file referencing byol_2019 in parameters.json
1 parent d87d8aa commit 25a6c3b

File tree

4 files changed

+116
-5
lines changed

4 files changed

+116
-5
lines changed

extensions/server.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,25 @@ echo "Running couchbase-cli node-init"
6565
--node-init-hostname=$nodeDNS \
6666
--node-init-data-path=/datadisk/data \
6767
--node-init-index-path=/datadisk/index \
68+
--node-init-analytics-path=/datadisk/analytics \
6869
--user=$adminUsername \
6970
--pass=$adminPassword
7071

7172
if [[ $nodeIndex == "0" ]]
7273
then
7374
totalRAM=$(grep MemTotal /proc/meminfo | awk '{print $2}')
74-
dataRAM=$((50 * $totalRAM / 100000))
75-
indexRAM=$((15 * $totalRAM / 100000))
75+
dataRAM=$((45 * $totalRAM / 100000))
76+
indexRAM=$((8 * $totalRAM / 100000))
7677

7778
echo "Running couchbase-cli cluster-init"
7879
./couchbase-cli cluster-init \
7980
--cluster=$nodeDNS \
8081
--cluster-ramsize=$dataRAM \
8182
--cluster-index-ramsize=$indexRAM \
83+
--index-storage-setting=memopt \
84+
--cluster-analytics-ramsize=$indexRAM \
85+
--cluster-fts-ramsize=$indexRAM \
86+
--cluster-eventing-ramsize=$indexRAM \
8287
--cluster-username=$adminUsername \
8388
--cluster-password=$adminPassword \
8489
--services=data,index,query,fts,eventing,analytics

extensions/util_ms.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env bash
2+
3+
adjustTCPKeepalive ()
4+
{
5+
# Azure public IPs have some odd keep alive behaviour
6+
7+
echo "Setting TCP keepalive..."
8+
sysctl -w net.ipv4.tcp_keepalive_time=120
9+
10+
echo "Setting TCP keepalive permanently..."
11+
echo "net.ipv4.tcp_keepalive_time = 120
12+
" >> /etc/sysctl.conf
13+
}
14+
15+
formatDataDisk ()
16+
{
17+
# This script formats and mounts the drive on lun0 as /datadisk
18+
# It also sets the swap file to 32GB on /mnt which is the temporary disk on /dev/sdb
19+
20+
SWAPFILE="/mnt/swapFile.swap"
21+
22+
echo "Creating and formating a new swap file ..."
23+
24+
fallocate -l 1g ${SWAPFILE}
25+
chmod 600 ${SWAPFILE}
26+
echo "Formating the swap file ..."
27+
mkswap ${SWAPFILE}
28+
echo "Enabling the swap file ..."
29+
swapon ${SWAPFILE}
30+
echo "${SWAPFILE} swap swap defaults 0 0" | sudo tee -a /etc/fstab
31+
32+
DISK="/dev/disk/azure/scsi1/lun0"
33+
PARTITION="/dev/disk/azure/scsi1/lun0-part1"
34+
MOUNTPOINT="/datadisk"
35+
36+
echo "Partitioning the disk."
37+
echo "g
38+
n
39+
p
40+
1
41+
42+
43+
t
44+
83
45+
w"| fdisk ${DISK}
46+
47+
echo "Waiting for the symbolic link to be created..."
48+
udevadm settle --exit-if-exists=$PARTITION
49+
50+
echo "Creating the filesystem."
51+
mkfs -j -t ext4 ${PARTITION}
52+
53+
echo "Updating fstab"
54+
LINE="${PARTITION}\t${MOUNTPOINT}\text4\tnoatime,nodiratime,nodev,noexec,nosuid\t1\t2"
55+
echo -e ${LINE} >> /etc/fstab
56+
57+
echo "Mounting the disk"
58+
mkdir -p $MOUNTPOINT
59+
mount -a
60+
61+
echo "Changing permissions"
62+
chown couchbase $MOUNTPOINT
63+
chgrp couchbase $MOUNTPOINT
64+
}
65+
66+
turnOffTransparentHugepages ()
67+
{
68+
echo "#!/bin/bash
69+
### BEGIN INIT INFO
70+
# Provides: disable-thp
71+
# Required-Start: $local_fs
72+
# Required-Stop:
73+
# X-Start-Before: couchbase-server
74+
# Default-Start: 2 3 4 5
75+
# Default-Stop: 0 1 6
76+
# Short-Description: Disable THP
77+
# Description: disables Transparent Huge Pages (THP) on boot
78+
### END INIT INFO
79+
80+
echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled
81+
echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag
82+
" > /etc/init.d/disable-thp
83+
chmod 755 /etc/init.d/disable-thp
84+
service disable-thp start
85+
update-rc.d disable-thp defaults
86+
}
87+
88+
setSwappinessToZero ()
89+
{
90+
sysctl vm.swappiness=0
91+
echo "
92+
# Required for Couchbase
93+
vm.swappiness = 0
94+
" >> /etc/sysctl.conf
95+
}
96+
97+
addCBGroup ()
98+
{
99+
$username = $1
100+
$password = $2
101+
path = ${3-'/opt/couchbase/bin/'}
102+
cli=${path}couchbase-cli group-manage
103+
ls $path
104+
$cli --username $username --password $password --create --group-name
105+
#runs in the directory where couchbase is installed
106+
}

generator/deployment_ms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def generateServer(region, group, vnetName, createVnet, subnetName, groupName, r
533533
"settings": {
534534
"fileUris": [
535535
"[concat(variables('extensionUrl'), 'server_generator.sh')]",
536-
"[concat(variables('extensionUrl'), 'util.sh')]"
536+
"[concat(variables('extensionUrl'), 'util_ms.sh')]"
537537
]
538538
},
539539
"protectedSettings": {
@@ -641,7 +641,7 @@ def generateSyncGateway(region, group, vnetName, createVnet, subnetName):
641641
"settings": {
642642
"fileUris": [
643643
"[concat(variables('extensionUrl'), 'syncGateway.sh')]",
644-
"[concat(variables('extensionUrl'), 'util.sh')]"
644+
"[concat(variables('extensionUrl'), 'util_ms.sh')]"
645645
]
646646
},
647647
"protectedSettings": {

generator/parameters/parameters.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"value": "longpass12---"
1313
},
1414
"license": {
15-
"value": "byol"
15+
"value": "byol_2019"
1616
},
1717
"uniqueString": {
1818
"value": "n4f5pbg2ayvjc"

0 commit comments

Comments
 (0)