Install MongoDB under Linux

1. Upload the mongodb installation package to the server and unzip it

  cd /usr/local

  rz...

  tar xvf mongodb-linux-i686-2.6.11.tar #decompress

2. Rename the decompressed file to mongodb, and create the data folder and logs log file below

  mv mongodb-linux-i686-2.6.11 mongodb #rename

  cd mongodb/ #cd to mongodb file

  mkdir data #folder    

  touch logs #log file

  

 

3. Start MongoDB

  cd /usr/local/mongodb/bin

  #Connection method without password:

  /usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/logs --logappend  --port=27017 --fork --journal   #32位的加--journal

  #Connection method that requires a password:

/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/logs --logappend --auth --port=27017 --fork

  

  #Parameter explanation

1   -- logpath log file path
 2   -- master designated as the master machine
 3   -- slave designated as the slave machine
 4   -- source designated the IP address of the master machine
 5   --pologSize designated log file size does not exceed 64M. Because resync is very operational Large and time-consuming, it is best to avoid resync by setting a large enough oplogSize (the default oplog size is 5% of the free disk size ).
6   -- logappend add 7 at the end of the log file
   -- port enables the port number
 8   -- fork runs in the background
 9   -- only specifies which database to copy only
 10   -- slavedelay refers to the time interval for slave replication detection
 11   --auth whether authentication is required Permission login (username and password)


4. Check whether it is started:
  netstat -nutlp

   

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324988981&siteId=291194637