Linux-Ubuntu14.04下mongodb安装部署

本文详细介绍了如何在 Ubuntu 系统上下载、安装和配置 MongoDB 数据库版本 4.0.5 的全过程。包括创建必要的目录,解压并安装 MongoDB 文件,设置数据库目录和日志文件,安装客户端,以及使用关键参数启动数据库服务。

 

mongo 下载:https://www.mongodb.com/download-center/community?jmp=nav

创建目录,将下载的文件放在如下位置

xxx@ubuntu:/usr/local$ sudo mkdir mongo
xxx@ubuntu:/usr/local$ ls
bin  etc  games  include  lib  man  mongo  sbin  share  src
xxx@ubuntu:/usr/local$ cd mongo/
xxx@ubuntu:/usr/local/mongo$ ls
mongodb-linux-x86_64-ubuntu1404-4.0.5.tgz

解压

xxx@ubuntu:/usr/local/mongo$ sudo tar -xvf mongodb-linux-x86_64-ubuntu1404-4.0.5.tgz
xxx@ubuntu:/usr/local/mongo$ ls
mongodb-linux-x86_64-ubuntu1404-4.0.5
mongodb-linux-x86_64-ubuntu1404-4.0.5.tgz

创建数据库目录以及日志文件

xxx@ubuntu:/usr/local/mongo$ cd mongodb-linux-x86_64-ubuntu1404-4.0.5
xxx@ubuntu:/usr/local/mongo/mongodb-linux-x86_64-ubuntu1404-4.0.5$ sudo mkdir data 
xxx@ubuntu:/usr/local/mongo/mongodb-linux-x86_64-ubuntu1404-4.0.5$ sudo touch logs
xxx@ubuntu:/usr/local/mongo/mongodb-linux-x86_64-ubuntu1404-4.0.5$ ls 
bin logs MPL-2 data logs.2019-01-14T08-18-21 README LICENSE-Community.txt logs.2019-01-14T08-25-22 THIRD-PARTY-NOTICES

 

安装客户端

先下载这个文件,然后安装

sudo dpkg -i mongodb-org-shell_4.0.5_amd64.deb

进入到mongodb下面的bin里面查看mongodb帮助文档

./mongod -h

找到参数

--fork

--dbpath arg

--logpath arg

--nohttpinterface

--dbpath=/usr/local/mongodb/data/ 用于指定存放的mongodb数据库

--fork 是后台执行,不然一直在前台

--logpath=/usr/local/mongodb/logs 用于指定mongodb的日志记录文件

 

启动数据库

sudo ./mongod --dbpath=/usr/local/mongo/mongodb-linux-x86_64-ubuntu1404-4.0.5/data/ --logpath=/usr/local/mongo/mongodb-linux-x86_64-ubuntu1404-4.0.5/logs

即可通过mongo命令进入数据库。

xxx@ubuntu:~/Desktop$ mongo
MongoDB shell version v4.0.5
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("0783a892-c57e-4dee-94af-c3746762298a") }
MongoDB server version: 4.0.5
Server has startup warnings: 
2019-01-14T16:48:44.102+0800 I STORAGE  [initandlisten] 
2019-01-14T16:48:44.102+0800 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-01-14T16:48:44.102+0800 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] 
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] 
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] 
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] 
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-01-14T16:48:44.839+0800 I CONTROL  [initandlisten] 
2019-01-14T16:48:44.840+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-01-14T16:48:44.840+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-01-14T16:48:44.840+0800 I CONTROL  [initandlisten] 
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

> 

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/sea-stream/p/10267639.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值