手机版
你好,游客 登录 注册
背景:
阅读新闻

MongoDB 安装、主从配置、以及监控

[日期:2013-11-03] 来源:Linux社区  作者:mrcto [字体:大 中 小]

1、安装

--------------------------------------------------------------------------------
#添加安装源

[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/RedHat/os/x86_64/
gpgcheck=0
enabled=1

#yum 安装
yum install -y mongo-10gen mongo-10gen-server


#添加到开机自动启动
chkconfig mongod on

 

2、启动,停止,重启命令

--------------------------------------------------------------------------------
service mongod start

service mongod stop
service mongod restart


3、测试

--------------------------------------------------------------------------------
使用mongoperf 查看磁盘IO性能#mongoperf -h
usage:
mongoperf < myjsonconfigfile

{

nThreads:<n>, // number of threads (default 1)
fileSizeMB:<n>, // test file size (default 1MB)
sleepMicros:<n>, // pause for sleepMicros/nThreads between each operation (default 0)
mmf:<bool>, // if true do i/o's via memory mapped files (default false)
r:<bool>, // do reads (default false)
w:<bool>, // do writes (default false)
recSizeKB:<n>, // size of each write (default 4KB)
syncDelay:<n> // secs between fsyncs, like --syncdelay in mongod. (default 0/never)
}
进行测试:
[root@php1 ~]# cat <jsonfile
{
nThreads:1,
fileSizeMB:1,
sleepMicros:0,
mmf:'true',
r:'true',
w:'true',
recSizeKB:4,
syncDelay:0
}


#参考Real world MongoDB benchmarks with benchRun
https://blog.serverdensity.com/real-world-mongodb-benchmarks-with-benchrun/

运行mongo
#mongo
>db.foo.insert( { _id : 1 } )
>ops = [{ op :"findOne", ns :"test.foo", query : { _id : 1 } }, { op :"update", ns :"test.foo", query : { _id : 1 } , update : { $inc : { x : 1 } } } ]
[
{
"op":"findOne",
"ns":"test.foo",
"query": {
"_id": 1
}
},
{
"op":"update",
"ns":"test.foo",
"query": {
"_id": 1
},
"update": {
"$inc": {
"x": 1
}
}
}
]
>for( x = 1; x<=128; x*=2){
... res = benchRun( { parallel : x ,
... seconds : 5 ,
... ops : ops
... } )
... print("threads: "+ x +"\t queries/sec: "+ res.query )
... }

threads: 1 queries/sec: 7886.8
threads: 2 queries/sec: 12786.2
threads: 4 queries/sec: 14891.2
threads: 8 queries/sec: 16361.2
threads: 16 queries/sec: 19811.6
threads: 32 queries/sec: 18343.8
threads: 64 queries/sec: 26470.4
threads: 128 queries/sec: 36110.4

更多详情见请继续阅读下一页的精彩内容: http://www.linuxidc.com/Linux/2013-11/92286p2.htm

MongoDB 的详细介绍:请点这里
MongoDB 的下载地址:请点这里

推荐阅读:

Java实现MongoDB中自增长字段 http://www.linuxidc.com/Linux/2012-05/61552.htm

CentOS编译安装MongoDB http://www.linuxidc.com/Linux/2012-02/53834.htm

CentOS 编译安装 MongoDB与mongoDB的php扩展 http://www.linuxidc.com/Linux/2012-02/53833.htm

CentOS 6 使用 yum 安装MongoDB及服务器端配置 http://www.linuxidc.com/Linux/2012-08/68196.htm

Ubuntu 13.04下安装MongoDB2.4.3 http://www.linuxidc.com/Linux/2013-05/84227.htm

如何在MongoDB中建立新数据库和集合 http://www.linuxidc.com/Linux/2013-06/85749.htm

MongoDB入门必读(概念与实战并重) http://www.linuxidc.com/Linux/2013-07/87105.htm

《MongoDB 权威指南》(MongoDB: The Definitive Guide)英文文字版[PDF] http://www.linuxidc.com/Linux/2012-07/66735.htm

linux
相关资讯       MongoDB安装 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款