Install, deploy, and start MongoDB in CentOS. 1. Download the installation package 32-bit wgetfastdl. mongodb. orglinuxmongodb-linux-i686-2.2.3.
Install, deploy, and start MongoDB in CentOS. 1. Download the installation package 32-bit wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.2.3.
Install, deploy, and start MongoDB in CentOS.
1. Download the installation package
32-bit
Wget
64-bit
Wget
Decompress the package after the download is complete.
Tar zxf mongodb-linux-i686-2.2.3.tgz
2. Installation preparation
Move mongodb to the/usr/local/server/mongdb folder
Music mongodb-linux-i686-2.2.3/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/mongodb/bin/mongod -- dbpath =/usr/local/mongodb/data-logpath =/usr/local/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/mongodb/bin/mongod -- dbpath =/usr/local/mongodb/data -- logpath =/usr/local/mongodb/logs -- logappend -- auth -- port = 27017 -- fork
// No password is required.
/Usr/local/server/bin/mongod -- dbpath =/usr/local/mongodb/data -- logpath =/usr/local/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 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