mongodb is a noSQL database. I use it to construct the vd database.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list sudo apt-get update sudo apt-get install -y mongodb-org
sudo service mongod start
iptables -A INPUT -p tcp --dport 27017 -j ACCEPT
cat /var/log/mongodb/mongod.log
|
use subl /etc/mongod.conf
to edit the configuration of mongodb. The default file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
storage: dbPath: /var/lib/mongodb journal: enabled: true
systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log
net: port: 27017 bindIp: 127.0.0.1
|
After some edits:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
storage: dbPath: /var/lib/mongodb journal: enabled: true
systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log
net: port: 27017 bindIp: 127.0.0.1
security: authorization: enable
|
For security, to add admin user and create users:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| use admin
db.createUser( { user: "adminname", pwd: "password", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } )
db.createUser( { user: "adminname", pwd: "password", roles: [ { role: "dbOwner", db: "admin" } ] } )
db.createUser( { user: "adminname", pwd: "password", roles: [ { role: "readWriteAnyDatabase", db: "admin" } ] } )
db.createUser( { user: "adminname", pwd: "password", roles: [ { role: "read", db: "reporting" }, { role: "read", db: "products" }, { role: "read", db: "sales" }, { role: "readWrite", db: "accounts" } ] } )
|