summaryrefslogtreecommitdiff
path: root/scripts/files/elements/ubuntu-mongodb/install.d/10-mongodb
blob: b32f1483940b584f64fd597961e43c5351ec0a5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh

# CONTEXT: GUEST during CONSTRUCTION as ROOT
# PURPOSE: Install controller base required packages

set -e
set -o xtrace

export DEBIAN_FRONTEND=noninteractive

cat > "/etc/rc.local" << _EOF_
# Make sure to disable Linux kernel feature transparent huge pages,
# it will affect greatly both memory usage and latency in a negative way.
# See: http://docs.mongodb.org/manual/tutorial/transparent-huge-pages/
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
  echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
  echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi

exit \$?

_EOF_

# see http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" \
    | tee /etc/apt/sources.list.d/mongodb-org-3.0.list
apt-get update
apt-get install -y mongodb-org

# the following config changes are needed: smallfiles set to true, and bind_ip
# set to default
sed -i '/bind_ip/d' /etc/mongod.conf
sed -i '/smallfiles/d' /etc/mongod.conf
echo 'smallfiles = true' >> /etc/mongod.conf