返回首页
当前位置: 主页 > 操作系统 > Ubuntu教程 >

Centos安装mongodb基础教程

时间:2016-11-11 22:12来源:电脑教程学习网 www.etwiki.cn 编辑:admin

1、从官网下载最新的mongodb,选择Linux,再根据自己本机的linux系统选择相应的版本。

2、解压下载的mongodb的tar包

解压之后主要的运行脚本都在bin目录中,建立软链接:ln -s /usr/soft/mongodb/bin/* /usr/local/bin。这样就可以直接使用mongo的各种命令

3、运行mongo

建立数据文件夹db、日志文件夹logs、配置文件夹conf

建立三个脚本文件:startMongo.sh、stopMongo.sh、mongoStat.sh

(1)startMongo.sh 启动mongo脚本

/usr/soft/mongodb/bin/mongod -f /usr/soft/mongodb/conf/mongodb_27021.conf --jour nal

(2)stopMongo.sh 停止mongo脚本

/usr/soft/mongodb/bin/mongod -f /usr/soft/mongodb/conf/mongodb_27021.conf --shut

down

(3)mongoStat.sh 每隔10秒钟查看一次mongo状态

./mongostat --port 27021 10
4、附上mongodb_27021.conf的配置内容


# mongo.conf

#where to log
logpath=/usr/soft/mongodb/logs/mongo_27021.log

logappend=true

# fork and run in background
fork = true

port = 27021
# dbpath=/var/lib/mongo

dbpath=/usr/soft/mongodb/db/

# Disables write-ahead journaling

# Enables periodic logging of CPU utilization and I/O wait
#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
#quota = true

# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads

# Ignore query hints
#nohints = true

# 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

# Specify .ns file size for new databases.
# nssize =

# Accout token for Mongo monitoring server.
#mms-token =

# Server name for Mongo monitoring server.
#mms-name =

# 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
#rest = true

顶一下
(0)
0%
踩一下
(0)
0%
标签(Tag):Centos安装mong
------分隔线----------------------------
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
验证码:点击我更换图片
推荐内容