千家信息网

rhel6上install mongodb

发表于:2025-02-03 作者:千家信息网编辑
千家信息网最后更新 2025年02月03日,下载:mongodb-linux-x86_64-3.2.6.tgz请去mongodb的官方网站下载,本地址不提供下载。上传mongodb-linux-x86_64-3.2.6.tgz到/usr/loc
千家信息网最后更新 2025年02月03日rhel6上install mongodb

下载:mongodb-linux-x86_64-3.2.6.tgz

请去mongodb的官方网站下载,本地址不提供下载。


上传mongodb-linux-x86_64-3.2.6.tgz到/usr/local目录下

tar xvfz mongodb-linux-x86_64-3.2.6.tgzmv mongodb-linux-x86_64-3.2.6 mongodbchown -R mongo:dbmon mongodb

安装完成,mongodb的安装就是解压过程。


下面是启动:

cd mongodb

bin/mongod --dbpath=/data/mongodb/

指定数据文件所在目录,默认是/data/db。如果执行此启动命令的session关掉,则mongodb也一起关掉。如果让它后台运行则要加参数fork,如果指定fork,则要指定logpath参数。


可以编辑一个参数文件,启动时指定参数文件启动。在参数文件中指定相关参数。

先创建配置文件、数据文件、日志文件的路径

cd /usr/local/mongodbmkdir datamkdir etcmkdir logscd etctouch mongodb.cnfjournal=truebind_ip=xxx.xxx.xxx.xxxport=27017httpinterface=truerest=truestorageEngine=mmapv1dbpath=/usr/local/mongodb/datafork=truelogpath=/usr/local/mongodb/logs/mongodb.logprofile=1slowms=1replSet=xbfax

指定参数文件启动

cd /usr/local/mongodbbin/mongod -f /usr/local/mongodb/etc/mongodb.cnf


客户端连接:

bin/mongo xxx.xxx.xxx.xxx:27017MongoDB shell version: 3.2.6connecting to: xxx.xxx.xxx.xxx:27017/testWelcome to the MongoDB shell.For interactive help, type "help".For more comprehensive documentation, see        http://docs.mongodb.org/Questions? Try the support group        http://groups.google.com/group/mongodb-user


或是在windows上使用图形化工具:MongoVUE

关于MongoVUE请自行google


下面是相关参数的一些解释:

journal 启用日志选项,MongoDB的数据操作将会写入到journal文件夹的文件里,默认为true
bind_ip 绑定服务IP,若绑定127.0.0.1,则只能本机访问,不指定默认本地所有IP
port 指定服务端口号,默认端口27017
httpinterface http接口
rest 开启rest API
storageEngine 启动引擎
dbpath 数据文件存放路径
fork 以守护进程的方式运行MongoDB,创建服务器进程
logpath 指定MongoDB日志文件,注意是指定文件不是目录
profile 档案参数 0=off 1=slow, 2=all
slowms value of slow for profile and console log
replSet 设置副本集名称

0