mongodb单机环境搭建

实验环境

操作系统: ubuntu-16.04-x64
mongodb版本:3.6.2

安装步骤

1.下载安装包

下载mongodb安装包,点击这里,本次实验选择ubuntu-16.04-x64。

2.解压与配置

  1. 将下载好的安装包上传到linux主机上。

  2. 解压安装包并拷贝到安装路径下。

     tar xf mongodb-linux-x86_64-ubuntu1604-4.0.0.tgz 
     cp  cp mongodb  /usr/local
    
  3. 修改环境变量PATH

     vim /etc/profile
     export PATH="$PATH:/usr/local/mongodb/bin"  
     source /etc/profile  # 使环境变量的修改立即生效
    

3.启动

启动mongodb

mongod  --dbpath  /usr/local/mongodb/data/  --logpath /usr/local/mongodb/ls/mongo.log
--dbpath:用于指定mongodb数据文件路径
--logpath:用于指定mongodb日志文件路径

启动mongodb client

root@ubuntu:/usr/local/mongodb/logs# mongo
MongoDB shell version v3.6.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.2
Server has startup warnings: 
2018-06-28T21:44:48.381-0700 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-06-28T21:44:48.381-0700 I CONTROL  [initandlisten] 
2018-06-28T21:44:48.381-0700 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2018-06-28T21:44:48.381-0700 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 
2018-06-28T21:44:48.381-0700 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 
2018-06-28T21:44:48.381-0700 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2018-06-28T21:44:48.381-0700 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2018-06-28T21:44:48.381-0700 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2018-06-28T21:44:48.381-0700 I CONTROL  [initandlisten]

在命令行中输入:

> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB

猜你喜欢

转载自blog.csdn.net/cl2010abc/article/details/80855097