数据库的终端命令操作

设置数据库的存储位置
  mongod --dbpath 目录
  e.g. mongod --dbpath dbs

设置数据库端口
  mongod --port 8080
  * 默认监听端口27017

数据库的备份和恢复

  备份 mongodump -h 127.0.0.1 -d 库名 -o 备份名
    e.g. 将本机stu数据库备份到bak目录下
    mongodump -h 127.0.0.1 -d stu -o bak
  恢复 mongorestore -h dbhost:port -d dbname path
    e.g. 将stu数据库恢复到本机的res数据库中(res不存在就会自动创建)
    mongorestore -h 127.0.0.1:27017 -d res bak/stu

数据库的监测

   在终端输入 mongostat
    insert query update delete : 每秒增删改查的次数
    command 每秒运行命令的次数
    flushes 每秒和磁盘交互次数
    vsize 使用虚拟内存大小
    time 时间
    res 物理内存

  监测每个数据读写的时长: mongotop
    ns 数据表
    total 总时间
    read 读时间
    write 写时间

posted on 2018-09-19 18:52  zengsf  阅读(573)  评论(0编辑  收藏  举报

导航