The custom upstart script should be a part of the elements, as it is OS specific. This requires 2 parts - add the code to the elements (here), and remove the code from trove (follow-up). Partial-Bug: 1493515 Change-Id: I0ae98f173058cae6b9e0eee440318f0277972503
66 lines
1.9 KiB
Bash
Executable File
66 lines
1.9 KiB
Bash
Executable File
#!/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
|
|
|
|
# MongoDB configuration settings
|
|
# use the default bindIP
|
|
sed -i '/bindIp/d' /etc/mongod.conf
|
|
# need to use smallFiles until the device is mounted
|
|
sed -i 's/# mmapv1:/ mmapv1:\n smallFiles: true/' /etc/mongod.conf
|
|
|
|
cat > "/etc/init/mongos.conf" << '_EOF_'
|
|
limit fsize unlimited unlimited # (file size)
|
|
limit cpu unlimited unlimited # (cpu time)
|
|
limit as unlimited unlimited # (virtual memory size)
|
|
limit nofile 64000 64000 # (open files)
|
|
limit nproc 64000 64000 # (processes/threads)
|
|
|
|
pre-start script
|
|
mkdir -p /var/log/mongodb/
|
|
end script
|
|
|
|
start on runlevel [2345]
|
|
stop on runlevel [06]
|
|
|
|
script
|
|
ENABLE_MONGOS="yes"
|
|
if [ -f /etc/default/mongos ]
|
|
then
|
|
. /etc/default/mongos
|
|
fi
|
|
if [ "x$ENABLE_MONGOS" = "xyes" ]
|
|
then
|
|
exec start-stop-daemon --start --quiet --chuid mongodb \
|
|
--exec /usr/bin/mongos -- --config /etc/mongod.conf
|
|
fi
|
|
end script
|
|
_EOF_
|