MongoDB 安装、主从配置、以及监控
2013-11-03 15:35
495 查看
1、安装
#添加安装源
使用mongoperf 查看磁盘IO性能#mongoperf -h
[root@php1 ~]# cat <jsonfile
https://blog.serverdensity.com/real-world-mongodb-benchmarks-with-benchrun/
运行mongo
#mongo
#两个服务器修改hosts:
#vim /etc/mongod.conf
#主服务器上
#mongo
#mongostat
The mongostat utility provides a quick overview of the status of a currently running mongod or mongos instance. mongostat is functionally similar to the UNIX/Linux file system utility vmstat, but provides data regarding mongod and mongos instances.
#mongotop
mongotop provides a method to track the amount of time a MongoDB instance spends reading and writing data. mongotop provides statistics on a per-collection level. By default, mongotop returns values every second.
#mongodb连接管理客户端robomongo
下载地址:www.robomongo.org
#MMS管理
管理地址:https://mms.mongodb.com
需要安装pymongo并安装mms agent
1、安装Python 2.6+
2、安装PyMongo
3、下载:mms-monitoring-agent
#添加安装源
[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 on2、启动,停止,重启命令
service mongod start service mongod stop service mongod restart3、测试
使用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.44、主从配置
主 | php1 | 172.17.16.7 |
从 | mysql1 | 172.17.16.21 |
172.17.16.7 php1.domain.com#主上添加配置:vim /etc/mongod.conf
master = true source = php1.dapingmu.conf#从上添加配置:
#vim /etc/mongod.conf
slave = true source = php1.dapingmu.com#查看主从,使用robomongo或直接在服务器上使用命令行工具
#主服务器上
#mongo
>use local >db.slaves.find() /* 0 */ { "_id" : ObjectId("526b44843f12574552e6ce48"), "config" : { "host" : "172.17.16.21:29025", "upgradeNeeded" : true }, "ns" : "local.oplog.$main", "syncedTo" : Timestamp(1382870579, 1) }5、监控管理
#mongostat
The mongostat utility provides a quick overview of the status of a currently running mongod or mongos instance. mongostat is functionally similar to the UNIX/Linux file system utility vmstat, but provides data regarding mongod and mongos instances.
#mongotop
mongotop provides a method to track the amount of time a MongoDB instance spends reading and writing data. mongotop provides statistics on a per-collection level. By default, mongotop returns values every second.
#mongodb连接管理客户端robomongo
下载地址:www.robomongo.org
#MMS管理
管理地址:https://mms.mongodb.com
需要安装pymongo并安装mms agent
1、安装Python 2.6+
2、安装PyMongo
3、下载:mms-monitoring-agent
wget https://mms.mongodb.com/settings/mmsAgent/15f01bbee11f24c1c5b2b31fab30c406/mms-monitoring-agent-(MMS-Group-Name).tar.gz[/code]4、解压并运行$ nohup python agent.py >> /YOUR_LOG_DIRECTORY/agent.log 2>&1 &5、添加一个Mongo Node
即可登录MMS管理地址查看MongoDB 节点监控信息图表
本文出自 “张跃的部落格” 博客,请务必保留此出处http://mrcto.blog.51cto.com/1923168/1319612
相关文章推荐
- MongoDB Connector for Hadoop
- MongoDB学习心得(整理中)
- MongoDB基本使用
- 配置MongoDB集群分片
- 深入剖析MongoDB架构
- Solr与MongoDB集成,实时增量索引
- MongoDB install and use
- 如何将 MongoDB MapReduce 速度提升 20 倍
- [Solr] (源) Solr与MongoDB集成,实时增量索引
- 快速搭建MongoDB分片集群
- MongoDB MapReduce速度提升20倍的优化宝典
- Mongodb写入安全机制--GetLastError
- WinXP编译mongodb c++ driver
- 论mongodb
- MongoDB学习之四----文本索引的简单使用
- mongoDB分页的两种方法(图例)
- mongodb命令介绍
- 时间序列数据处理的角逐:MongoDB vs. Cassandra
- python操作MongoDB基础知识
- python操作MongoDB