不安装数据库的mongoimport
mongoimport without installing the database
是否有安装 mongo 导入工具但不安装所有 mongo 包的简单解决方案?
mongo导入工具将在机器 A 上使用,但数据将保存到机器 B。
目前,我有两台机器。他们都安装了 mongo。但是,机器 A 使用 mongoimport 并且连接指向机器 B。我希望能够使用机器 A 而无需安装 mongo 安装附带的所有其他软件包。
Ubuntu
在 Ubuntu 上,关注 documentation for installing MongoDB CE on Ubuntu
添加包签名密钥
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
向 apt 配置添加源文件
Ubuntu 12.04
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
Ubuntu 14.04
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
Ubuntu 16.04
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
重新加载本地包数据库
sudo apt-get update
安装 mongoldb-org-tools
包,其中包含 mongoimport
sudo apt-get install -y mongodb-org-tools
MacOS
安装 macports,如果您还没有的话。然后,做
sudo port selfupdate && sudo port install mongo-tools
注释
就我个人而言,我认为远程导入数据是一个非常糟糕的主意™。您的连接可能很容易成为瓶颈,并且根据您要导入的文档数量,这可能会严重限制性能。此外,远程连接更有可能中断几个数量级,这会使您留下部分导入的文件。
我宁愿在远程机器上使用 GNU screen,开始导入,暂停终端并等待导入完成:
$ screen
Screen version 4.00.03 (FAU) 23-Oct-06
Copyright (c) 1993-2002 Juergen Weigert, Michael Schroeder
Copyright (c) 1987 Oliver Laumann
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program (see the file COPYING); if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Send bugreports, fixes, enhancements, t-shirts, money, beer & pizza to
screen@uni-erlangen.de
[Press Space or Return to end.]
$ mongoimport <your opts here>
<ctrl+a,ctrl+d>
$ screen -r # to reattach the detached terminal session
这样,您可以在分离导入时安全地终止终端会话。
是否有安装 mongo 导入工具但不安装所有 mongo 包的简单解决方案?
mongo导入工具将在机器 A 上使用,但数据将保存到机器 B。
目前,我有两台机器。他们都安装了 mongo。但是,机器 A 使用 mongoimport 并且连接指向机器 B。我希望能够使用机器 A 而无需安装 mongo 安装附带的所有其他软件包。
Ubuntu
在 Ubuntu 上,关注 documentation for installing MongoDB CE on Ubuntu
添加包签名密钥
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
向 apt 配置添加源文件
Ubuntu 12.04
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
Ubuntu 14.04
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
Ubuntu 16.04
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
重新加载本地包数据库
sudo apt-get update
安装
mongoldb-org-tools
包,其中包含mongoimport
sudo apt-get install -y mongodb-org-tools
MacOS
安装 macports,如果您还没有的话。然后,做
sudo port selfupdate && sudo port install mongo-tools
注释
就我个人而言,我认为远程导入数据是一个非常糟糕的主意™。您的连接可能很容易成为瓶颈,并且根据您要导入的文档数量,这可能会严重限制性能。此外,远程连接更有可能中断几个数量级,这会使您留下部分导入的文件。
我宁愿在远程机器上使用 GNU screen,开始导入,暂停终端并等待导入完成:
$ screen
Screen version 4.00.03 (FAU) 23-Oct-06
Copyright (c) 1993-2002 Juergen Weigert, Michael Schroeder
Copyright (c) 1987 Oliver Laumann
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program (see the file COPYING); if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Send bugreports, fixes, enhancements, t-shirts, money, beer & pizza to
screen@uni-erlangen.de
[Press Space or Return to end.]
$ mongoimport <your opts here>
<ctrl+a,ctrl+d>
$ screen -r # to reattach the detached terminal session
这样,您可以在分离导入时安全地终止终端会话。