• 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()

  • 相关阅读:
    org.hibernate.QueryException: could not resolve property
    tomcat启动异常(严重: Dispatcher initialization failed Unable to load configuration.
    MySQL开发规范
    JAVA字符串格式化-String.format()的使用
    使用 Ant 自动生成项目构建版本
    MySQL随机获取数据的方法,支持大数据量
    System.nanoTime与System.currentTimeMillis的区别
    [MySQL FAQ]系列 — 为什么InnoDB表要建议用自增列做主键
    inet_ntoa、 inet_aton、inet_addr
    MySQL关键字(保留字)列表
  • 原文地址:https://www.cnblogs.com/taoge007/p/6063710.html
Copyright © 2020-2023  润新知