MongoDB:修订间差异
来自康健生活
| 第19行: | 第19行: | ||
修改mongodb的配置文件 让其监听所有外网 IP。 | 修改mongodb的配置文件 让其监听所有外网 IP。 | ||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
vi /etc/mongodb.conf</syntaxhighlight>}} | vi /etc/mongodb.conf</syntaxhighlight>|#}} | ||
{{hcdiff|head=mongodb.conf|output=<syntaxhighlight lang="bash" highlight="5"> | {{hcdiff|head=mongodb.conf|output=<syntaxhighlight lang="bash" highlight="5"> | ||
| 第38行: | 第38行: | ||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
systemctl restart mongod.service</syntaxhighlight>}} | systemctl restart mongod.service</syntaxhighlight>|#}} | ||
== 参考 == | == 参考 == | ||
* https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/ | * https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/ | ||
2020年5月1日 (五) 03:16的版本
安装
Centos
添加 yum 源
vi /etc/yum.repos.d/mongodb-org-4.0.repo
mongodb-org-4.0.repo
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
yum install -y mongodb-org && systemctl start mongod
远程访问配置
修改mongodb的配置文件 让其监听所有外网 IP。
vi /etc/mongodb.conf
mongodb.conf
...
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
...
...
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
...
systemctl restart mongod.service
参考
No categories