-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-mongo.sh
22 lines (22 loc) · 1.04 KB
/
install-mongo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Installing Mongo DB
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list -y
sudo apt-get -qq update
sudo apt-get -o Dpkg::Use-Pty=0 -qq install mongodb nano -y
sudo cp /home/deploy/script/mongodb.service /etc/systemd/system/mongodb.service
mkdir /srv/mongodb
mkdir /srv/mongodb/db0
sudo chown -R mongodb /srv/mongodb/db0
echo "#################### CHECKING CLUSTER FOLDER CREATION ####################"
ls /srv/mongodb
echo "#################### REGISTERING SERVICE ####################"
sudo systemctl daemon-reload
sudo systemctl stop mongodb.service
sudo systemctl start mongodb.service
sudo systemctl enable mongodb.service
sudo systemctl status mongodb.service
echo "#################### STARTING MONGO CLUSTER ####################"
sleep 5
export LC_ALL=C
sudo mongo --eval 'printjson(rs.initiate({_id: "rs0", members:[{_id : 0, host : "127.0.0.1:27017"}]}))'
sudo mongo --eval 'printjson(rs.status())'