Changes

Jump to navigation Jump to search
1,335 bytes added ,  23:33, 8 April 2016
Line 4: Line 4:  
  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
 
  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 update
 +
==== Client and Server ====
 
  sudo apt-get install -y mongodb-org
 
  sudo apt-get install -y mongodb-org
 +
==== Client only ====
 +
sudo apt-get install mongodb-clients
 
Check if service is active
 
Check if service is active
 
  sudo systemctl status mongd
 
  sudo systemctl status mongd
Line 70: Line 73:  
  <nowiki>security:
 
  <nowiki>security:
 
   authorization: enabled</nowiki>
 
   authorization: enabled</nowiki>
 +
==== Add user roles ====
 +
<nowiki>use reporting
 +
db.grantRolesToUser(
 +
    "reportsUser",
 +
    [
 +
      { role: "read", db: "accounts" }
 +
    ]
 +
)</nowiki>
 +
==== Revoke user roles ====
 +
<nowiki>use reporting
 +
db.revokeRolesFromUser(
 +
    "reportsUser",
 +
    [
 +
      { role: "readWrite", db: "accounts" }
 +
    ]
 +
)</nowiki>
 +
 +
==== Create User ====
 +
<nowiki>use test
 +
db.createUser(
 +
    {
 +
      user: "tester",
 +
      pwd: "password",
 +
      roles: [
 +
        { role: "read", db: "test1" },
 +
        { role: "read", db: "test2" },
 +
        { role: "read", db: "test3" },
 +
        { role: "readWrite", db: "test" }
 +
      ]
 +
    }
 +
);</nowiki>
 +
or
 +
<nowiki>use products
 +
db.addUser( { user: "Alice",
 +
              pwd: "Moon1234",
 +
              roles: [ "readWrite", "dbAdmin" ]
 +
            } )</nowiki>
 +
or
 +
<nowiki>db.createUser(
 +
...        {
 +
...          user: "....",
 +
...          pwd: ".........",
 +
...          roles: [ "readWrite" ]
 +
...        }
 +
... )
 +
</nowiki>
 +
 +
==== Drop User ====
 +
<nowiki>db.dropUser(username)}</nowiki>
 +
 +
=== Enable remote connections ===
 +
* Edit /etc/mongodb.conf
 +
* Add the ip's you whish to enable for remote access to bind_ip separated by ',' (Dont remove 127.0.0.1!!)
 +
bind_ip = 127.0.0.1,192.168.56.222
 +
 
=== Disable Transparent Huge Pages (THP) ===
 
=== Disable Transparent Huge Pages (THP) ===
 
Create the init.d script.<br />
 
Create the init.d script.<br />
Line 110: Line 168:  
Distribution Command<br />
 
Distribution Command<br />
   −
Ubuntu and Debian sudo update-rc.d disable-transparent-hugepages defaults<br />
+
Ubuntu and Debian <nowiki>sudo update-rc.d disable-transparent-hugepages defaults</nowiki><br />
SUSE sudo insserv /etc/init.d/disable-transparent-hugepages<br />
+
SUSE <nowiki>sudo insserv /etc/init.d/disable-transparent-hugepages</nowiki><br />
Red Hat, CentOS, Amazon Linux, and derivatives sudo chkconfig --add disable-transparent-hugepages<br />
+
Red Hat, CentOS, Amazon Linux, and derivatives <nowiki>sudo chkconfig --add disable-transparent-hugepages</nowiki><br />
    
== Start/Stop/Restart MongoDB ==
 
== Start/Stop/Restart MongoDB ==
Line 187: Line 245:  
#::    user: "myUserAdmin",
 
#::    user: "myUserAdmin",
 
#::    pwd: "abc123",
 
#::    pwd: "abc123",
#::    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
+
#::    roles: [ { role: "root", db: "admin" } ]
 
#::  }
 
#::  }
 
#::)</pre>
 
#::)</pre>

Navigation menu