centos6.5安装mongodb

step1:

下载https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.11.tgz 最新版,这个是linux64位下载地址,你也可以到首页自己选择

step2:

解压tar vxf mongodb-linux-x86_64-2.4.11.tgz,解压完之后,进入到根(/)目录,创建data/db文件夹

step3:

进入解压完之后的mongodb文件夹,进入bin目录,运行./mongod,发现出现错误信息:Please make at least 3379MB available in /data/db/journal or use --smallfiles,提示空间不够

step4:

这个时候使用命令:./mongod --smallfiles来进行启动,如果继续提示空间不够,那么需要删除一些压缩包,来释放空间

成功启动界面
step5:

如果你需要进入MongoDB后台管理,你需要先打开mongodb装目录的下的bin目录,然后执行mongo命令文件。命令是[root@centos bin]# ./mongo

step6:

在比MongoDB服务的端口多1000的端口上,你可以访问到MondoDB的web用户界面。如:如果你的MongoDB运行端口使用默认的27017,你可以在端口号为28017访问web用户界面。



关闭mongodb命令: [ root@centos  bin]#  ./mongod --shutdown
以守护进程来启动mongodb:在mongodb根目录下建立etc文件夹,在etc文件夹下新建一个mongo.conf的配置文件,
路径是/root/Downloads/mongodb-linux-x86_64-2.4.11/etc/mongo.conf , 该文件内容如下:
logpath=../log/mongodb.log 
logappend=false
dbpath=/root/Downloads/data/db
fork=true

之后保存退出,建立log文件夹,之后可以以守护进程来启动
[root@centos bin]# ./mongod -f ../etc/mongo.conf --smallfiles 
warning: remove or comment out this line by starting it with '#', skipping now : logappend=false 
about to fork child process, waiting until server is ready for connections. 
forked process: 5217 
all output going to: /root/Downloads/mongodb-linux-x86_64-2.4.11/bin/../log/mongodb.log 
log file [/root/Downloads/mongodb-linux-x86_64-2.4.11/bin/../log/mongodb.log] exists; copied to temporary file [/root/Downloads/mongodb-linux-x86_64-2.4.11/bin/../log/mongodb.log.2014-10-13T03-37-09] 
child process started successfully, parent exiting 
[root@centos bin]#

表示启动成功了,可以使用如下命令查看
[ root@centos bin]# ps -ef|grep monfod 
root 5233 4393 0 11:39 pts/2 00:00:00 grep monfod

这时候可以使用telnet来查看27017端口是否启动:telnet localhost 27017
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
表示端口正在进行监听
如果关闭守护进程要使用:./mongod --shutdown --dbpath= /root/Downloads/data/db

这个时候我们访问web端口只能看到首页信息,内部信息是看不到的,如果想看到,需要在配置文件中加入一句话rest=true然后重新启动服务即可

关闭mongodb命令: [ root@centos  bin]#  ./mongod --shutdown
以守护进程来启动mongodb:在mongodb根目录下建立etc文件夹,在etc文件夹下新建一个mongo.conf的配置文件,
路径是/root/Downloads/mongodb-linux-x86_64-2.4.11/etc/mongo.conf , 该文件内容如下:
logpath=../log/mongodb.log 
logappend=false
dbpath=/root/Downloads/data/db
fork=true

之后保存退出,建立log文件夹,之后可以以守护进程来启动
[ root@centos bin]# ./mongod -f ../etc/mongo.conf --smallfiles 
warning: remove or comment out this line by starting it with '#', skipping now : logappend=false 
about to fork child process, waiting until server is ready for connections. 
forked process: 5217 
all output going to: /root/Downloads/mongodb-linux-x86_64-2.4.11/bin/../log/mongodb.log 
log file [/root/Downloads/mongodb-linux-x86_64-2.4.11/bin/../log/mongodb.log] exists; copied to temporary file [/root/Downloads/mongodb-linux-x86_64-2.4.11/bin/../log/mongodb.log.2014-10-13T03-37-09] 
child process started successfully, parent exiting 
[ root@centos bin]#

表示启动成功了,可以使用如下命令查看
[ root@centos bin]# ps -ef|grep monfod 
root 5233 4393 0 11:39 pts/2 00:00:00 grep monfod

这时候可以使用telnet来查看27017端口是否启动:telnet localhost 27017
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
表示端口正在进行监听
如果关闭守护进程要使用:./mongod --shutdown --dbpath= /root/Downloads/data/db

这个时候我们访问web端口只能看到首页信息,内部信息是看不到的,如果想看到,需要在配置文件中加入一句话rest=true然后重新启动服务即可
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值