E:无法找到包mongodb-org

时间:2015-03-09 15:35:56

标签: node.js mongodb installation

我正在尝试下载mongodb,我正在按照link的步骤进行操作。

但是当我走到这一步时:

sudo apt-get install -y mongodb-org

我收到以下错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package mongodb-org  //This is the error

为什么会发生这种情况并且有解决方法?

13 个答案:

答案 0 :(得分:184)

我遇到了同样的问题但是通过更改包文件部分命令来修复它。我遵循的整个步骤是:

首先尝试使用此命令:     sudo apt-get install -y mongodb

这是由Ubuntu提供的非官方mongodb软件包,它不是由MongoDB维护的,而是与MongoDB的官方支持软件包冲突。

如果上述命令不起作用,那么您可以通过以下方法之一解决问题:

#Step 1:  Import the MongoDB public key
#In Ubuntu 18.*+, you may get invalid signatures. --recv value may need to be updated to EA312927. 
#See here for more details on the invalid signature issue: [https://stackoverflow.com/questions/34733340/mongodb-gpg-invalid-signatures][1]

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

#Step 2: Generate a file with the MongoDB repository url
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list

#Step 3: Refresh the local database with the packages
sudo apt-get update

#Step 4: Install the last stable MongoDB version and all the necessary packages on our system
sudo apt-get install mongodb-org

         #Or
# The unofficial mongodb package provided by Ubuntu is not maintained by MongoDB and conflict with MongoDB’s offically supported packages. Use the official MongoDB mongodb-org packages, which are kept up-to-date with the most recent major and minor MongoDB releases.
sudo apt-get install -y mongodb 

希望这对你也有用。您可以按照MongoDB

进行操作

<强>更新    上面的说明将安装mongodb 2.6版本,如果你想为Uubuntu 12.04安装最新版本,那么只需替换上面step 2并遵循以下指令而不是:

#Step 2: Generate a file with the MongoDB repository url
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list

如果您使用的是Ubuntu 14.04,请使用以下步骤而不是step 2

#Step 2: Generate a file with the MongoDB repository url
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

答案 1 :(得分:49)

这里的真正问题可能是你有一个 32位系统。 MongoDB 3.X从未被用于32位系统,因此32位的存储区为空(因此找不到它的原因)。安装默认的2.X Ubuntu软件包可能是您最好的选择:

sudo apt-get install -y mongodb 


另一种解决方法,如果你想获得最新版本的Mongo:

你可以去 https://www.mongodb.org/downloads 并使用下拉列表选择“Linux 32位旧版”

但它伴随着严重的limitations ......

  

此32位旧版发行版不包含SSL加密   限制在2GB左右的数据。通常,您应该使用64位   建立。有关详细信息,请参阅here

答案 2 :(得分:36)

尝试不使用&#39; -org&#39;:

  

sudo apt-get install -y mongodb

为我工作!

答案 3 :(得分:7)

我正在运行Ubuntu 14.04;并且仍然无法找到包裹;我尝试了上面的所有答案以及更多。 适合我的网址是:

echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list

来源:http://www.liquidweb.com/kb/how-to-install-mongodb-on-ubuntu-14-04/

答案 4 :(得分:5)

所有步骤都正确,只需更改步骤4,如下所示

  • 步骤4:在我们的系统上安装最后一个稳定的MongoDB版本和所有必需的软件包

命令:sudo apt-get install mongodb

它对我有用。

答案 5 :(得分:4)

如果您当前正在使用 MongoDB 3.3存储库 (正如MongoDB网站正式建议的那样),您应该考虑到用于版本3.3的软件包名称是:

  

的mongodb-ORG-不稳定

然后,此版本的正确安装命令为:

sudo apt-get install -y mongodb-org-unstable

考虑到这一点,我建议使用当前最新的稳定版本(v3.2),直到v3.3变得稳定,安装它的命令如下所示:

下载v3.2存储库密钥:

wget -qO - https://www.mongodb.org/static/pgp/server-3.2.asc | sudo apt-key add -

如果您使用 Ubuntu 12.04 Mint 13 ,请添加以下存储库:

echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

如果您使用 Ubuntu 14.04 Mint 17 ,请添加以下存储库:

echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

如果您使用 Ubuntu 16.04 Mint 18 ,请添加以下存储库:

echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

更新软件包列表并安装mongo:

sudo apt-get update
sudo apt-get install -y mongodb-org

答案 6 :(得分:2)

目前接受的答案有效,但会安装一个过时的Mongo版本。

Mongo文档指出:MongoDB仅为Ubuntu 12.04 LTS(精确穿山甲)和14.04 LTS(Trusty Tahr)提供包。但是,这些软件包可能适用于其他Ubuntu版本。

因此,要获得最新的稳定Mongo(3.0),请使用此(不同的步骤是第二步):

    apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
    echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list
    apt-get update
    apt-get install mongodb-org

希望这有帮助。


我想补充一点,作为上一步,您必须检查您的GNU / Linux发行版,它将构建Repo列表网址。对我来说,正如我使用它:

DISTRIB_CODENAME=rafaela
DISTRIB_DESCRIPTION="Linux Mint 17.2 Rafaela"
NAME="Ubuntu"
VERSION="14.04.2 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.2 LTS"

最初的第二步:

"Create a list file for 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"

无法正常工作,因为它生成了错误的Repo网址。基本上,它将分发代号“rafaela”放在不存在的url repo中。您可以在软件源,附加存储库下查看软件包管理器上的Repo URL。

