MongoDB 安装

简单介绍了如何使用RPM包安装MongoDB,并介绍了配置文件中的主要内容,以及演示了MongoDB Shell的一些简单使用

下载

MongoDB Download Center

Version:    3.6.13(previous release)
OS:         REHEL 7.0 Linux 64-bit x64
Package:    shell

mongodb-org-server-3.6.13-1.el7.x86_64.rpm  // 服务端程序
mongodb-org-mongos-3.6.13-1.el7.x86_64.rpm  // 部署集群需要
mongodb-org-tools-3.6.13-1.el7.x86_64.rpm   // 附加工具如数据导入导出
mongodb-org-shell-3.6.13-1.el7.x86_64.rpm   // 命令行连接工具

安装

rpm -ivh mongodb-org-*-3.6.13-1.el7.x86_64.rpm

配置文件

实际部署中需要注意下列配置

  1. 日志位置
  2. 数据位置
  3. pidfile位置
  4. 监听IP和Port
# /etc/mongod.conf
# 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: /var/lib/mongo
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  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: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.


#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:

后台管理Shell

查看shell工具安装位置

# rpm -ql mongodb-org-shell-3.6.13-1.el7.x86_64
/usr/bin/mongo
/usr/share/man/man1/mongo.1

直接运行mongo。由于它是一个JavaScript shell,可以做一些简单的运算。

./mongo
MongoDB shell version v3.6.13

> 1 + 2
3

插入一个简单的数据并检索

> db.runoob.insert({x:10})
WriteResult({ "nInserted" : 1 })
> db.runoob.find()
{ "_id" : ObjectId("5d1dae0369bc72b9a9588c35"), "x" : 10 }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值