centos mogodb 安装

前端之家收集整理的这篇文章主要介绍了centos mogodb 安装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、环境准备:

1mkdir/home/mongodb#创建MongoDB程序存放目录2mkdir/data/mongodata-p#创建数据存放目录3mkdir/data/log/mongolog-p#创建日志存放目录

2、下载:

1curl-Ohttps://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.1.tgz

3、安装:

1tarxfmongodb-linux-x86_64-3.2.1.tgz2cdmongodb-linux-x86_64-3.2.13cp-r*/home/mongodb

为了便于命令启动,需要编辑全局变量PATH

1vim/etc/profile.d/mongo.sh2exportPATH=$PATH:/home/mongodb/bin
source/etc/profile.d/mongo.sh

4、启动服务

首先查看mongod的帮助信息

1[root@test~]#mongod--help
启动服务示例:
1mongod--dbpath=/data/mongodata--logpath=/data/log/mongolog/mongodb.log--logappend--fork

查看是否启动:

1netstat-tnlp|grepmongod2tcp000.0.0.0:270170.0.0.0:*LISTEN17909/mongod

以上可看出端口27017已经运行

5、测试

启动mongodb的shell:

1[root@test~]#mongo2MongoDBshellversion:3.2.13connectingto:test4Serverhasstartupwarnings:
52016-01-25T16:12:52.960+0800ICONTROL[initandlisten]**WARNING:Youarerunningthisprocessastherootuser,whichisnotrecommended.62016-01-25T16:12:52.960+0800ICONTROL[initandlisten]
72016-01-25T16:12:52.960+0800ICONTROL[initandlisten]
82016-01-25T16:12:52.960+0800ICONTROL[initandlisten]**WARNING:/sys/kernel/mm/transparent_hugepage/enabledis'always'.92016-01-25T16:12:52.960+0800ICONTROL[initandlisten]**Wesuggestsettingitto'never'102016-01-25T16:12:52.960+0800ICONTROL[initandlisten]
112016-01-25T16:12:52.960+0800ICONTROL[initandlisten]**WARNING:/sys/kernel/mm/transparent_hugepage/defragis'always'.122016-01-25T16:12:52.960+0800ICONTROL[initandlisten]**Wesuggestsettingitto'never'132016-01-25T16:12:52.960+0800ICONTROL[initandlisten]
14>help15db.help()helpondbmethods16db.mycoll.help()helponcollectionmethods17sh.help()shardinghelpers18rs.help()replicasethelpers19helpadminadministrativehelp20helpconnectconnectingtoadbhelp21helpkeyskeyshortcuts22helpmiscmiscthingstoknow23helpmrmapreduce2425showdbsshowdatabasenames26showcollectionsshowcollectionsincurrentdatabase27showuseRSShowusersincurrentdatabase28showprofileshowmostrecentsystem.profileentrieswithtime>=1ms29showlogsshowtheaccessibleloggernames30showlog[name]printsoutthelastsegmentofloginmemory,'global'isdefault31use<db_name>setcurrentdatabase32db.foo.find()listobjectsincollectionfoo33db.foo.find({a:1})listobjectsinfoowherea==134itresultofthelastlineevaluated;usetofurtheriterate35DBQuery.shellBatchSize=xsetdefaultnumberofitemstodisplayonshell36exitquitthemongoshell37>showdbs38local0.000GB39>

至此,MongoDB3.2.1安装完毕。

原文链接:https://www.f2er.com/centos/380023.html

猜你在找的CentOS相关文章