<strong>1、mongod 启动项注释(默认不能生成路径,需手动建立)</strong><br />
<span style="white-space:pre"></span>dbpath 数据库实例的路径<br />
<span style="white-space:pre"></span>logpath 日志记录路径<br />
<span style="white-space:pre"></span>logappend 日志采用追加形式,默认为覆盖<br />
<span style="white-space:pre"></span>bind_ip 实例绑定IP地址<br />
<span style="white-space:pre"></span>port 实例指定端口,web管理接口在此接口上加1000<br />
<span style="white-space:pre"></span>fork 以后台实行进行运行,<br />
<span style="white-space:pre"></span>journal 开启操作日志功能<br />
<span style="white-space:pre"></span>syncdelay 同步刷新磁盘时间,单位为秒,默认60秒<br />
<span style="white-space:pre"></span>directoryperdb db单独存放目录,类似MySQL独立表空间<br />
<span style="white-space:pre"></span>maxConns 最大链接数<br />
<span style="white-space:pre"></span>repairpath 执行repair的临时目录,如果没有开启journal,异常死机,需要执行repair操作<br />

<p>
    <span style="white-space:pre"></span>auth 需要账户验证登录
</p>
<p>
    <br />
    
</p>
<p>
    <strong>2、停止服务 &nbsp;shutdownServer() &nbsp;db.shutdownServer()</strong>
</p>
<p>
    <strong><br />
    </strong>
</p>
<p>
    <strong>3、查看当前进程 db.currentOp()<span style="white-space:pre"> </span></strong>
</p>
<p>
    <br />
    
</p>
<p>
    <strong>4、结束某个进程 db.killOp(进程号)</strong>
</p>
<p>
    <strong><br />
    </strong>
</p>
<strong>5、当前实例每秒运行状态 &nbsp;使用mongostat 进入某个库实例</strong><br />
<span style="white-space:pre"></span>insert 每秒插入<br />
<span style="white-space:pre"></span>query 每秒查询<br />
<span style="white-space:pre"></span>update 每秒更新<br />
<span style="white-space:pre"></span>delete 每秒删除<br />
<span style="white-space:pre"></span>locked 锁定量<br />
<span style="white-space:pre"></span>qr|qw 客户端排队长度 &nbsp;读、写<br />
<span style="white-space:pre"></span>ar|aw 活跃的客户端数量 读、写<br />

<p>
    <span style="white-space:pre"></span>conn 链接数
</p>
<p>
    <br />
    
</p>
<strong>6、导出数据 mongoexport&nbsp;</strong><br />

<p>
    <span style="white-space:pre"></span>mongoexport -d 数据库名称 -c 表名称 -o 要导出的文件的路径
</p>
<p>
    <br />
    
</p>
<strong>7、数据库备份 mongodump ,只选择数据库,则代表全库备份</strong><br />

<p>
    <span style="white-space:pre"></span>mongodump -d 数据库名 -c 备份表名 -o 备份路径
</p>
<p>
    <br />
    
</p>
<strong>8、数据库还原 mongorestore &nbsp;,drop为先删除再插入数据</strong><br />
<span style="white-space:pre"></span>mongorestore -d 数据库名 备份的路径 --drop<br />

<p>
    <span style="white-space:pre"></span>mongorestore -d drumdb d:\MDRUM\drumdb
</p>
<p>
    <br />
    
</p>
<strong>9、修复数据库,会将无效和有损坏的数据给清理掉</strong><br />

<p>
    <span style="white-space:pre"></span>db.repairDatabase()
</p>
<p>
    <br />
    
</p>
<strong>10、fsync 对数据库增加写入锁,需要在admin库执行语句,执行之后则将缓冲区的数据写入磁盘,阻塞其他写操作,<br />
<span style="white-space:pre"></span>然后可以进行备份,备份结束之后,对写入锁进行还原 db.$cmd.sys.unlock.findOne(); &nbsp;<br />
<span style="white-space:pre"></span>解锁之后可以使用db.currentOp()<span style="white-space:pre"></span>查看进程</strong><br />
<span style="white-space:pre"></span>加锁 db.runCommand({&quot;fsync&quot; : 1, &quot;lock&quot; : 1});<br />
<span style="white-space:pre"></span>解锁 db.$cmd.sys.unlock.findOne(); &nbsp;

 posted on 2017-06-22 11:34  TooYoung222  阅读(151)  评论(0编辑  收藏  举报