This repository has been archived by the owner on Mar 14, 2023. It is now read-only.
forked from zeroc0d3/ruby-deploy-gcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration MongoDB
ZeroC0D3 Team edited this page Jan 26, 2018
·
1 revision
- Make database folder
/data/mongodb
sudo mkdir -p /data/mongodb
sudo chmod 777 /data/mongodb
- Change configuration path database mongo
sudo nano /etc/mongodb.conf
-------
# dbPath: /var/lib/mongodb
dbPath: /data/mongodb
- Default Port Connection
# network interfaces
net:
port: 31399
bindIp: 127.0.0.1
- Enable authorization
sudo nano /etc/mongodb.conf
-------
security:
authorization: "enabled"
- Default Configuration
mongo port : 31399
mongo auth:
admin :
user: "mongo_root"
pass: "r00t_p4ssw0rd"
role: root
db_mongo :
user: "mongo_user
pass: "us3r_p4ssw0rd"
role: read & write -> db_mongo db
- Setup Authentification User
mongo
use [db_name]
db.createUser({user: "[username]", pwd: "[password]", roles: [ { role: "[roles_name]", db: "[db_name]" } ]})
show collections
-------
use admin
db.createUser({user: "mongo_root", pwd: "r00t_p4ssw0rd", roles: [ { role: "root", db: "admin" } ]})
show collections
use db_mongo
db.createUser({user: "mongo_user", pwd: "us3r_p4ssw0rd", roles: [ { role: "readWrite", db: "db_mongo" } ]})
show collections
- Restart MongoDB Services (with new configuration)
ps aux | grep -i mongod | awk {'print $2'} | sudo xargs kill -9
sudo mongod --fork --config /etc/mongod.conf
mongo mongodb://127.0.0.1:[port] -u [username] -p --authenticationDatabase [db_name]
[ENTER PASSWORD]
-------
mongo mongodb://127.0.0.1:31399 -u mongo_root -p --authenticationDatabase admin
mongo mongodb://127.0.0.1:31399 -u mongo_user -p --authenticationDatabase db_mongo
# 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
dbPath: /data/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 31399
bindIp: 127.0.0.1
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
security:
authorization: "enabled"
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
- Configuration MongoDB at
config/mongoid.yml
#################################
# MongoDB #
#################################
development:
# Configure available database sessions. (required)
clients:
default:
uri: 'mongodb://mongo_user:[email protected]:31399/db_mongo'
options:
consistency: :strong
max_retries: 30
retry_interval: 1
timeout: 15
test:
clients:
default:
database: db_mongo
hosts:
- localhost:31399
options:
read: primary
# In the test environment we lower the retries and retry interval to
# low amounts for fast failures.
max_retries: 1
retry_interval: 0
production:
# Configure available database sessions. (required)
clients:
default:
# The standard MongoDB connection URI allows for easy replica set
# connection setup.
# Use environment variables or a config file to keep your
# credentials safe.
uri: 'mongodb://mongo_user:[email protected]:31399/db_mongo'
options:
# The default consistency is :eventual, which reads from
# secondaries when possible.
# Strong forces reads to primary.
# We recommend using strong consistency.
consistency: :strong
# max_retries specifies the number of times to attempt an
# operation before giving up. Default 30 seconds
max_retries: 30
# retry_interval specifies the number of seconds to wait before
# retrying a single operation. Default 1 second.
retry_interval: 1
# The default timeout is 5, which is the time in seconds for an
# operation to time out.
# We recommend 15 because it allows for plenty of time in most
# operating environments.
# Mongoid doubles the configured value (known issue) so 15
# results in a timeout of 30s.
# Note that if you have a long-running query (over 30 seconds),
# it will time out.
# See our example for long-running queries in the blog post
# referenced above.
timeout: 15
# Set this to ensure that your writes are a round-trip operation
# and are confirmed by the system. Default (false).
safe: true
# refresh_interval specifies the number of seconds to cache information
# about a node. Default is 300 seconds (5 minutes).
refresh_interval: 10
- References: Digital Ocean - MongoDB
Research & Development (RnD) - ZeroC0D3 Team
- Email: [email protected]
- Repository: https://github.com/zeroc0d3lab
- Install-Packages
- Setup-Server
- Setup-Account
- Configuration-Bash
- Configuration-Zsh
- Install-Bash-Theme
- Install-Zsh-Theme
- Install-Docker
- Install-Memcached
- Install-MongoDB
- Install-MySQL
- Install-NodeJS
- Install-PostgreSQL
- Install-Redis
- Install-Ruby
- Install-SQLite3
- Configuration-App
- Configuration-GCM
- Configuration-Hosts
- Configuration-Memcached
- Configuration-MongoDB
- Configuration-PostgreSQL
- Configuration-Puma
- Configuration-Swap
- Configuration-Unicorn
- Nginx-Puma
- Nginx-Unicorn
- Logrotate
- Deployment-Dashboard
- Deployment-Configuration
- Deployment-Process
- Deployment-Folder-Structure
- Deploy-Preinstall