zoukankan      html  css  js  c++  java
  • MongoDB释放磁盘空间

    1. 先删除旧的文档db.remove({});

    2. 从副本集中移除待清理的成员:

      (1) 登录副本集中的 Primary 服务器(/opt/mongo1/bin/mongo --port 27017)

      (2) rs.remove("192.168.1.54:27019")

    3. 关闭待清理的 mongodb 服务器

      (1) 登录待清理的 mongodb 服务器(/opt/mongo2/bin/mongo --port 27018)

      (2) user admin; db.shutdownServer();

    4. 修改 mongodb 启动参数,并运行

      bin/mongod --dbpath /home/mongodata2/data --port 27018 --logpath=/home/mongodata2/logs/mongodb2.log --repair --repairpath /opt/data

    5. 确认 mongod 运行结束

      可以用 ps axu | grep mongod 查看进程是否结束。
      也可以看日志文件 /home/mongodata2/logs/mongodb2.log 是否有如下输出:

      2016-05-10T13:14:41.646+0800 [conn5413] dbexit: shutdown called
      2016-05-10T13:14:41.646+0800 [conn5413] shutdown: going to close listening sockets...
      2016-05-10T13:14:41.646+0800 [conn5413] closing listening socket: 8
      2016-05-10T13:14:41.646+0800 [conn5413] closing listening socket: 10
      2016-05-10T13:14:41.646+0800 [conn5413] removing socket file: /tmp/mongodb-27018.sock
      2016-05-10T13:14:41.646+0800 [conn5413] shutdown: going to flush diaglog...
      2016-05-10T13:14:41.646+0800 [conn5413] shutdown: going to close sockets...
      2016-05-10T13:14:41.646+0800 [conn5413] shutdown: waiting for fs preallocator...
      2016-05-10T13:14:41.646+0800 [conn5413] shutdown: lock for final commit...
      2016-05-10T13:14:41.646+0800 [conn5413] shutdown: final commit...
      2016-05-10T13:14:41.647+0800 [conn5413] shutdown: closing all files...
      2016-05-10T13:14:41.832+0800 [conn5413] closeAllFiles() finished
      2016-05-10T13:14:41.832+0800 [conn5413] journalCleanup...
      2016-05-10T13:14:41.832+0800 [conn5413] removeJournalFiles
      2016-05-10T13:14:41.889+0800 [conn5413] shutdown: removing fs lock...
      2016-05-10T13:14:41.889+0800 [conn5413] dbexit: really exiting now

    6. 最后以正常方式启动 mongod,并将成员加入到副本集中

      登录副本集中的 Primary 服务器

      rs.add("IPADDR:27018")

      查看副本集的运行结果:  rs.printSlaveReplicationInfo()

  • 相关阅读:
    libevent源码分析--(转)
    libevent源码分析(转)
    服务器模型---总结
    暴力英语学习法 + 严格的目标管理 = 成功快速靠谱的学好英语(转)
    log4net写入mysql完整例子
    form操作
    ASP.NET Razor
    java爬虫:在请求body中增加json数据采集
    asp.net mvc3登录验证
    远程复制无法读取源文件或磁盘
  • 原文地址:https://www.cnblogs.com/taoge007/p/6063710.html
Copyright © 2011-2022 走看看