MongoDB installation and deployment (1)

Source: Internet
Author: User

Brief description: MongoDB is a distributed file storage-based database. Written in C ++. It is designed to provide scalable, high-performance data storage solutions for Web applications.

Environment: centos 5.5x64

Installation:

CD/root/tools
Wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.0.tgz
Tar zxvf mongodb-linux-x86_64-2.0.0.tgz
MV mongodb-linux-x86_64-2.0.0/elain/apps/mongodb-linux-x86_64-2.0.0
Ln-S/elain/apps/mongodb-linux-x86_64-2.0.0/elain/apps/MongoDB
Ln-S/elain/apps/MongoDB/bin/*/bin/

# Add a user group

/Usr/sbin/groupadd-G 690 MongoDB
/Usr/sbin/useradd-G MongoDB-u 690-S/sbin/nologin

# Creating a storage directory

Mkdir-P/elain/data/MongoDB/DB/
Chown-r MongoDB. MongoDB/elain/data/MongoDB/DB/

# Start running

Nohup mongod -- dbpath/elain/data/MongoDB/DB &

# Auto start

Echo "mongod -- dbpath/elain/data/DB">/etc/rc. Local

# Start MongoDB as a service and require verification

/Elain/apps/MongoDB/bin/mongod -- fork -- Port 27001 -- auth -- dbpath/elain/data/MongoDB/DB/-- logpath/elain/logs/MongoDB. Log

# Note: the directories used in the parameters must be created.

# Stop

Kill-2 'ps-Ef | grep mongod | grep-V grep | awk' {print $2 }'''

# Verify startup

[Root @ md01 ~] # Netstat
-Ln

Active Internet connections (only servers)

PROTO Recv-Q send-Q local address foreign address State

TCP 0 0 0.0.0.0: 28001
0.0.0.0: * listen

TCP 0 0 0.0.0.0: 27001
0.0.0.0: * listen

You can also access: http: // ip: 28001/browse

# Logon:

Mongo -- host server IP: 27001 [root @ md01 ~] # Mongo
-- Host localhost: 27001

MongoDB shell version: 2.0.0

Connecting to: localhost: 27001/test
>

# Test

[Root @ md02 MongoDB] #
Mongo

MongoDB shell version: 1.8.3

Connecting to: Test

Thu Sep 8 22:16:13 [initandlisten] connection
Accepted from 127.0.0.1: 43643 #2
> DB. Foo. Save ({A: 1 })
> DB. Foo. Find ()
{"_ Id": objectid ("4e68ce01f4be44b5812e7f9a"), "A": 1}

Appendix 1:
The usage of each tool in MongoDB bin:

Mongod: database server, similar to mysqld. Each instance starts a process and can run fork as daemon.
Mongo: the client command line tool, similar to sqlplus/MySQL, is actually a JS interpreter and supports JS syntax.
Mongodump/mongorestore: imports data into a bson file/restores the bson file to a database, similar to xtracbackup
Export export/Export Import: export the collection to JSON/CSV format data/import the data into the database, similar to mysqldump/mysqlimport
Bsondump: Dump bson files into JSON data
Mongos: shard routing. If sharding is used, the application is connected to mongos instead of mongod.
Program Files: gridfs management tool
Mongostat: Real-time Monitoring Tool

Appendix 2:
The main parameters of mongod include:

Dbpath: data file storage path. Each database creates a sub-directory.
Logpath: Error Log File
Logappend: The append mode is used for error logs (the overwriting mode is used by default)
Bind_ip: the IP address bound to the external service. It is usually set to null and bound to all available IP addresses of the local machine. You can specify the IP address as needed.
Port: External Service port. Web Management port + 1000 based on this port
Fork: run the service in the form of daemon.
Journal: enables the log function to save operation logs to reduce the recovery time of standalone faults. It is officially added after version 1.8 to replace the Dur parameter in version 1.7.5.
Syncdelay: interval at which sync is executed, in seconds.
Directoryperdb: each database is stored in a separate directory. We recommend that you set this parameter.
Maxconns: Maximum number of connections
Repairpath: temporary directory for executing repair. If journal is not enabled and the system restarts after an exception occurs, you must perform the repair operation.

Reproduced from: http://www.elain.org /? P = 602

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.