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

Installation / configuration (file) / startup problems of mongodb

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

Share

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

Installation / configuration (file) / startup problems of mongodb

Download address: http://www.mongodb.org/downloads

[root@centos-1 software] # ll | grep mongodb-linux-x86_64-2.4.12.tar

-rw-r--r--. 1 root root 95267358 January 6 11:02 mongodb-linux-x86_64-2.4.12.tar

[root@centos-1 software] # tar-xvf mongodb-linux-x86_64-2.4.12.tar

[root@centos-1 software] # cd mongodb-linux-x86_64-2.4.12

[root@centos-1 mongodb-linux-x86_64-2.4.12] # ll

Total dosage 64

Drwxr-xr-x. 2 root root 4096 January 7 13:13 bin

-rw-. 1 nagios nagios 34520 August 4 2013 GNU-AGPL-3.0

-rw-. 1 nagios nagios 1359 August 4 2013 README

-rw-. 1 nagios nagios 18436 August 4 2013 THIRD-PARTY-NOTICES

Cp all ongodb-linux-x86_64-2.4.12 files to / usr/local/mongodb

[root@centos-1 mongodb-linux-x86_64-2.4.12] # cp-rf * / usr/local/mongodb/

[root@centos-1 mongodb] # cd / usr/local/mongodb

Create a data directory:

[root@centos-1 mongodb] # mkdir data

Create a log file:

[root@centos-1 mongodb] # touch logs

[root@centos-1 mongodb] # cd bin

[root@centos-1 bin] # pwd

/ usr/local/mongodb/bin

[root@centos-1 bin] # ll

The total dosage is 237824

-rwxr-xr-x. 1 root root 18316272 January 6 14:30 bsondump

-rwxr-xr-x. 1 root root 9537192 January 6 14:30 mongo

-rwxr-xr-x. 1 root root 18376872 January 6 14:30 mongod

-rwxr-xr-x. 1 root root 18373328 January 6 14:30 mongodump

-rwxr-xr-x. 1 root root 18328816 January 6 14:30 mongoexport

-rwxr-xr-x. 1 root root 18377760 January 6 14:30 mongofiles

-rwxr-xr-x. 1 root root 18340944 January 6 14:30 mongoimport

-rwxr-xr-x. 1 root root 18320432 January 6 14:30 mongooplog

-rwxr-xr-x. 1 root root 18320080 January 6 14:30 mongoperf

-rwxr-xr-x. 1 root root 18381296 January 6 14:30 mongorestore

-rwxr-xr-x. 1 root root 13868984 January 6 14:30 mongos

-rwxr-xr-x. 1 root root 18286728 January 6 14:30 mongosniff

-rwxr-xr-x. 1 root root 18366064 January 6 14:30 mongostat

-rwxr-xr-x. 1 root root 18320944 January 6 14:30 mongotop

Cp the files mongo (customer server command) / mongod (mongo startup command) to / usr/bin (these two commands become global commands)

[root@centos-1 bin] # cp mongod / usr/bin/

[root@centos-1 bin] # cp mongo / usr/bin/

Create a profile for mongo:

[root@centos-1 bin] # touch / etc/mongodb.conf

Just configure the parameters in the file.

# configuration files are stored in / etc/mongod.conf

#-- here is the content--

# mongo.conf

# location where database files are saved

Dbpath=/usr/local/mongodb/data

# location where log files are saved

Logpath=/usr/local/mongodb/logs

# Log recording method, which is saved by adding

Logappend=true

# authentication is required

Auth=true

# running port

Port=27017

# running in the background

Fork=true

# pid file path

Pidfilepath=/usr/local/mongodb/mongodb.pid

Start the mongodb service:

[root@centos-1 bin] # mongod-- config=/etc/mongodb.conf

About to fork child process, waiting until server is ready for connections.

Forked process: 30913

All output going to: / usr/local/mongodb/logs

Child process started successfully, parent exiting

Check to see if the service started successfully:

[root@centos-1 bin] # netstat-lanp | grep "27017"

