温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

mongodb的安装/配置(文件)/启动 问题

发布时间:2020-06-23 12:18:45 来源:网络 阅读:1420 作者:dengwang123 栏目:MongoDB数据库


mongodb的安装/配置(文件)/启动 问题

下载地址: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 1月   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

总用量 64

drwxr-xr-x. 2 root   root    4096 1月   7 13:13 bin

-rw-------. 1 nagios nagios 34520 8月   4 2013 GNU-AGPL-3.0

-rw-------. 1 nagios nagios  1359 8月   4 2013 README

-rw-------. 1 nagios nagios 18436 8月   4 2013 THIRD-PARTY-NOTICES


将ongodb-linux-x86_64-2.4.12 文件全部cp到 /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


创建数据目录:

[root@centos-1 mongodb]# mkdir  data

创建日志文件:

[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

总用量 237824

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

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

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

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

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

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

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

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

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

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

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

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

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

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


将文件 mongo(客服端命令)/mongod(mongo启动命令)cp到/usr/bin(是这两个命令成为全局命令)

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

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


创建mongo的配置文件:

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

文件中配置一下参数即可。


# 配置文件存放在/etc/mongod.conf

# ------------------------------一下是内容---------------------------------------

# mongo.conf


# 数据库文件保存位置

dbpath=/usr/local/mongodb/data


# 日志文件的保存位置

logpath=/usr/local/mongodb/logs


# 日志的记录方式,日志以添加的方式保存

logappend=true


# 需要身份验证

auth=true


# 运行端口

port=27017


# 在后台运行

fork=true


# pid 文件路径

pidfilepath=/usr/local/mongodb/mongodb.pid



启动mongodb服务:

[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


查看服务是否成功启动:

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

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


关闭mongodb服务:

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

killing process with pid: 30913



配置mongodb服务为开机启动:将 mongod  --config=/etc/mongodb.conf 添加到/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



=======以上就是mongodb的配置和安装===============================================================

mongodb.conf启动参数


配置文件存放在/etc/mongod.conf

#------------------------------一下是内容---------------------------------------

# mongo.conf


# 日志文件存放位置

logpath=/var/log/mongo/mongod.log


# 以追加方式写入日志

logappend=true


# 是否已守护进程方式运行(后台运行)

fork = true


# 设置端口(默认27017)

#port = 27017


# 数据库文件保存位置

dbpath=/var/lib/mongo


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

# 启用定期记录CPU利用率和 I/O 等待

#cpu = true


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

# 是否以安全认证方式运行,默认是不认证的非安全方式

#noauth = true

#auth = true


# Verbose logging output.

# 详细记录输出

#verbose = true


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

# developing drivers)用于开发驱动程序时的检查客户端接收数据的有效性

#objcheck = true


# Enable db quota management

# 启用数据库配额管理,默认每个db可以有8个文件,可以用quotaFiles参数设置

#quota = true

# 设置oplog记录等级

# Set oplogging level where n is

#   0=off (default)

#   1=W

#   2=R

#   3=both

#   7=W+some reads

#oplog = 0


# Diagnostic/debugging option 动态调试项

#nocursors = true


# Ignore query hints 忽略查询提示

#nohints = true

# 禁用http界面,默认为localhost:28017

# Disable the HTTP interface (Defaults to localhost:27018).这个端口号写的是错的

#nohttpinterface = true


# 关闭服务器端脚本,这将极大的限制功能

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

# functionality

#noscripting = true

# 关闭扫描表,任何查询将会是扫描失败

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

#notablescan = true

# 关闭数据文件预分配

# Disable data file preallocation.

#noprealloc = true

# 为新数据库指定.ns文件的大小,单位:MB

# Specify .ns file size for new databases.

# nssize = <size>


# Accout token for Mongo monitoring server.

#mms-token = <token>

# mongo监控服务器的名称

# Server name for Mongo monitoring server.

#mms-name = <server-name>

# mongo监控服务器的ping 间隔

# Ping interval for Mongo monitoring server.

#mms-interval = <seconds>


# Replication Options 复制选项


# in replicated mongo databases, specify here whether this is a slave or master 在复制中,指定当前是从属关系

#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


=====================================

个人对部分分重要参数的理解:


--dbpath:数据存放目录,mongodb启动的必带参数。

–logpath:日志存放文件,mongodb启动时如果没有带这个参数。

--logappend:日志以追加的方式写入日志文件。

--auth:登陆到mongo的用户必须验证身份(提供密码和账号),空账号可登陆但是无权限操作DB,

启动的时候如果没有指定此参数,那么登陆到mongo的用户具有所有的权限(不安全),

admin架构中的用户权限最大,可以查询其他任何架构中的信息,其他架构中的用户只能查看自己架构中的信息。

–-port:指定端口

--shutdown:关闭mongo服务

--fork:在后台运行,此参数必须同--logpath一起使用。


参考链接:

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

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




向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI