mongodb的安装/配置(文件)/启动 问题
admin
2023-04-12 11:03:36
0


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 =


# Accout token for Mongo monitoring server.

#mms-token =

# mongo监控服务器的名称

# Server name for Mongo monitoring server.

#mms-name =

# mongo监控服务器的ping 间隔

# Ping interval for Mongo monitoring server.

#mms-interval =


# 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




相关内容

热门资讯

徐巧芯剖析赖清德:最怕自己丢掉... 海峡导报综合报道 大罢免投票一周年纪念活动26日举行,台北市长蒋万安出席并怒轰,民进党一年过后仍没有...
中国红十字会总会紧急向广东调拨... 记者从中国红十字会总会了解到,针对台风“红霞”给广东造成的灾情,中国红十字会总会启动四级应急响应,紧...
这些少年,正被“毒蛋”围猎 李梦抽了几口电子烟,吐出了白色的烟雾,有一股浓烈的水果香味。随后,她看着自己握电子烟的手,跟身边人说...
蒋万安号召“倒阁”,卢秀燕认为... 海峡导报综合报道 台北市长蒋万安27日抛出震撼议题,表示多名民代向他提议推动“倒阁”,要求台行政机构...
特朗普将在白宫会见两位重要客人 俄乌战争仍未结束,美伊冲突又有升级风险。在此背景下,美国总统特朗普将在白宫接见乌克兰和以色列领导人。...
新租客打扫卧室柜子上掉落4万元... 近日,莲前西路某小区内,张倩签下一套房子的租赁合同。当天上午,她带着12岁的大女儿周馨怡和11岁的小...
六部门通告:禁止涉军队退役报废... 关于禁止涉军队退役报废装备销售活动的通告近年来,部分经营者在线上线下公开销售涉及我军退役报废装备(指...
九寨沟景区发生泥石流,部分道路... 7月26日,九寨沟风景名胜区管理局发布泥石流灾害通报:2026年7月26日15时50分,九寨沟景区局...
空调26度不凉是什么原因 从空调内部元器件来说,不凉的原因有可能是温度传感器出现故障了,也有可能是空调压缩机或者铜管出现问题,...
鲸鸿动能携手香港国际机场、鸿蒙...   2026 年 7 月 25 日,十余位鸿蒙车主组成的车队从珠海出发,经港珠澳大桥通关抵达香港国际...