Unix 2 [ACC] STREAM LISTENING 211915 30932/mongod / tmp/mongodb-27017.sock

Shut down the mongodb service:

[root@centos-1 bin] # mongod-dbpath=/usr/local/mongodb/data-shutdown

Killing process with pid: 30913

Configure the mongodb service to boot: add mongod-- config=/etc/mongodb.conf to / etc/rc.local

[root@centos-1 bin] # vi / etc/rc.local

#! / bin/sh

#

# This script will be executed * after* all the other init scripts.

# You can put your own initialization stuff in here if you don't

# want to do the full Sys V style init stuff.

Mongod-config=/etc/mongodb.conf

Touch / var/lock/subsys/local

/ usr/local/net-snmp/sbin/snmpd-c / etc/snmpd.con

The above is the configuration and installation of mongodb

Mongodb.conf startup parameters

Configuration files are stored in / etc/mongod.conf

#-- here is the content--

# mongo.conf

# location of log files

Logpath=/var/log/mongo/mongod.log

# write to the log by append

Logappend=true

# whether it has been run in daemon mode (background running)

Fork = true

# set port (default 27017)

# port = 27017

# location where database files are saved

Dbpath=/var/lib/mongo

# Enables periodic logging of CPU utilization and I/O wait

# enable periodic recording of CPU utilization and IGM O wait

# cpu = true

# Turn on/off security. Off is currently the default

# whether to run in a secure authentication mode. The default is a non-secure way that is not certified.

# noauth = true

# auth = true

# Verbose logging output.

# detailed record output

# verbose = true

# Inspect all client data for validity on receipt (useful for

# developing drivers) used to check the validity of the data received by the client when developing the driver

# objcheck = true

# Enable db quota management

# enable database quota management. By default, each db can have 8 files, which can be set with the quotaFiles parameter.

# quota = true

# set oplog record level

# Set oplogging level where n is

# 0=off (default)

# 1 / W

# 2r

# 3=both

# 7=W+some reads

# oplog = 0

# Diagnostic/debugging option dynamic debugging items

# nocursors = true

# Ignore query hints ignores query hints

# nohints = true

# disable http interface. Default is localhost:28017

# Disable the HTTP interface (Defaults to localhost:27018). This port number is wrong.

# nohttpinterface = true

# turn off server-side scripts, which will greatly limit the functionality

# Turns off server-side scripting. This will result in greatly limited

# functionality

# noscripting = true

# turn off scanning table, any query will cause scan failure

# Turns off table scans. Any query that would do a table scan fails.

# notablescan = true

# turn off data file pre-allocation

# Disable data file preallocation.

# noprealloc = true

# specify the size of the .ns file for the new database, in MB

# Specify. Ns file size for new databases.

# nssize =

# Accout token for Mongo monitoring server.

# mms-token =

# name of mongo monitoring server

# Server name for Mongo monitoring server.

# mms-name =

# ping interval of mongo monitoring server

# Ping interval for Mongo monitoring server.

# mms-interval =

# Replication Options replication options

# in replicated mongo databases. Specify here whether this is a slave or master is in replication. Specifies that it is currently a dependency.

# slave = true

# source = master.example.com

# Slave only: specify a single database to replicate

# only = master.example.com

# or

# master = true

# source = slave.example.com

= =

Personal understanding of some of the important parameters:

-- dbpath: data storage directory, which is a required parameter for mongodb startup.

-logpath: log stores files, if mongodb starts without this parameter.

-- logappend: the log is written to the log file as an append.

-- auth: users who log in to mongo must verify their identity (provide password and account number). Empty accounts can log in but do not have permission to operate DB.

If this parameter is not specified at startup, the user who logs in to mongo has all permissions (not secure)

Users in admin architecture have the most privileges and can query information in any other schema, while users in other schemas can only view information in their own schemas.

-- port: designated port

-- shutdown: shut down the mongo service

-- fork: runs in the background. This parameter must be used with-- logpath.

Reference link:

Http://blog.csdn.net/yuwenruli/article/details/8529192

Http://www.it165.net/database/html/201402/5303.html

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