Changes

From SME Server
Jump to navigationJump to search
1,252 bytes added ,  15:34, 18 July 2022
Adding a admin user and templating
Line 36: Line 36:     
{{Warning box|Please check additional notes below before trying this section}}
 
{{Warning box|Please check additional notes below before trying this section}}
   
{{Warning box| Complete work in progress - here be Dragons!}}
 
{{Warning box| Complete work in progress - here be Dragons!}}
   Line 86: Line 85:     
  mongo --eval "printjson(rs.initiate())"
 
  mongo --eval "printjson(rs.initiate())"
 +
 +
===Other settings===
 +
 +
nano /etc/security/limits.conf
 +
 +
These settings are automatically added during installation
 +
 +
@mongod      soft        nproc      unlimited
 +
@mongod      hard      nproc        unlimited
 +
@mongod      soft      nofile      64000
 +
@mongod      hard      nofile      64000
 +
 +
Adding a user
 +
 +
https://www.linode.com/docs/guides/install-mongodb-on-centos-7/
 +
 +
use admin
 +
 +
db.createUser(
 +
  {
 +
    user: "admin",
 +
    pwd: "admin123",
 +
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
 +
  }
 +
)
 +
 +
show users
 +
 +
We can then set Mongo to force authenticaiotn when conneting.
 +
 +
nano /usr/lib/systemd/system/mongod.service.d/50koozali.conf
 +
 +
Add:
 +
 +
[Service]
 +
Environment="OPTIONS= --auth-f /etc/mongod.conf"
 +
 +
Restart Mongo
 +
 +
systemctl restart mongod
 +
 +
You should now need a password to login.
 +
 +
===Templating mongod.conf===
 +
 +
This is possible but we need to create a new file so we do not overwrite the original - otherwise yum/rpm will complain.
 +
 +
Something like /etc/mongo/mongod.conf
 +
 +
Template fragments in
 +
 +
/etc/e-smith/templates/etc/mongo/mongod.conf
 +
 +
We can then amend the systemd overrride
 +
 +
nano /usr/lib/systemd/system/mongod.service.d/50koozali.conf
 +
 +
Add this:
 +
 +
[Service]
 +
Environment="OPTIONS=-f /etc/mongod/mongod.conf"
 +
    
===Dump and restore===
 
===Dump and restore===

Navigation menu