http://mayanze.com/(这里有我写的粗浅网站,欢迎留言)
参考官方按照文档:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
1.Configure the package management system (
yum
).Create a
/etc/yum.repos.d/mongodb-org-4.4.repo
file so that you can install MongoDB directly usingyum
:[mongodb-org-4.4] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
翻译:创建
/etc/yum.repos.d/mongodb-org-4.4.repo 文件
然后把下面代码复制进去,如截图
2.Install the MongoDB packages.
To install the latest stable version of MongoDB, issue the following command:
sudo yum install -y mongodb-org
翻译:就是执行 sudo yum install -y mongodb-org 这个命令会安装最新的稳定版本
By default, MongoDB runs using the
mongod
user account and uses the following default directories:
/var/lib/mongo
(the data directory)/var/log/mongodb
(the log directory)默认数据目录和日志目录就是这两个;
配置文件在:
/etc/mongod.conf
启动
sudo systemctl start mongod
查看状态
sudo systemctl status mongod
停掉
sudo systemctl stop mongod
重启
sudo systemctl restart mongod
配置远程连接, vi /etc/mongod.conf
注意看默认配置后面一段注释:
# Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
翻译:输入 0.0.0.0,:: 绑定到所有IPv4和IPv6地址,或者使用net.bindIpAll设置。
然后重新启动
systemctl restart mongod