当前位置:首页 > 数据库 > Mongodb 两种 安装方式

Mongodb 两种 安装方式

2022年09月16日 08:17:57数据库8
环境: linux 下: redhat or centos
MONGODB 安装方式1: 通过配置yum,来安装mongodb, 企业版与一般版本:
不多说,直接看文档
[root@dominic5 ~]# ping www.baidu.com
PING www.a.shifen.com (180.97.33.71) 56(84) bytes of data.
64 bytes from 180.97.33.71: icmp_seq=1 ttl=52 time=25.3 ms
64 bytes from 180.97.33.71: icmp_seq=2 ttl=52 time=29.3 ms
[root@dominic5 ~]# cat /etc/yum.repos.d/mongodb.repo   --一般版本
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
[mongodb-enterprise-2.6]                                              --企业版本安装
name=MongoDB Enterprise 2.6 Repository
baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/2.6/$basearch/
gpgcheck=0
enabled=1
[root@dominic4 ~]#sudo yum install mongodb-org
[root@dominic4 ~]# sudo yum install mongodb-enterprise

Loaded plugins: product-id, security, subscription-manager
Updating Red Hat repositories.
server | 1.5 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mongodb-enterprise.x86_64 0:2.6.3-1.el5 set to be updated
--> Processing Dependency: mongodb-enterprise-mongos = 2.6.3 for package: mongodb-enterprise
--> Processing Dependency: mongodb-enterprise-server = 2.6.3 for package: mongodb-enterprise
--> Processing Dependency: mongodb-enterprise-shell = 2.6.3 for package: mongodb-enterprise
--> Processing Dependency: mongodb-enterprise-tools = 2.6.3 for package: mongodb-enterprise
--> Running transaction check
---> Package mongodb-enterprise-mongos.x86_64 0:2.6.3-1.el5 set to be updated
---> Package mongodb-enterprise-server.x86_64 0:2.6.3-1.el5 set to be updated
--> Processing Dependency: net-snmp for package: mongodb-enterprise-server
--> Processing Dependency: cyrus-sasl-gssapi for package: mongodb-enterprise-server
--> Processing Dependency: libsensors.so.3()(64bit) for package: mongodb-enterprise-server
---> Package mongodb-enterprise-shell.x86_64 0:2.6.3-1.el5 set to be updated
---> Package mongodb-enterprise-tools.x86_64 0:2.6.3-1.el5 set to be updated
--> Running transaction check
---> Package cyrus-sasl-gssapi.x86_64 0:2.1.22-5.el5_4.3 set to be updated
---> Package lm_sensors.x86_64 0:2.10.7-9.el5 set to be updated
---> Package net-snmp.x86_64 1:5.3.2.2-14.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================
 Package Arch Version Repository Size
================================================================================================================================
Installing:
 mongodb-enterprise x86_64 2.6.3-1.el5 mongodb-enterprise-2.6 4.7 k
Installing for dependencies:
 cyrus-sasl-gssapi x86_64 2.1.22-5.el5_4.3 server 30 k
 lm_sensors x86_64 2.10.7-9.el5 server 525 k
 mongodb-enterprise-mongos x86_64 2.6.3-1.el5 mongodb-enterprise-2.6 7.0 M
 mongodb-enterprise-server x86_64 2.6.3-1.el5 mongodb-enterprise-2.6 9.2 M
 mongodb-enterprise-shell x86_64 2.6.3-1.el5 mongodb-enterprise-2.6 4.3 M
 mongodb-enterprise-tools x86_64 2.6.3-1.el5 mongodb-enterprise-2.6 90 M
 net-snmp x86_64 1:5.3.2.2-14.el5 server 705 k
