MongoDB installation and, set up accounts, master and slave

Source: Internet
Author: User
Tags install mongodb mongodb version

I used to use MongoDB, in the evening check the need for the command, about how MongoDB how to use, I do not know

Official website: http://www.mongodb.org/
MongoDB installation, master-slave configuration
One MongoDB installation

Click ( here) to collapse or open

  1. [[email protected]_server Src]# wget http://fastdl.mongodb. Org/linux/mongodb-linux -x86_64-2.0.0.tgz
  2. [email protected]_server src]# tar xzvf mongodb-linux-x86_64-2. 0. 0. tgz
  3. [email protected]_server src]# mv MongoDB-linux-x86_64-2. 0. 0/usr/Local /mongodb
  4. [email protected]_server src]# mkdir/usr/local/mongodb/data
  5. [email protected]_server src]# touch/usr/local/mongodb/logs
  6. [[Email Protected]_server bin]#/usr/local/mongodb/bin/mongod --dbpath =/usr/local/mongodb/data --logpath =/usr/local/mongodb/logs --logappend --port=27017 --fork
  7. [Email Protected]_server bin]# . /mongo
  8. MongoDB Shell version: 2. 0. 0
  9. Connecting to: test
  10. > Use test;
  11. Switched to DB test
  12. > Exit
  13. Bye
  14. [Email Protected]_server bin]# netstat -anlpt | grep mongo
  15. TCP 0 0 0. 0. 0. 0: 27017 0. 0. 0. 0:* LISTEN 11504/mongod
  16. TCP 0 0 0. 0. 0. 0: 28017 0. 0. 0. 0:* LISTEN 11504/mongod

Note: If an error -bash:/usr/local/mongodb/bin/mongod:cannot Execute binary file description of your server and MongoDB version does not correspond, if the server is 64-bit, download x86_64 MongoDB, if the server is 32-bit, download i686 mongodb/

The installation method references the http://blog.chinaunix.net/uid-24250828-id-3770298.html

Set up your account,

It's best to set it up without--auth.

Use admin

Db.adduser ("name", "passwd")

Db.auth ("name", "passwd") if Output 1 is correct

In the service, then you have to add an account to each library,

Use logs

Db.adduser ("name", "passwd").

And then it's the master and slave.

If you install MongoDB by the method above. Then just need to put the entire MongoDB file, rsync to another server,

And then when you start adding configuration options, that's easy to say.

Due to the addition of accounts, authentication is required to use the--keyfile option for master-slave copy.

Master and slave Two inside of the file to the same, specific crossing Internet cafes http://docs.mongodb.org/manual/core/master-slave/# Configuration-options-for-master-slave-deployments

Note chmod keyfile will not error child process failed, exited with error number 1

And then it's time to start, just fill in the options.

Main/usr/local/mongodb/bin/mongod--auth--master--dbpath=/usr/local/mongodb/data--logpath=/usr/local/mongodb/logs/ Mongodb.log--logappend--port=27017--fork

From--keyfile=/usr/local/mongodb/bin/mongod--auth--slave--source 192.168.10.36:27017--dbpath=/usr/local/mongodb/ Data--logpath=/usr/local/mongodb/logs/mongodb.log--logappend--port=27017--fork--keyfile=/usr/local/mongodb/ Keyfile/usr/local/mongodb/keyfile

192.168.10.37-based IP address

And then it's ready. You can add a data to the Lord and look it up from the top.

There are errors, look at the log

Stop MongoDB is the boot configuration option, fill in the previous--shutdown

MongoDB installation and, set up accounts, master and slave

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.