https://www.youtube.com/watch?v=pWbMrx5rVBE
sudo su
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
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
apt update
sudo apt install -y mongodb-org
systemctl start mongodb
docker run -p 27017:27017 -d mongo:5.0-focal
curl https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2004-x86_64-100.3.0.deb -O
sudo apt install ./mongodb-database-tools-ubuntu2004-x86_64-100.3.0.deb
mkdir mongosh
cd mongosh
curl https://downloads.mongodb.com/compass/mongosh-0.8.3-linux.tgz -O
tar -zxvf mongosh-0.8.3-linux.tgz
chmod +x bin/mongosh
sudo ln -s /home/atlex/mongosh/bin/mongosh /usr/local/bin/
mongosh --host localhost --port 27017
# mongosh --host remote.atlex00.com --port 27017 --username mymongouser
> show dbs
admin 32.8 kB
config 12.3 kB
local 32.8 kB
> show users
[]
> use newdb;
switched to db newdb
> show collections;
> db.createCollection("mycollection") ;
{ ok: 1 }
> show collections
mycollection
> db.mycollection.insert( {field:"first", second:"third"} );
DeprecationWarning: Collection.insert() is deprecated. Use insertOne, insertMany or bulkWrite.
{
acknowledged: true,
insertedIds: { '0': ObjectId("604608c3a330a2ccdfb207dc") }
}
> db.mycollection.find();
[
{
_id: ObjectId("604608c3a330a2ccdfb207dc"),
field: 'first',
second: 'third'
}
]
> db.dropDatabase();
> quit()
https://www.mongodb.com/basics/clusters
oplog
(operation log).# Check replica sets status
> rs.status()