Transaction Summary
================================================================================================================================
Install 8 Package(s)
Upgrade 0 Package(s)
Total size: 112 M
Total download size: 1.2 M
Is this ok [y/N]: Y
Downloading Packages:
(1/3): net-snmp-5.3.2.2-14.el5.x86_64.rpm | 705 kB 00:00
(2/3): cyrus-sasl-gssapi-2.1.22-5.el5_4.3.x86_64.rpm | 30 kB 00:00
(3/3): lm_sensors-2.10.7-9.el5.x86_64.rpm | 525 kB 00:00
--------------------------------------------------------------------------------------------------------------------------------
Total 7.8 MB/s | 1.2 MB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : cyrus-sasl-gssapi 1/8
  Installing : lm_sensors 2/8
  Installing : net-snmp 3/8
  Installing : mongodb-enterprise-server 4/8
  Installing : mongodb-enterprise-tools 5/8
  Installing : mongodb-enterprise-shell 6/8
  Installing : mongodb-enterprise-mongos 7/8
  Installing : mongodb-enterprise 8/8
duration: 652(ms)
Installed products updated.
Installed:
  mongodb-enterprise.x86_64 0:2.6.3-1.el5
Dependency Installed:
  cyrus-sasl-gssapi.x86_64 0:2.1.22-5.el5_4.3 lm_sensors.x86_64 0:2.10.7-9.el5
  mongodb-enterprise-mongos.x86_64 0:2.6.3-1.el5 mongodb-enterprise-server.x86_64 0:2.6.3-1.el5
  mongodb-enterprise-shell.x86_64 0:2.6.3-1.el5 mongodb-enterprise-tools.x86_64 0:2.6.3-1.el5
  net-snmp.x86_64 1:5.3.2.2-14.el5
Complete!

----  一般版本添加文件
You can specify any available version of MongoDB. However yum will upgrade the packages when a newer version
becomes available. To prevent unintended upgrades, pin the package. To pin a package, add the following exclude
directive to your /etc/yum.conf file:
exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools

-----企业版本添加文件
Pin a specific version of MongoDB Enterprise. Although you can specify any available version of MongoDB
Enterprise, yum will upgrade the packages when a newer version becomes available. To prevent unintended upgrades,
pin the package. To pin a package, add the following exclude directive to your /etc/yum.conf file:
exclude=mongodb-enterprise,mongodb-enterprise-server,mongodb-enterprise-shell,mongodb-enterprise-mong 

MONGODB 安装方式2:

=======#####
Install for 64-bit Linux
Step 1: Download the binary files for the desired release of MongoDB. Download the binaries from
https://www.mongodb.org/downloads.
For example, to download the latest release through the shell, issue the following:
curl -O http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.2.tgz   --直接下载source db
Step 2: Extract the files from the downloaded archive. For example, from a system shell, you can extract through
the tar command:
tar -zxvf mongodb-linux-x86_64-2.6.2.tgz
Step 3: Copy the extracted archive to the target directory. Copy the extracted folder to the location from which
MongoDB will run.
mkdir -p mongodb
cp -R -n mongodb-linux-x86_64-2.6.2/ mongodb
Step 4: Ensure the location of the binaries is in the PATH variable. The MongoDB binaries are in the bin/
directory of the archive. To ensure that the binaries are in your PATH, you can modify your PATH.
For example, you can add the following line to your shell’s rc file (e.g. ~/.bashrc):
export PATH=<mongodb-install-directory>:$PATH
Replace <mongodb-install-directory> with the path to the MongoDB binaries.
方式一 安装,启动连接mongodb 通过mongo

mongo
By default, mongo looks for a database server listening on port 27017 on the localhost interface. To connect to
a server on a different port or interface, use the --port and --host options.
1. From the mongo shell, confirm you are in the mydb database by issuing the following:
db

2. If mongo does not return mydb for the previous operation, set the context to the mydb database, with the
following operation:
use mydb

3. Create two documents named j and k by using the following sequence of JavaScript operations:
j = { name : "mongo" }
k = { x : 3 }

4. Insert the j and k documents into the testData collection with the following sequence of operations:
db.testData.insert( j )
db.testData.insert( k )
When you insert the first document, the mongod will create both the mydb database and the testData
collection.

