wget https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.4/x86_64/RPMS/mongodb-org-server-4.4.2-1.el7.x86_64.rpm
rpm -i mongodb-org-server
#此时已自动创建mongod用户, 创建默认 /etc/mongod.confwget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.2.tgz
#解压这个压缩包之后包含, mongod(服务程序,上面已经安装), mongos(路由节点), mongo(客户端,用于连接mongod服务进程)# mongod.conf# for documentation of all options, see:# http://docs.mongodb.org/manual/reference/configuration-options/# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /mongodb/data
journal:
enabled: true# engine:# wiredTiger:# how the process runs
processManagement:
fork: true# fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.#security:#operationProfiling:#replication:#sharding:## Enterprise-Only Options#auditLog:#snmp:
# mongod.conf# for documentation of all options, see:# http://docs.mongodb.org/manual/reference/configuration-options/# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /mongodb/data
journal:
enabled: true# engine:# wiredTiger:# how the process runs
processManagement:
fork: true# fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.#security:#operationProfiling:
replication:
replSetName: MyMongo
#sharding:## Enterprise-Only Options#auditLog:#snmp:
# config server 存储索引的节点# mongod.conf# for documentation of all options, see:# http://docs.mongodb.org/manual/reference/configuration-options/# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /mongodb/data
journal:
enabled: true# engine:# wiredTiger:# how the process runs
processManagement:
fork: true# fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
#port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.#security:#operationProfiling:
replication:
replSetName: ForConfig
sharding:
clusterRole: configsvr
## Enterprise-Only Options#auditLog:#snmp:#最后正常启动 mongod -f /etc/mongod.conf 默认监听在27019端口
#shard 节点# mongod.conf# for documentation of all options, see:# http://docs.mongodb.org/manual/reference/configuration-options/# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /mongodb/data
journal:
enabled: true# engine:# wiredTiger:# how the process runs
processManagement:
fork: true# fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
#port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.#security:#operationProfiling:
replication:
replSetName: MyMongo
sharding:
clusterRole: shardsvr
## Enterprise-Only Options#auditLog:#snmp:#最后正常启动 mongod -f /etc/mongod.conf 默认监听在27019端口
权限
use admin;//创建超级管理员
db.createUser({user:"myroot", pwd:"xxxxx", roles:[{"role":"root","db":"admin"}]});//添加一个管理其他账户的账户
db.createUser({user:"myadmin", pwd:"xxxxx", roles:[{role:"userAdminAnyDatabase", db:"admin"}]});//登陆
use admin;
db.auth("myroot","xxxxx");//在两个个数据库上创建读写权限用户
db.createUser({user:"your_world_2",pwd:"xxxxx", roles:[{role:"readWrite", db:"school"},{role:"readWrite", db:"school_2"}]});
#每个replication节点, shard节点, configsvr节点都必须在配置文件中指明keyFile# mongod.conf# for documentation of all options, see:# http://docs.mongodb.org/manual/reference/configuration-options/# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /mongodb/data
journal:
enabled: true# engine:# wiredTiger:# how the process runs
processManagement:
fork: true# fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
security:
keyFile: /mongodb/data/mongo.keyfile
authorization: enabled
#operationProfiling:
replication:
replSetName: MyMongo
sharding:
clusterRole: shardsvr
## Enterprise-Only Options#auditLog:#snmp: