Centos安装mongodb

来源:互联网 发布:mac系统cs6破解补丁 编辑:程序博客网 时间:2024/05/04 23:09
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


转载来源:http://www.16boke.com/article/detail/37

0 0
原创粉丝点击