---
# System prepended metadata

title: Setup MongoDB factory server
tags: [Database]

---

---
tags: Database
---


#  Setup MongoDB factory server

### OS detail
```
root@test-Factory-DB:/home/test# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.2 LTS
Release:	22.04
Codename:	jammy
```

### Install SSH 

1. Verify ssh 
```
ssh localhost
```
2. update 
```
sudo apt-get update
```
3. Install ssh server
```
sudo apt-get install openssh-server
```
4. Verify ssh service
```
sudo service ssh status
```

### Install mongoDB

***step1:***Import the public key used by the package management system.¶
```wget -qO - https://www.mongodb.org/static/pgp/server-3.6.asc | sudo apt-key add -```

***step2:***Create a list file for MongoDB.
```echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list```

***step3:***update
```sudo apt-get update```

***step4:***
```sudo apt-get install -y mongodb-org=3.6.23 mongodb-org-server=3.6.23 mongodb-org-shell=3.6.23 mongodb-org-mongos=3.6.23 mongodb-org-tools=3.6.23```

[***Follow this wepage for mongoDB installation doubts***](https://www.mongodb.com/docs/v3.6/tutorial/install-mongodb-on-ubuntu/)
### Fix update issue
```
mkdir ~/solution
cd ~/solution/

cat << EOF > ~/solution/sources.list
deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

deb http://archive.canonical.com/ubuntu focal partner
deb-src http://archive.canonical.com/ubuntu focal partner
EOF

sudo sed -i "s/focal/$(lsb_release -c -s)/" ~/solution/sources.list
sudo rm /etc/apt/sources.list
sudo cp ~/solution/sources.list /etc/apt/sources.list

sudo mv /etc/apt/sources.list.d/* ~/solution

```


### Reference 

1. https://www.mongodb.com/docs/v3.6/tutorial/install-mongodb-on-ubuntu/
2. https://www.mongodb.com/docs/v3.6/tutorial/install-mongodb-on-ubuntu/