我所做的是浏览网站:

http://repo.mongodb.org/apt/ubuntu/dists/

我发现对于Ubuntu来说,“可靠”和“精确”是唯一可用的网络文件夹,而不是“rafaela”。

解决方案:以root身份打开文件'mongodb-org-3.1.list'或'mongodb.list'并替换相应版本的“rafaela”或您的发布版本(对我而言) :“可靠”),保存更改并继续执行后续步骤。此外,您的包管理器也可以让您轻松更改回购URL。

希望它适合你。 ---

答案 7 :(得分:1)

首先需要添加包数据库并添加PGP密钥。

运行以下命令。

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

#add package file
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

#update package list
sudo apt-get update

#install mongo
sudo apt-get install -y mongodb-org

答案 8 :(得分:1)

我在14.04遇到了同样的问题,但我通过以下步骤解决了这个问题:

  1. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
  2. echo&#34; deb http://repo.mongodb.org/apt/ubuntu&#34; $(lsb_release -sc)&#34; / mongodb-org / 3.0 multiverse&#34; | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
  3. sudo apt-get update
  4. sudo apt-get install -y mongodb
  5. 它就像魅力一样:)

答案 9 :(得分:1)

sudo apt-get install -y mongodb 

它适用于32位ubuntu,试试吧。祝你好运。

答案 10 :(得分:0)

这适用于Ubuntu 17.04

    public function entityToArray($entity, &$aClassNamesDone=array(), $latestClassName="") {

    $result = array();

    if(is_null($entity)) {
        return $result;
    }

    $className = get_class($entity);

    // init with calling entity
    if(empty($aClassNamesDone)) {
        $aClassNamesDone[] =$className;
    }

    $uow = $this->getEntityManager()->getUnitOfWork();

    $entityPersister = $uow->getEntityPersister($className);
    $classMetadata = $entityPersister->getClassMetadata();

    //DEPENDS ON DOCTRINE VERSION
    //if(strstr($className, 'DoctrineProxies\\__CG__\\')){
    if(strstr($className, 'Proxies\\__CG__\\')){
        $uow->initializeObject($entity);
    }

    foreach ($uow->getOriginalEntityData($entity) as $field => $value) {

        if (isset($classMetadata->associationMappings[$field])) {

            $assoc = $classMetadata->associationMappings[$field];

            if (isset($classMetadata->columnNames[$field])) {
                $columnName = $classMetadata->columnNames[$field];
                $result[$columnName] = $value;
            }

            // to avoid recursivity we can look for the owning side (gives similar results as Query::HYDRATE_ARRAY):
            // elseif($assoc['isOwningSide']) { ...
            // or we can track entities explored and avoid any duplicates (this will however ignore some fields pointing to the same entity class)
            // for example: only one of createdBy, updatedBy will be kept

            else if(!in_array($assoc['targetEntity'], $aClassNamesDone) || $assoc['targetEntity'] == $latestClassName) {

                try {

                    if ($assoc['targetEntity'] != 'Timestamp') {

                        $aClassNamesDone[] = $assoc['targetEntity'];

                        $targetClass = $this->getEntityManager()->getClassMetadata($assoc['targetEntity']);

                        if (($assoc['type'] == \Doctrine\ORM\Mapping\ClassMetadata::MANY_TO_MANY) || ($assoc['type'] == \Doctrine\ORM\Mapping\ClassMetadata::ONE_TO_MANY)) {

                            $getterName = 'get' . ucfirst($assoc['fieldName']);
                            $entityChildren = $entity->$getterName();
                            foreach ($entityChildren as $oneChild) {
                                $result[$assoc['fieldName']][] = $this->getEntityManager()->getRepository($assoc['targetEntity'])->entityToArray($oneChild, $aClassNamesDone, $assoc['targetEntity']);
                            }

                        } else if (($assoc['type'] == \Doctrine\ORM\Mapping\ClassMetadata::ONE_TO_ONE) || ($assoc['type'] == \Doctrine\ORM\Mapping\ClassMetadata::MANY_TO_ONE)) {

                            $getterName = 'get' . ucfirst($assoc['fieldName']);
                            $entityChild = $entity->$getterName();
                            $result[$assoc['fieldName']] = $this->getEntityManager()->getRepository($assoc['targetEntity'])->entityToArray($entityChild, $aClassNamesDone, $assoc['targetEntity']);

                        }
                    }

                } catch (\Exception $e) {
                    //var_dump('No entityToArray for ' . $assoc['targetEntity']);
                    throw ($e);
                }
            }

        }
    }

    return $result;
}

如果您发现失败,请执行以下操作:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

sudo apt-get update

sudo apt-get install -y mongodb-org

然后运行此命令:

dpkg: error processing archive /var/cache/apt/archives/mongodb-org-tools_3.6.2_amd64.deb (--unpack):
trying to overwrite '/usr/bin/bsondump', which is also in package mongo-tools 3.2.11-1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)

sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" |

参考文献:

答案 11 :(得分:0)

当我按照official document上发布的步骤进行操作时,在Ubuntu 16.04上遇到了相同的问题。
然后,我在步骤2中删除文本“ [arch = amd64,arm64]” ,它对我有用。

echo "deb https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list   
apt-get install -y mongodb-org  

答案 12 :(得分:0)

对于使用Ubuntu 18.04的用户可以运行以下命令:

Ubuntu 18.04(仿生)创建/etc/apt/sources.list.d/mongodb-org-4.2.list文件:

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list