forked from T-NOVA/TeNOR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallation_mongodb.sh
executable file
·71 lines (53 loc) · 2 KB
/
installation_mongodb.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# +-----------------+
# | Install MongoDB |
# +-----------------+
echo "Started installation of MongoDB"
# Import public key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
# Create a list file
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
# Reload local package database
sudo apt-get update
# Install the latest stable version
sudo apt-get install -y mongodb-org
# Change MongoDB configuration to accept external connections
sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mongod.conf
# +--------------------------------------+
# | Disable Transparent Huge Pages (THP) |
# +--------------------------------------+
echo "Disabling Transparent Huge Pages (THP)"
echo 'never' | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
echo 'never' | sudo tee /sys/kernel/mm/transparent_hugepage/defrag
## Create the init script to disable transparent hugepages (THP)
cat > /tmp/disable-transparent-hugepages << EOF
#!/bin/sh
### BEGIN INIT INFO
# Provides: disable-transparent-hugepages
# Required-Start: $local_fs
# Required-Stop:
# X-Start-Before: mongod mongodb-mms-automation-agent
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description: Disable Linux transparent huge pages, to improve
# database performance.
### END INIT INFO
case $1 in
start)
thp_path=/sys/kernel/mm/transparent_hugepage
echo 'never' > ${thp_path}/enabled
echo 'never' > ${thp_path}/defrag
unset thp_path
;;
esac
EOF
# Copy the init script to init.d folder
sudo mv /tmp/disable-transparent-hugepages /etc/init.d/disable-transparent-hugepages
# Make it executable
sudo chmod 755 /etc/init.d/disable-transparent-hugepages
# Configure Ubuntu to run it on boot
sudo update-rc.d disable-transparent-hugepages defaults
echo "Restarting mongod service"
sudo service mongod restart
echo "Installation completed"