5. Confirm that the testData collection exists. Issue the following operation:
show collections
The mongo shell will return the list of the collections in the current (i.e. mydb) database. At this point, the only
collection is testData. All mongod databases also have a system.indexes (page 251) collection.

6. Confirm that the documents exist in the testData collection by issuing a query on the collection using the
find() method:
db.testData.find()
This operation returns the following results. The ObjectId (page 148) values will be unique:
{ "_id" : ObjectId("4c2209f9f3924d31102bd84a"), "name" : "mongo" }
{ "_id" : ObjectId("4c2209fef3924d31102bd84b"), "x" : 3 }

----摘自官当,其他OS(windows,ubantu, suse等) 安装,请查看官当

作者:仗剑天涯'赢在江湖
来源链接:https://blog.csdn.net/lmocm/article/details/37878533

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。


本文链接:https://www.javaclub.cn/database/41671.html

标签: MongoDB
分享给朋友:

“Mongodb 两种 安装方式” 的相关文章

WebFlux 集成 Thymeleaf 、 Mongodb 实践,Spring Boot 2

WebFlux 集成 Thymeleaf 、 Mongodb 实践,Spring Boot 2

这是泥瓦匠的第105篇原创 文章工程: JDK 1.8 Maven 3.5.2 Spring Boot 2.1.3.RELEASE 工程名:springboot-webflux-5-thymeleaf-mong...

Spring Boot WebFlux 集成 Mongodb 数据源操作

Spring Boot WebFlux 集成 Mongodb 数据源操作

WebFlux 整合 Mongodb 前言 上一讲用 Map 数据结构内存式存储了数据。这样数据就不会持久化,本文我们用 MongoDB 来实现 WebFlux 对数据源的操作。 什么是 MongoDB ? 官网:https://...

UBUNTU下MONGODB出现PHP Fatal error: Uncaught exception 'MongoConnectionException' with message 和 Authentication failed on database 'admin' with username

MONGO 远程连接服务器,出现: PHP Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: 63.141.xx.xxx:270...

mongodb二进制安装与yum安装

一.什么是mongodb       MongoDB是一个高性能,开源,无模式的文档型数据库,是当前NoSql数据库中比较热门的一种。MongoDB 是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能 最丰富,最像关...

springboot给mongodb添加索引

最近项目中,需要用到mongodb,然后有一个定时任务每天都会新建表,但是数据量又很大,查询的时候很慢,因此需要在新建表的时候给表添加索引 //简易例子 String collectionName = "t_user"; Index index = new Index();...

mongodb与mysql命令对比

mongodb与mysql命令对比 传统的关系数据库一般由数据库(database)、表(table)、记录(record)三个层次概念组成,MongoDB是由数据库(database)、集合(collection)、文档对象(document)三个层次组成。MongoDB对于关...

MongoDB与Mysql常用命令解释

原文 本文旨在介绍MongoDB,Mysql的常用命令:将MongoDB 和传统的关系型数据库的常用命令对照起来学习,更加便于记忆和理解。 MongoDB是由数据库(database/repository)、集合(collection)、文档对象(documen...

JAVA单例MongoDB工具类

我经常对MongoDB进行一些基础操作,将这些常用操作合并到一个工具类中,方便自己开发使用。 没用Spring Data、Morphia等框架是为了减少学习、维护成本,另外自己直接JDBC方式的话可以更灵活,为自己以后的积累留一个脚印。   JAVA驱动版本...

MongodB数据库安装教程

MongodB数据库安装教程

MongodB数据库安装教程 1 官网下载msi安装文件 官网地址:[传送门](MongoDB Community Download | MongoDB) 阿里云盘:「mongodb-windows-x86_64-5.0.5-s...

Mongodb 安装

Mongodb 安装

ee@ubuntu:~$ curl http://downloads.mongodb.org/linux/mongodb-linux-i686-1.6.4.tgz > mongo.tgz % Total % Received % Xferd Average Sp...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。