Get the App
SLTechnology News&Howtos  ›  Database  › 

MongoDB installation, master-slave configuration, and monitorin

Shulou Source: shulou.com Published: 2022-06-01 14:30:43 10月03日 Update

1. Installation

# add installation source

[mongodb] name=MongoDB Repositorybaseurl= http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/gpgcheck=0enabled=1#yum installation

Yum install-y mongo-10gen mongo-10gen-server

# add to Boot Auto start

Chkconfig mongod on

2. Start, stop, restart command

Service mongod startservice mongod stopservice mongod restart

3. Testing

Use mongoperf to view disk IO performance

# mongoperf-h

Usage: mongoperf

< myjsonconfigfile{ nThreads:, // number of threads (default 1) fileSizeMB:, // test file size (default 1MB) sleepMicros:, // pause for sleepMicros/nThreads between each operation (default 0) mmf:, // if true do i/o's via memory mapped files (default false) r:, // do reads (default false) w:, // do writes (default false) recSizeKB:, // size of each write (default 4KB) syncDelay: // secs between fsyncs, like --syncdelay in mongod. (default 0/never)} 进行测试: [root@php1 ~]# cat 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) Xuse local > db.slaves.find () / * 0 * / {"_ id": ObjectId ("526b44843f12574552e6ce48"), "config": {"host": "172.17.16.21 526b44843f12574552e6ce48", "upgradeNeeded": true}, "ns": "local.oplog.$main", "syncedTo": Timestamp (1382870579, 1)}

5. Monitoring and management

# 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 connection Management client robomongo

Download address: www.robomongo.org

# MMS Management

Management address: https://mms.mongodb.com

Need to install pymongo and install mms agent

1. Install Python 2.6 +

2. Install PyMongo

3. Download: mms-monitoring-agent

Wget https://mms.mongodb.com/settings/mmsAgent/15f01bbee11f24c1c5b2b31fab30c406/mms-monitoring-agent- (MMS-Group-Name). Tar.gz

4. Decompress and run

$nohup python agent.py > > / YOUR_LOG_DIRECTORY/agent.log 2 > & 1 &

5. Add a Mongo Node

You can log in to the MMS management address to view the MongoDB node monitoring information chart.

Tags: Management configuration address server service master-slave monitoring command test run two information chart client client tool performance disk node reference Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info macOS NVidia Microsoft Apple