Last active
October 8, 2020 16:12
-
-
Save brantburnett/a6e601a7141e89bc47587b1e7b94bcdc to your computer and use it in GitHub Desktop.
Couchbase EC2 NVMe Userdata Script
This file contains 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 | |
# Include as user data during instance startup, or run as root using sudo | |
# Assumes that you are using an i3 instance type with NVMe instance storage attached | |
# Set swappiness to zero | |
sysctl vm.swappiness=0 | |
echo "vm.swappiness = 0" >> /etc/sysctl.conf | |
# Disable transparent huge pages | |
cat > /etc/init.d/disable-thp <<- 'EOM' | |
#!/bin/bash | |
### BEGIN INIT INFO | |
# Provides: disable-thp | |
# Required-Start: $local_fs | |
# Required-Stop: | |
# X-Start-Before: couchbase-server docker | |
# 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 | |
case $1 in | |
start) | |
if [ -d /sys/kernel/mm/transparent_hugepage ]; then | |
echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled | |
echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag | |
elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then | |
echo 'never' > /sys/kernel/mm/redhat_transparent_hugepage/enabled | |
echo 'never' > /sys/kernel/mm/redhat_transparent_hugepage/defrag | |
else | |
return 0 | |
fi | |
;; | |
esac | |
EOM | |
chmod 755 /etc/init.d/disable-thp | |
/etc/init.d/disable-thp start | |
chkconfig disable-thp on | |
# Mount the ephemeral storage (NVMe SSD instance storage) | |
mkfs -t ext4 /dev/nvme*n1 | |
mkdir -p /mnt/couchbase | |
mount -t ext4 /dev/nvme0n1 /mnt/couchbase | |
echo "/dev/nvme0n1 /mnt/couchbase ext4 defaults,noatime 0 0" | tee -a /etc/fstab | |
chmod 777 /mnt/couchbase | |
# Install Docker | |
yum -y update | |
yum install docker -y | |
service docker start | |
# Install Amazon SSM Agent | |
cd /tmp | |
sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm | |
# Run Couchbase 5.0.0-beta2 | |
docker run -d --name couchbase --network=host --restart=always \ | |
-v /mnt/couchbase:/opt/couchbase/var \ | |
--ulimit nofile=100000:100000 --ulimit core=100000000:100000000 --ulimit memlock=100000000:100000000 \ | |
couchbase/server:5.0.0-beta2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment