简体   繁体   English

如何在Ubuntu 14.04中安装MongoDB 3.2.3?

[英]How to install MongoDB 3.2.3 in Ubuntu 14.04?

I am new to mongodb, cant understand how i can install MongoDB 3.2.3 in Ubuntu 14.04. 我是mongodb的新手,无法理解如何在Ubuntu 14.04中安装MongoDB 3.2.3。

Also i have downloaded https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.2.3.tgz and extracted files from that directory, now how i can add it with php? 我也已经下载了https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.2.3.tgz并从该目录中提取了文件, 现在如何用php添加它?

when i go to the bin directory and run mongod then this error occurs: 当我转到bin目录并运行mongod时,会发生此错误:

vagrant@vagrant-ubuntu-trusty-64:/vagrant/mongodb/mongodb/bin$ ./mongod vagrant @ vagrant-ubuntu-trusty-64:/ vagrant / mongodb / mongodb / bin $ ./mongod

2016-02-23T16:59:47.366+0000 I CONTROL [initandlisten] MongoDB starting : pid=8246 port=27017 dbpath=/data/db 64-bit host=vagrant-ubuntu-trusty-64 2016-02-23T16:59:47.366 + 0000 I CONTROL [initandlisten] MongoDB开始:pid = 8246端口= 27017 dbpath = / data / db 64位主机= vagrant-ubuntu-trusty-64

2016-02-23T16:59:47.366+0000 I CONTROL [initandlisten] db version v3.2.3 2016-02-23T16:59:47.366 + 0000 I CONTROL [initandlisten]数据库版本v3.2.3

2016-02-23T16:59:47.367+0000 I CONTROL [initandlisten] git version: b326ba835e1b70f6f31ece7937 2016-02-23T16:59:47.367 + 0000 I CONTROL [initandlisten] git版本:b326ba835e1b70f6f31ece7937

2016-02-23T16:59:47.367+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014 2016-02-23T16:59:47.367 + 0000 I CONTROL [initandlisten] OpenSSL版本:OpenSSL 1.0.1f 2014年1月6日

2016-02-23T16:59:47.367+0000 I CONTROL [initandlisten] allocator: tcmalloc 2016-02-23T16:59:47.367 + 0000 I CONTROL [initandlisten]分配器:tcmalloc

2016-02-23T16:59:47.367+0000 I CONTROL [initandlisten] modules: none 2016-02-23T16:59:47.367 + 0000 I CONTROL [initandlisten]模块:无

2016-02-23T16:59:47.367+0000 I CONTROL [initandlisten] build environment: 2016-02-23T16:59:47.367 + 0000 I CONTROL [initandlisten]构建环境:

2016-02-23T16:59:47.367+0000 I CONTROL [initandlisten] distmod: ubuntu1404 2016-02-23T16:59:47.367 + 0000 I CONTROL [initandlisten] distmod:ubuntu1404

2016-02-23T16:59:47.368+0000 I CONTROL [initandlisten] distarch: x86_64 2016-02-23T16:59:47.368 + 0000 I CONTROL [initandlisten] distarch:x86_64

2016-02-23T16:59:47.368+0000 I CONTROL [initandlisten] target_arch: x86_64 2016-02-23T16:59:47.368 + 0000 I CONTROL [initandlisten] target_arch:x86_64

2016-02-23T16:59:47.368+0000 I CONTROL [initandlisten] options: {} 2016-02-23T16:59:47.368 + 0000 I CONTROL [initandlisten]选项:{}

2016-02-23T16:59:47.384+0000 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb- 27017.sock errno:1 Operation not permitted 2016-02-23T16:59:47.384 + 0000 E NETWORK [initandlisten]无法解除套接字文件/ tmp / mongodb- 27017.sock errno的链接:1不允许操作

2016-02-23T16:59:47.384+0000 I - [initandlisten] Fatal Assertion 28578 2016-02-23T16:59:47.384 + 0000 I-[initandlisten]致命断言28578

2016-02-23T16:59:47.385+0000 I - [initandlisten] 2016-02-23T16:59:47.385 + 0000 I-[initandlisten]

***aborting after fassert() failure *** fassert()失败后中止

we first have to import they key for the official MongoDB repository. 我们首先必须将它们导入官方MongoDB存储库的密钥。

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

After successfully importing the key you will see: 成功导入密钥后,您将看到:

gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

Next, we have to add the MongoDB repository details so APT will know where to download the packages from. 接下来,我们必须添加MongoDB存储库详细信息,以便APT知道从何处下载软件包。

Issue the following command to create a list file for MongoDB. 发出以下命令为MongoDB创建列表文件。

echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

After adding the repository details, we need to update the packages list. 添加存储库详细信息后,我们需要更新软件包列表。

sudo apt-get update

Now we can install the MongoDB package itself. 现在,我们可以安装MongoDB软件包本身。

sudo apt-get install -y mongodb-org

After package installation MongoDB will be automatically started. 软件包安装后,MongoDB将自动启动。 You can check this by running the following command. 您可以通过运行以下命令进行检查。

service mongod status

If MongoDB is running, you'll see an output like this (with a different process ID). 如果MongoDB正在运行,您将看到类似这样的输出(具有不同的进程ID)。

mongod start/running, process 1611

You can also stop, start, and restart MongoDB using the service commands. 您还可以使用服务命令停止,启动和重新启动MongoDB。 To stop MongoDB use 停止使用MongoDB

service mongod stop

To start MongoDB use 开始使用MongoDB

service mongod start

It can be done more easily using MongoDB apt repository: Run this commands on the terminal: 使用MongoDB apt存储库可以更轻松地完成此操作:在终端上运行以下命令:

  1. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 须藤apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
  2. echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.2 main" | 回声“ deb http://repo.mongodb.org/apt/debian wheezy / mongodb-org / 3.2 main” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
  3. sudo apt-get update sudo apt-get更新
  4. sudo apt-get install -y mongodb-org=3.2.3 mongodb-org-server=3.2.3 mongodb-org-shell=3.2.3 mongodb-org-mongos=3.2.3 mongodb-org-tools=3.2.3 sudo apt-get install -y mongodb-org = 3.2.3 mongodb-org-server = 3.2.3 mongodb-org-shell = 3.2.3 mongodb-org-mongos = 3.2.3 mongodb-org-tools = 3.2.3

**** in your home create folder ****在您的家庭创建文件夹中

mkdir mongodb mkdir mongodb

cd mongodb cd mongodb

curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.3.tgz curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.3.tgz

tar -xvzf mongodb-linux-x86_64-3.2.3.tgz tar -xvzf mongodb-linux-x86_64-3.2.3.tgz

cd /opt cd / opt

sudo mkdir mongodb 须藤mkdir mongodb

cd mongodb/ cd mongodb /

sudo cp -R ~/mongodb/mongodb-linux-x86_64-3.2.3/* . sudo cp -R〜/ mongodb / mongodb-linux-x86_64-3.2.3 / *。

*****dot (.) for current folder *****点(。)用于当前文件夹

cd /var/lib cd / var / lib

sudo mkdir mongodb 须藤mkdir mongodb

****now try mongodb by running mongod in opt/mongodb/bin folder ****现在通过在opt / mongodb / bin文件夹中运行mongod来尝试mongodb

cd /opt/mongodb/bin cd / opt / mongodb / bin

sudo ./mongod --dbpath /var/lib/mongodb 须藤./mongod --dbpath / var / lib / mongodb

Alternatively, instead of cluttering the OS and dealing with file(dependency) management manually, try using the docker container. 另外,也可以尝试使用docker容器,而不是使操作系统混乱并手动处理文件(依赖项)管理。

  1. Install docker 安装泊坞窗

  2. Start a container, listening on the default port, 27017, directly: 启动一个容器,直接在默认端口27017上侦听:
    docker run --net=host --name some-mongo -d mongo

  3. You can pass all the regular mongod command line parameters after -d mongo as well as the version, ie: 您可以在-d mongo以及版本之后传递所有常规mongod命令行参数,即:

    docker run --net=host --name some-mongo -d mongo --storageEngine wiredTiger --smallfiles --auth ...

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

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