Created
April 1, 2024 04:35
-
-
Save patterns/3205b8784142673b2b8254b5d8b43fe8 to your computer and use it in GitHub Desktop.
Mongodb install steps inside LXD container on rpi4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# MongoDB official community ed discontinued support of raspberry pi after mongod 4.4 | |
# We tried their steps from https://www.mongodb.com/docs/v4.4/tutorial/install-mongodb-on-ubuntu/ | |
# and the result is core dump; didn't matter for 20.04/18.04 images, all core dumps. | |
# Lesson learned, just use the old apt package provided by Ubuntu. | |
lxc launch ubuntu:20.04 mdb | |
lxc exec mdb -- bash | |
#apt update | |
#apt upgrade | |
#apt install mongodb -y | |
#systemctl status mongodb | |
## some steps differ from https://www.digitalocean.com/community/tutorials/how-to-secure-mongodb-on-ubuntu-20-04 | |
#mongo | |
> use admin | |
> db.createUser({user: "ADMIN", pwd: "ADMIN", roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]}) | |
> exit | |
#vi /etc/mongod.conf | |
## uncomment the line with "auth=true" to enable authentication | |
#systemctl restart mongodb | |
#mongo -u ADMIN -p --authenticationDatabase admin | |
## type ADMIN for the password when prompted | |
> db = db.getSiblingDB('DV-DB'); | |
> db.createUser({ user: 'DV-TESTER', pwd: 'DV-PASSWORD', roles: [{ role: 'readWrite', db: 'DV-DB' }] }) | |
> db.createCollection('enrollment'); | |
> exit | |
## this login can be used with URI "mongodb://DV-TESTER:DV-PASSWORD@127.0.0.1:27017/DV-DB" | |
## to allow pass-thru connections from the host os to the container see | |
#sudo lxc config device add web mdbport27017 proxy listen=tcp:0.0.0.0:27017 connect=tcp:127.0.0.1:27017 | |
## if the machine has LAN DHCP IP assigned 10.11.12.13 | |
## then the URI becomes "mongodb://DV-TESTER:DV-PASSWORD@10.11.12.13:27017/DV-DB" | |
## and should be available to the LAN clients without firewall changes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see linode tutorial for the
lxc config device proxy
command -- https://www.linode.com/docs/guides/beginners-guide-to-lxd/