当前位置: 首页 > news >正文

Install MongoDB to Ubuntu 18.04

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

Import the public key used by the package management system

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

Create a list file for MongoDB.

echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list

Reload local package database

sudo apt update

Install the latest version of MongoDB

sudo apt install -y mongodb-org

mongodb client

lwk@ubuntu1804:~$ sudo systemctl status mongodb
Unit mongodb.service could not be found.
lwk@ubuntu1804:~$ sudo systemctl status mongod
● mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: https://docs.mongodb.org/manual
lwk@ubuntu1804:~$ sudo systemctl start mongod
lwk@ubuntu1804:~$ sudo systemctl status mongod
● mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-08-23 08:23:39 UTC; 3s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 2268 (mongod)
   CGroup: /system.slice/mongod.service
           └─2268 /usr/bin/mongod --config /etc/mongod.conf

Aug 23 08:23:39 ubuntu1804 systemd[1]: Started MongoDB Database Server.
Aug 23 08:23:39 ubuntu1804 mongod[2268]: 2018-08-23T08:23:39.507+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-ena
lwk@ubuntu1804:~$
lwk@ubuntu1804:~$ mongo
MongoDB shell version v4.0.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.1
Welcome 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
Server has startup warnings: 
2018-08-23T08:23:39.590+0000 I STORAGE  [initandlisten] 
2018-08-23T08:23:39.590+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2018-08-23T08:23:39.590+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2018-08-23T08:23:40.125+0000 I CONTROL  [initandlisten] 
2018-08-23T08:23:40.125+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-08-23T08:23:40.125+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-08-23T08:23:40.125+0000 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()
---

> 

远程连接

lwk@qwfys:~$ mongo 01.ubuntu.qwfys.com:27017/test
MongoDB shell version v4.0.1
connecting to: mongodb://01.ubuntu.qwfys.com:27017/test
2018-08-23T17:38:03.153+0800 E QUERY    [js] Error: couldn't connect to server 01.ubuntu.qwfys.com:27017, connection attempt failed: SocketException: Error connecting to 01.ubuntu.qwfys.com:27017 (192.168.56.101:27017) :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed
lwk@qwfys:~$

连接不上,需要将mongodb配置文件/etc/mongod.conf

lwk@ubuntu1804:~$ cat /etc/mongod.conf 
# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1


# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:
lwk@ubuntu1804:~$ 

中的bindIp的值改为0.0.0.0,然后重启服务。修改后,重启服务后再连接:

lwk@qwfys:~$ mongo 01.ubuntu.qwfys.com:27017/test
MongoDB shell version v4.0.1
connecting to: mongodb://01.ubuntu.qwfys.com:27017/test
MongoDB server version: 4.0.1
Server has startup warnings: 
2018-08-23T09:41:05.597+0000 I STORAGE  [initandlisten] 
2018-08-23T09:41:05.597+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2018-08-23T09:41:05.597+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2018-08-23T09:41:06.326+0000 I CONTROL  [initandlisten] 
2018-08-23T09:41:06.326+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-08-23T09:41:06.326+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-08-23T09:41:06.326+0000 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://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

转载于:https://my.oschina.net/qwfys200/blog/1933001

相关文章:

  • SpringCloud Gateway入门
  • 使用jQuery操作input的value值
  • tpl-angularjs Web端开发工程模板
  • [python] RRT快速拓展随机树
  • 《Python从菜鸟到高手》已经出版,开始连载了,购买送视频课程
  • Clojure基础课程2-Clojure中的数据长啥样?
  • Spring Boot【快速入门】
  • 使用时间器区别网页上的单击和双击
  • css设置全局变量和局部变量
  • 宏观政策转向,消费金融行业能否送别“至暗时刻”?
  • vc code
  • FLIP-24+-+SQL+Client
  • 【转】【WPF】WPF - MVVM - 如何将ComboBox的Selectchange事件binding到ViewModel
  • linux内核中链表代码分析---list.h头文件分析(二)【转】
  • 时间不对导致vSAN服务无法启动
  • hexo+github搭建个人博客
  • 《深入 React 技术栈》
  • 07.Android之多媒体问题
  • express.js的介绍及使用
  • git 常用命令
  • HTML5新特性总结
  • linux学习笔记
  • SegmentFault 技术周刊 Vol.27 - Git 学习宝典:程序员走江湖必备
  • Sequelize 中文文档 v4 - Getting started - 入门
  • vue从创建到完整的饿了么(18)购物车详细信息的展示与删除
  • 初识 beanstalkd
  • 初识MongoDB分片
  • 高性能JavaScript阅读简记(三)
  • 关于使用markdown的方法(引自CSDN教程)
  • 聊聊sentinel的DegradeSlot
  • 前端技术周刊 2018-12-10:前端自动化测试
  • 深度学习入门:10门免费线上课程推荐
  • 它承受着该等级不该有的简单, leetcode 564 寻找最近的回文数
  • 无服务器化是企业 IT 架构的未来吗?
  • 在Unity中实现一个简单的消息管理器
  • 怎么将电脑中的声音录制成WAV格式
  • ​​快速排序(四)——挖坑法,前后指针法与非递归
  • ​ArcGIS Pro 如何批量删除字段
  • ​DB-Engines 11月数据库排名:PostgreSQL坐稳同期涨幅榜冠军宝座
  • #QT项目实战(天气预报)
  • #前后端分离# 头条发布系统
  • (10)ATF MMU转换表
  • (175)FPGA门控时钟技术
  • (4) openssl rsa/pkey(查看私钥、从私钥中提取公钥、查看公钥)
  • (delphi11最新学习资料) Object Pascal 学习笔记---第5章第5节(delphi中的指针)
  • (Redis使用系列) SpringBoot中Redis的RedisConfig 二
  • (搬运以学习)flask 上下文的实现
  • (附源码)计算机毕业设计ssm高校《大学语文》课程作业在线管理系统
  • (三)c52学习之旅-点亮LED灯
  • (十五)Flask覆写wsgi_app函数实现自定义中间件
  • (转)甲方乙方——赵民谈找工作
  • (转)原始图像数据和PDF中的图像数据
  • **PHP二维数组遍历时同时赋值
  • .Net 8.0 新的变化
  • .NET C# 使用 SetWindowsHookEx 监听鼠标或键盘消息以及此方法的坑