Sunday, December 29, 2019

Running MongoDB on ChromeOS (via Crostini)

In my previous post I explored Linux application support in ChromeOS and Chromebooks (a.k.a. Crostini). Of course I was bound to try running MongoDB in this environment, which I found to work really well (for development purposes). Here's my notes on running a MongoDB database and tools on a Chromebook with Linux (beta) enabled:
  • In ChromeOS, launch the Terminal app (which opens a Shell inside the 'Penguin' Linux container inside the 'Termina' Linux VM)
  • Run the following commands which are documented in the MongoDB Manual page on installing MongoDB Enterprise on Debian (following the manual's tab instructions titled “Debian 9 "Stretch”):
wget -qO - | sudo apt-key add -
echo "deb stretch/mongodb-enterprise/4.2 main" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list
sudo apt-get update
sudo apt-get install -y mongodb-enterprise
  • Start a MongoDB database instance running:
mkdir ~/data
mongod --dbpath ~/data
  • Launch a second Terminal window and then run the Mongo Shell against this database and perform a quick database insert and query test:

  • Install Python 3 and the PIP Python package manager (using Anaconda) and then install the MongoDB Python driver (PyMongo):
bash Anaconda3-*
source ~/.bashrc
python --version
pip --version
pip install --user pymongo
  • Test PyMongo by running a small ‘payments data generator’ Python script pulled down from a GitHub repository (this should insert records into the MongoDB local database’s “fs.payments” collection; after letting it run for a minute, continuously inserting new records, press Ctrl-C to stop it):
git clone
cd PaymentsWriteReadConcerns/
./ -p 1
  • Download MongoDB Compass (use the Ubuntu 64-bit 14.04+ version), install and run it against the 'localhost' MongoDB database and inspect the contents of the “fs.payments” collection:
sudo apt install ./mongodb-compass_*_amd64.deb

Song for today: Sun. Tears. Red by Jambinai

1 comment:

Paul Done said...

Just tested on latest version of ChromeOS & Linux it bundles at of 31-Oct-2020. This version now uses Debian 10 (Buster).

As a result, the changes to installation are:

* Follow this for installing MongoDB: (choose Debian 10 "Buster" tab)
* Python3 is already installed, to see version run: $ python3 --version
* To install pip run: $ sudo apt install python3-pip
* To see pip version run: $ pip3 --version
* To install PyMongo run: $ pip3 install --user pymongo