Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Install mongodb under linux

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Download the installation package

Wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-3.0.6.tgz

Extract the compressed package after the download is completed

Tar zxf mongodb-linux-i686-3.0.6.tgz

Installation preparation

Move mongodb to the / usr/local/mongodb folder

Mv mongodb-linux-i686-3.0.6 / usr/local/mongodb

Create database folders and log files

Mkdir / usr/local/mongodb/data

Touch / usr/local/mongodb/logs

Set Boot self-boot

Add the mongodb startup project to rc.local to ensure that mongodb starts when the server is powered on

Echo "/ usr/local/mongodb/bin/mongod-- dbpath=/usr/local/mongodb/data-logpath=/usr/local/mongodb/logs-logappend-- auth-port=27017" > / etc/rc.local

Start mongodb

Cd to the bin folder in the mongodb directory to start mongodb

/ / the following is the login method that requires permission, and the user needs a user name and password to connect.

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

/ / this does not require a password

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

Start from a configuration file

Launch command: / usr/local/mongodb/bin/mongod-f mongodb.conf

[represents port number, defaults to 27017 if not specified]

Parameter interpretation:-- dbpath database path (data file)

-- logpath log file path

-- master designated as the master machine

-- slave specified as slave machine

-- source specifies the IP address of the host machine

-- pologSize specifies that the log file size does not exceed 64m. Because resync is very heavy 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).

-- add at the end of the logappend log file

-- port enable port number

-- fork runs in the background

-- only specifies which database to replicate

-- slavedelay refers to the time interval detected from replication

-- whether auth needs to verify permission login (username 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 the log is written to the log file as an append or overwrite

-- fork fork server process runs as a child process

Cpu periodically show cpu and iowait utilization periodically displays the use of cpu and io

-- noauth run without security runs in authentication-free mode

-- auth run with security authentication mode operation

-- objcheck inspect client data for validity on receipt checks the validity of client input data

-- quota enable db quota management starts database quota management

-- quotaFiles arg number of files allower per db, requires-- quota specifies the number of files allowed per database

-- appsrvpath arg root directory for the babble app server

-- nocursors diagnostic/debugging option debug diagnostic option

-- nohints ignore query hints ignores query hit rate

-- nohttpinterface disable httpinterface shuts down the http interface. Default is 28017.

-- noscripting disable scripting engine shuts down the script engine

-- noprealloc disable data file preallocation turns off database file size pre-allocation

-smallfiles use a smaller default file size uses a smaller default file size

-- nssize arg (= 16) .ns file size (in MB) for new databases default size of the new database ns file

-- the mode provided by diaglog arg 0=off 1-write-2-R 3=both 7=W+some reads is read-only, write-only, or read-write, or mainly write + partial read mode.

-- sysinfo print some diagnostic system information print system diagnostic information

-- upgrade upgrade db if needed updates the database if necessary

-- repair run repair on all dbs repairs 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 for the system to synchronously refresh the disk. Default is 60s.

Replication options:

-- master master mode master replication mode

-- slave slave mode from replication mode

-- source arg when slave: specify master as specifies the address and port of the master when it is a slave

-- only arg when slave: when specify a single database to replicate is a slave, specify a single library to be copied from the master

-- pairwith arg address of server to pairwith

-- arbiter arg address of arbiter server arbitration server, used in the master and pair

-- autoresync automatically resync if slave data is stale automatically synchronizes slave data

-- oplogSize arg size limit (in MB) for oplog specifies the size of the operation log

-- opIdMem arg size limit (in bytes) for in memory storage of op ids specifies the amount of memory to store operation logs

Sharding options:

-- configsvr declare this is a config db of a cluster specifies the configuration server in shard

-- shardsvr declare this is a shard db of a cluster specifies shard server

Enter the CLI management interface of the database

Cd to the bin folder in the mongodb directory, and execute the command. / mongo

The operation is as follows:

[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 in the data directory. You can use the following repair command

Mongod-repair

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report