This repository was archived by the owner on Jan 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·97 lines (72 loc) · 2.84 KB
/
install.sh
File metadata and controls
executable file
·97 lines (72 loc) · 2.84 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
echo "Installing required packages"
# Remove files if any
sudo rm -rf mongo-c-driver-1.17.3
sudo rm -f mongo-c-driver-1.17.3.tar.gz
# Update the package index files
sudo apt-get update
# Run Upgrade
sudo apt-get -y upgrade
# Install required packages
sudo apt-get install -y build-essential
sudo apt-get install -y cmake
sudo apt-get install -y libssl-dev
sudo apt-get install -y zlib1g-dev
sudo apt-get install -y curl
# Required for Guid
sudo apt-get install -y uuid-dev
echo "Installing MongoDB"
# Import public key
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
# Create a list file for MongoDB
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
# Update the package index files
sudo apt-get update
# Install the latest version of MongoDB
sudo apt-get install -y mongodb-org
# Pin the packages at the currently installed versions
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
sudo systemctl daemon-reload
# Start MongoDB
sudo systemctl start mongod
echo "Installing MongoDB C Driver"
wget https://github.com/mongodb/mongo-c-driver/releases/download/1.17.3/mongo-c-driver-1.17.3.tar.gz
tar xzf mongo-c-driver-1.17.3.tar.gz
cd mongo-c-driver-1.17.3
mkdir cmake-build
cd cmake-build
cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..
cmake --build .
sudo cmake --build . --target install
echo "Installing MongoDB C++ Driver"
echo "Downloading MongoDB C++ Driver"
# Download the latest version of mongocxx driver
curl -OL https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.6.2/mongo-cxx-driver-r3.6.2.tar.gz
tar -xzf mongo-cxx-driver-r3.6.2.tar.gz
cd mongo-cxx-driver-r3.6.2/build
echo "Configuring MongoDB C++ Driver"
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local
echo "Building and Installing MongoDB C++ Driver"
sudo cmake --build . --target EP_mnmlstc_core
cmake --build .
sudo cmake --build . --target install
# Add usr/local/lib to the library path
# Used for shared libraries
sudo sh -c "printf '/usr/local/lib' > /etc/ld.so.conf.d/shared-library-path.conf"
sudo ldconfig
# Remove files
sudo rm -rf mongo-c-driver-1.17.3
sudo rm -f mongo-c-driver-1.17.3.tar.gz
# Stop mongod
sudo systemctl stop mongod
# Deploy a replica set
sudo mkdir -p /srv/mongodb/db0
sudo chown -R mongodb:mongodb /srv/mongodb/db0
sudo mongod --port 27017 --dbpath /srv/mongodb/db0 --replSet rs0 --bind_ip localhost --fork --logpath /var/log/mongod.log
mongo --eval "rs.initiate()"
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
echo "Installation complete!"