-
-
Notifications
You must be signed in to change notification settings - Fork 28
5 Mongodb Database
Tomato6966 edited this page Nov 25, 2022
·
2 revisions
This is a SELF HOSTING GUIDE for MONGODB
Mongodb self hosting cheat sheet for ubuntu 18.04
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 bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt-get update -y # updated packages
sudo apt-get install -y mongodb-org=4.4.8 mongodb-org-server=4.4.8 mongodb-org-shell=4.4.8 mongodb-org-mongos=4.4.8 mongodb-org-tools=4.4.8
If you're on ubuntu 20. swap the
echo "deb...
Command with this: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
if you encounter any error while starting,
Make sure to maybe adjust the port
27017
and the path file name
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
sudo service mongod restart # Restart mongodb
Access start/stop etc. the mongodb
systemctl start mongod # Start mongod via systemd
systemctl restart mongod # Restart mongod via systemd
systemctl stop mongod # Stop mongod via systemd
systemctl status mongod # Show the status of mongod via systemd
service mongod start # Start mongod via service (should always work)
service mongod stop # Stop mongod via service (should always work)
Add a user to the db with root access:
make sure that mongodb is running
> mongo
> use admin
> db.createUser(
{
user: "useradmin",
pwd: "thepianohasbeendrinking",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
Example /etc/mongod.conf File
Make sure to enable security.authorization AFTER You added a user (restart the db)
mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
engine: "wiredTiger"
wiredTiger:
engineConfig:
cacheSizeGB: 8 # Size of RAM CACHE (Default: 0.5*(50% - 1))
journalCompressor: "zlib" # Default "snappy" | Options: "none", "snappy", "zlib", "zstd"
directoryForIndexes: false # Default "false" | Options: true, false
collectionConfig:
blockCompressor: "zlib"
indexConfig:
prefixCompression: true
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
# how the process runs
processManagement:
fork: false
timeZoneInfo: /usr/share/zoneinfo
security:
authorization: "enabled"
-
1 All needed Console Commands
- 1.1 Directory Navigation
- 1.2 System Information
- 1.3 Hardware Information
- 1.4 File and Directory Cmds
- 1.5 Process Management
- 1.6 File Permissions
- 1.7 Networking
- 1.8 Archives (Tar Files)
- 1.9 Search
- 1.10 File Transfers
- 1.11 Disk Usage
- 1.12 User Information and Management
- 1.13 Speedtest
- 1.14 Clear Cache
- 1.15 Disable Sleeping Processes (Suspending)
- 1.16 Remove Welcome Message