文档章节

Install MongoDB to Ubuntu 18.04

qwfys
 qwfys
发布于 2018/08/23 16:11
字数 867
阅读 243
收藏 0

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/

© 著作权归作者所有

qwfys

qwfys

粉丝 6
博文 192
码字总数 147557
作品 0
杭州
架构师
私信 提问
如何在Ubuntu 18.04 LTS上安装和配置MongoDB

如何在Ubuntu 18.04 LTS上安装和配置MongoDB IMCN 18分钟前暂无评论 阅读 9 次 MongoDB是一款非关系型数据库,提供高性能,高可用性和自动扩展企业数据库。 MongoDB是一个非关系型数据库,因...

IMCN
2018/05/05
0
0
Ubuntu 18.04 安装日志-高清截图

Ubuntu 18.04 安装日志-高清截图 IMCN 28分钟前暂无评论 阅读 18 次 ubuntu 18.04 发布了,还是忍不住把自己的系统重做了,安装中分区不再做交换分区,直接一个主分区安装。以下是我的安装截...

IMCN
2018/05/12
0
0
linux怎么访问小米路由的硬盘

linux怎么访问小米路由的硬盘 IMCN 12分钟前暂无评论 阅读 11 次 转载自小米官方社区,在自己的电脑上试了试,分享一下,我的系统是刚装的 Ubuntu 18.04 LTS。 手机(APP)客户端点击接入设备...

IMCN
2018/05/18
0
0
如何在 Ubuntu 上安装 MongoDB

本教程介绍了在 Ubuntu 和基于 Ubuntu 的 Linux 发行版上安装 MongoDB 的两种方法。 MongoDB 是一个越来越流行的自由开源的 NoSQL 数据库,它将数据存储在类似 JSON 的灵活文档集中,这与 SQ...

作者: Sergiu
08/02
0
0
Python3中PyMongo使用举例

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/fengbingchun/article/details/89069165 MongoDB是一个基于分布式文件存储的开源数据库,由C++语言编写,与平...

fengbingchun
04/07
0
0

没有更多内容

加载失败,请刷新页面

加载更多

定期批量改密,实现高效运维,保障口令安全

随着企业IT资产规模的不断增大,各类主机、应用系统的管理也变得愈加困难。 对于系统管理员来说,保证操作系统的密码安全是其重要工作,在需要维护众多的主机时,其面临的困境将是: 1、难以...

堡垒啊
43分钟前
5
0
怎样在磁盘上查找MySQL表的大小?这里有答案

导读 我想知道 MySQL 表在磁盘上占用多少空间,但看起来很琐碎。不应该在 INFORMATION_SCHEMA.TABLES 中提供这些信息吗?没那么简单! 我想知道 MySQL 表在磁盘上占用多少空间,但看起来很琐碎...

问题终结者
今天
6
0
jQuery load() 方法实现加载远程数据

jQuery load() 方法是简单但强大的 AJAX 方法。load() 方法从服务器加载数据,并把返回的数据放入被选元素中。 语法: $(selector).load(URL,data,callback);必需的 URL 参数规定您希望加载的...

前端老手
今天
5
0
Spring Boot缓存实战 Redis 设置有效时间和自动刷新缓存-2

问题 上一篇Spring Boot Cache + redis 设置有效时间和自动刷新缓存,时间支持在配置文件中配置,说了一种时间方式,直接扩展注解的Value值,如: @Override@Cacheable(value = "people#${s...

xiaolyuh
今天
14
0
怎样在磁盘上查找MySQL表的大小?这里有答案

我想知道 MySQL 表在磁盘上占用多少空间,但看起来很琐碎。不应该在 INFORMATION_SCHEMA.TABLES 中提供这些信息吗?没那么简单! 我想知道 MySQL 表在磁盘上占用多少空间,但看起来很琐碎。不应...

Linux就该这么学
今天
5
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部