简体   繁体   English

如何在 linux 上安装 mongodb 二进制包

[英]how to install mongodb binary package on linux

I'm trying to install mongodb binary package by following the steps at http://docs.mongodb.org/manual/tutorial/install-mongodb-on-linux/ I'm on debian linux(Ubuntu 12.04) when I try to launch mongod, I get the message我正在尝试按照http://docs.mongodb.org/manual/tutorial/install-mongodb-on-linux/ 中的步骤安装 mongodb 二进制包我在 debian linux(Ubuntu 12.04)上尝试启动 mongod,我收到消息

bash: /usr/local/bin/mongod: cannot execute binary file

the ldd from /usr/local/bin/mongod reads not a dynamic executable来自 /usr/local/bin/mongod 的 ldd 读取的not a dynamic executable

Installing mongodb binary package on linux takes only a few minutes.在 linux 上安装 mongodb 二进制包只需要几分钟。 I would like to include installation of mongodb binary steps in shorter here:我想在此处包含更短的 mongodb 二进制步骤的安装:

Step 1 : Download the latest .tar.gz file from here ,always prefer 64 bit for production.第 1 步:从这里下载最新的 .tar.gz 文件,始终首选 64 位进行生产。

Step 2 : Make a source directory(/usr/local) and now extract the downloaded file using the below command:第 2 步:创建一个源目录(/usr/local),然后使用以下命令提取下载的文件:

 tar zxf mongodb-linux-i686-1.6.0.tar.gz 

Step 3 : Create a data directory using the below command第 3 步:使用以下命令创建数据目录

mkdir -p /data/db

Step 4 : Create an user mongo_user using the following command第 4 步:使用以下命令创建用户 mongo_user

useradd mongo_user

Step 5 : Change the ownership of the files in the source and data directory using the following command第 5 步:使用以下命令更改源和数据目录中文件的所有权

chown -R mongo_user.mongo_user /usr/local/

chown -R mongo_user.mongo_user /data/db/

Step 6 : Create a configuration file in any directory say vim /etc/mongod.conf第 6 步:在任何目录中创建一个配置文件,比如vim /etc/mongod.conf

Now add the following details as shown below:现在添加以下详细信息,如下所示:

verbose = true
dbpath = /data/db
logpath = /var/log/mongodb.log
logappend = true
port = 27017

Step 7 : Move to the bin folder in the source directory and now start the mongo server by the following command步骤7 :移动到源目录中的bin文件夹,现在通过以下命令启动mongo服务器

./mongod --config /etc/mongod.conf

Step 8 : Within the bin folder in source directory start the mongo client by the following command步骤 8 :在源目录的 bin 文件夹中,通过以下命令启动 mongo 客户端

./mongo --port 27017

The mongodb prompt appears !!! mongodb 提示出现!!!

PS : This is partially adapted from my blog. PS :这部分改编自我的博客。 For a clearer explanation see the original article .有关更清晰的解释,请参阅原始文章

This should get you up and running quickly:这应该可以让您快速启动并运行:

Install (/home/username/)安装(/home/用户名/)

sudo wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.7.tgz?_ga=1.57038442.1512045927.1417277541

sudo tar -zxvf mongodb-linux-x86_64-2.6.7.tgz?_ga=1.57038442.1512045927.1417277541

sudo mv mongodb-linux-x86_64-2.6.7 mongo-2.6.7

Create database directory (/home/username/mongo-2.6.7)创建数据库目录(/home/username/mongo-2.6.7)

sudo mkdir databases 

Start mongo启动mongo

mongod --dbpath /home/username/mongo-2.6.7/databases

Enter shell (/home/username/mongo-2.6.7/bin)进入shell (/home/username/mongo-2.6.7/bin)

./mongo 

You can set-up more in-depth configurations after you've played with it a bit.稍微玩玩之后,您可以设置更深入的配置。

It is caused by running 64-bit application on 32-bit system or vice versa.它是由在 32 位系统上运行 64 位应用程序引起的,反之亦然。

Double checkin and aligning your Linux OS version and the Mongodb version will solve this issue.仔细检查并调整您的 Linux 操作系统版本和 Mongodb 版本将解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM