仅安装 mongo shell,不安装 mongodb
Install ONLY mongo shell, not mongodb
如上所述,我只需要在 RHEL 实例(机器 A)上安装 mongo shell。
我在单独的实例(机器 B)上有一个 mongodb 服务器,需要从 A 连接到 运行 mongodump
和 mongorestore
命令。
我试着在网上查找它,但我得到的只是安装完整 mongodb 包的说明。
感谢任何帮助。
您可以按照 official tutorial 安装 mongodb
,而不是安装将安装所有软件包的主软件包,只安装包含 mongoshell 的软件包
Official documentation 说你应该只安装 mongodb-org-shell
就好了。
请按照以下步骤操作。
创建文件/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
sudo yum install -y mongodb-org-shell-2.6.9
mongo mongo-db_server_IP:27017/database_name -u username -p password
- 在
sudo vim /etc/yum.repos.d/mongodb.repo
创建存储库文件
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
gpgcheck=1
enabled=1
sudo yum clean all
sudo yum install mongodb-org-shell-4.0.2
mongo <mongo-server-ip>
注意:第 4 步并非在所有情况下都有效。您需要检查正确的命令以连接到远程 mongo 服务器。
来源:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
前往Mongo download页面;下载与您的操作系统相关的所需软件包。最后按照您的操作系统的说明安装软件包。
特别是安装 mongo
或 mongosh
:
- 下载
.tgz
文件并将文件解压到 /usr/local/
- 将
/usr/local/mongo/
添加到 shell 配置文件(例如 ~/.bashrc
)并重新启动您的终端
有关详细信息,请阅读 docs。
P.S.: 路径中的mongo
要根据下载包的版本有所不同。
您可能想要 install mongosh
(MongoDB Shell) instead. The legacy mongo
shell has been deprecated since MongoDB v5.0 and replaced by mongosh
. From the mongosh docs:
The new MongoDB Shell, mongosh
, offers numerous advantages over the
legacy mongo shell, such as:
- Improved syntax highlighting.
- Improved command history.
- Improved logging.
Currently mongosh supports a subset of the mongo shell
methods. Achieving feature parity between mongosh and the mongo shell
is an ongoing effort.
To maintain backwards compatibility, the methods that mongosh supports
use the same syntax as the corresponding methods in the mongo shell.
To see the complete list of methods supported by mongosh, see MongoDB
Shell Methods.
如上所述,我只需要在 RHEL 实例(机器 A)上安装 mongo shell。
我在单独的实例(机器 B)上有一个 mongodb 服务器,需要从 A 连接到 运行 mongodump
和 mongorestore
命令。
我试着在网上查找它,但我得到的只是安装完整 mongodb 包的说明。
感谢任何帮助。
您可以按照 official tutorial 安装 mongodb
,而不是安装将安装所有软件包的主软件包,只安装包含 mongoshell 的软件包
Official documentation 说你应该只安装 mongodb-org-shell
就好了。
请按照以下步骤操作。
创建文件/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
sudo yum install -y mongodb-org-shell-2.6.9
mongo mongo-db_server_IP:27017/database_name -u username -p password
- 在
sudo vim /etc/yum.repos.d/mongodb.repo
创建存储库文件
[mongodb-org-4.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/ gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc gpgcheck=1 enabled=1
sudo yum clean all
sudo yum install mongodb-org-shell-4.0.2
mongo <mongo-server-ip>
注意:第 4 步并非在所有情况下都有效。您需要检查正确的命令以连接到远程 mongo 服务器。
来源:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
前往Mongo download页面;下载与您的操作系统相关的所需软件包。最后按照您的操作系统的说明安装软件包。
特别是安装 mongo
或 mongosh
:
- 下载
.tgz
文件并将文件解压到/usr/local/
- 将
/usr/local/mongo/
添加到 shell 配置文件(例如~/.bashrc
)并重新启动您的终端
有关详细信息,请阅读 docs。
P.S.: 路径中的mongo
要根据下载包的版本有所不同。
您可能想要 install mongosh
(MongoDB Shell) instead. The legacy mongo
shell has been deprecated since MongoDB v5.0 and replaced by mongosh
. From the mongosh docs:
The new MongoDB Shell,
mongosh
, offers numerous advantages over the legacy mongo shell, such as:
- Improved syntax highlighting.
- Improved command history.
- Improved logging.
Currently mongosh supports a subset of the mongo shell methods. Achieving feature parity between mongosh and the mongo shell is an ongoing effort.
To maintain backwards compatibility, the methods that mongosh supports use the same syntax as the corresponding methods in the mongo shell. To see the complete list of methods supported by mongosh, see MongoDB Shell Methods.