Mongodb 两种 安装方式

环境: 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等) 安装,请查看官当

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值