-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathubuntu-mongo-install.sh
61 lines (41 loc) · 1.89 KB
/
ubuntu-mongo-install.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
#!/bin/bash
#################################
# MOUNT DISK
#################################
#echo -e "n p 1 \n \n t c a 1 w" | fdisk /dev/xvdc
(echo n; echo p; echo 1; echo ; echo; echo t; echo c; echo a; echo 1;echo w) | sudo fdisk /dev/xvdc
mkfs.ext3 /dev/xvdc1
mkdir /mongodb
sed -i '$ a /dev/xvdc1\t/mongodb\text3\tdefaults\t0\t0' /etc/fstab
#echo -e "/dev/xvdc1\t/mongodb\text3\tdefaults\t0\t0" >> /etc/fstab
#echo -e "/dev/xvdc1" >> /etc/fstab
#echo -e -n "\t" >> /etc/fstab #INSERT TAB
#echo -n "/mongodb" >> /etc/fstab
#echo -e -n "\t" >> /etc/fstab #INSERT TAB
#echo -n "ext3" >> /etc/fstab
#echo -e -n "\t" >> /etc/fstab #INSERT TAB
#echo -n "defaults" >> /etc/fstab
#echo -e -n "\t" >> /etc/fstab #INSERT TAB
#echo -n "0" >> /etc/fstab
#echo -e -n "\t" >> /etc/fstab #INSERT TAB
#echo -n "0" >> /etc/fstab
mount /dev/xvdc1 /mongodb
####################################
# INSTALL MONGO / MONGO ENTERPRISE
####################################
sudo 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" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
echo "deb http://repo.mongodb.com/apt/ubuntu "$(lsb_release -sc)"/mongodb-enterprise/stable multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list
sudo apt-get update
#sudo apt-get install -y mongodb-org
sudo apt-get install -y mongodb-enterprise
mkdir /mongodb/data
sed -i 's/dbpath=\/var\/lib\/mongodb/dbpath=\/mongodb\/data/' /etc/mongod.conf
sed -i 's/bind_ip/#bind_ip/' /etc/mongod.conf
sudo chown mongodb -R /mongodb
sudo chown mongodb -R /mongodb/data
sudo service mongod restart
sleep 2s
mongo admin --eval 'db.createUser({user:"mongoadmin",pwd:"mongopassword",roles:[{role:"userAdminAnyDatabase", db: "admin"}]})'
sed -i 's/#auth = true/auth = true/' /etc/mongod.conf
sudo service mongod restart