1. Download the installation package
Wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.8.2.tgz
Decompress the package after the download is complete.
Tar zxf mongodb-linux-i686-1.8.2.tgz
2. Installation preparation
Move MongoDB to the/usr/local/Server/mongdb folder
Music mongodb-linux-i686-1.8.2/usr/local/MongoDB
Create Database folders and log files
Mkdir/usr/local/MongoDB/Data
Touch/usr/local/MongoDB/logs
3. Set auto-start upon startup
Add the MongoDB startup project to RC. Local to ensure that MongoDB is started when the server is started.
Echo "/usr/local/Server/MongoDB/bin/mongod -- dbpath =/usr/local/Server/MongoDB/data-logpath =/usr/local/Server/MongoDB/logs -logappend -- auth-Port = 27017 ">/etc/rc. local
4. Start MongoDB
CD to the bin folder in the MongoDB directory to start MongoDB
// The following is the logon method that requires permissions. the user name and password are required for user connection.
/Usr/local/Server/MongoDB/bin/mongod -- dbpath =/usr/local/Server/MongoDB/data -- logpath =/usr/local/Server/MongoDB/logs -- logappend -- auth -- Port = 27017 -- fork
// No password is required.
/Usr/local/Server/MongoDB/bin/mongod -- dbpath =/usr/local/Server/MongoDB/data -- logpath =/usr/local/Server/MongoDB/logs -- logappend -- Port = 27017 -- fork
5. Parameter explanation: -- dbpath database path (data file)
-- Logpath: Log File Path
-- Master is specified as the master machine.
-- Slave is specified as the slave machine
-- Source: Specifies the IP address of the host.
-- Pologsize: the size of the specified log file cannot exceed 64 MB. because Resync is very large and time-consuming, it is best to set a large enough oplogsize to avoid Resync (the default oplog size is 5% of the idle disk size ).
-- Add at the end of the logappend Log File
-- Port enables the port number
-- Fork runs in the background
-- Only specifies which database to copy
-- Slavedelay indicates the interval between slave replication detection.
-- Does auth need to verify the permission to log on (user name and password)
-H [-- help] Show this usage information
-- Version show version information
-F [-- config] Arg configuration file specifying additional options
-- Port Arg specify port number
-- Bind_ip Arg local IP address to bind listener-all local IPS
Bound by default
-V [-- verbose] Be more verbose (include multiple times for more
Verbosity e.g.-vvvvv)
-- Dbpath Arg (=/data/DB/) directory for datafiles specifies the data storage directory
-- Quiet quieter output silent mode
-- Logpath Arg file to send all output to instead of stdout specifies the log storage directory
-- Logappend appnd to logpath instead of over-writing specifies whether to append or overwrite a log file.
-- Fork server process is run by creating a sub-process
-- CPU periodically show CPU and iowait utilization periodically displays CPU and IO usage
-- Noauth run without security run in No Authentication Mode
-- Auth run with Security Authentication Mode
-- Objcheck inspect client data for validity on receipt check the validity of client input data
-- Quota enable dB Quota Management
-- Quotafiles Arg number of files allower per dB, requires -- quota specifies the number of files allowed by each database
-- Initialize rvpath Arg root directory for the babble app Server
-- Nocursors diagnostic/debugging option debug diagnostic options
-- Nohints ignore query hints ignore query hit rate
-- Nohttpinterface disable HTTP interface: Disable the HTTP interface. The default value is 28017.
-- Noscripting disable scripting engine shut down the Script Engine
-- Noprealloc disable data file preallocation disable database file size pre-allocation
-- Smallfiles use a smaller default file size
-- Nssize Arg (= 16). Ns file size (in MB) for new databases default size of the NS file in the new database
-- Diaglog Arg 0 = off 1 = W 2 = R 3 = both 7 = W + some reads: Read-only, write-only, or read/write, or the primary write + part Read mode
-- Sysinfo print some diagnostic system information print system diagnostic information
-- Upgrade DB if needed update the database if necessary
-- Repair run repair on all DBS fix all databases
-- Notablescan do not allow table scans does not run table Scan
-- Syncdelay Arg (= 60) seconds between disk syncs (0 for never) the time when the system refreshes the disk synchronously. The default value is 60 s.
Replication options:
-- Master mode master replication Mode
-- Slave mode slave replication Mode
-- Source Arg when slave: Specify master as <server: Port> when it is a slave, specify the Master Address and Port
-- Only Arg when slave: specify a single database to replicate when it is set to slave, specify a single database to be copied from the master
-- Pairwith Arg address of server to pair
-- Arbiter Arg address of arbiter server arbitration server, used in master and pair
-- Autoresync automatically Resync if Slave Data is stale automatically synchronize Slave Data
-- Oplogsize Arg size limit (in MB) for OP log specifies the size of the operation log
-- Opidmem Arg size limit (in bytes) for in memory storage of OP IDs specifies the memory size for storing operation logs.
Sharding options:
-- Configsvr declare this is a Config dB of a cluster specifies the configuration server in the shard.
-- Shardsvr declare this is a shard dB of a cluster specified shard Server
6. Go to the CLI management interface of the database.
CD to the bin folder in the MongoDB directory and execute the command./Mongo
Run the following command:
[Root @ namenode MongoDB] #./bin/Mongo
MongoDB shell version: 1.8.2
Connecting to: Test
> Use test;
Switched to DB Test
If the database cannot be connected, it is a problem with the mongod. Lock file under the Data Directory. You can use the following repair command,
Mongod -- repair