- Google Cloud Platform Cookbook
- Legorie Rajan PS
- 270字
- 2021-08-27 19:13:24
Getting ready
The following are the initial setup verification steps to be taken before the recipe can be executed:
- Create or select a GCP project.
- Enable billing and enable the default APIs (some APIs such as BigQuery, storage, monitoring, and a few others are enabled automatically).
- Verify that Google Cloud SDK is installed on your development machine.
- Verify that the default project is set properly:
$ gcloud config list
- The VM which runs MongoDB from our first recipe allows connections only from the localhost. We'll have to modify the configuration to allow connections from the external world.
- SSH into the VM from the Console:

- Navigate to the MongoDB's configuration file, /etc/mongod.conf, and update the bindIp value to include 0.0.0.0:
# network interfaces net: port: 27017 bindIp: [127.0.0.1,0.0.0.0]
In a few versions of Mongo, it is just enough to comment our the bind_ip line in the mongodb config to allow access from outside the instance.
- Reboot the machine and verify that the MongoDB service is up and running.
- We'll also create a new firewall rule to allow access to port 27017 from anywhere:
$ gcloud compute firewall-rules \
create default-allow-mongo-27017 \ --allow tcp:27017 \ --source-ranges 0.0.0.0/0 \ --target-tags mysite-server \ --description "Allow port 27017 access to mysite-server"
The following screenshot shows the details of the firewall rule:

The MongoDB instance is now open to the world without any login credentials. So for production systems, make sure you secure the MongoDB instance with an admin user and run the mongod process using the --auth option.
- Connect to the MongoDB instance running on the VM from your development machine:
$ mongo mongodb://<External IP>:27017
推薦閱讀
- Effective DevOps with AWS
- 四向穿梭式自動(dòng)化密集倉儲(chǔ)系統(tǒng)的設(shè)計(jì)與控制
- 運(yùn)動(dòng)控制器與交流伺服系統(tǒng)的調(diào)試和應(yīng)用
- 在實(shí)戰(zhàn)中成長(zhǎng):Windows Forms開發(fā)之路
- 機(jī)器人人工智能
- 數(shù)據(jù)要素:全球經(jīng)濟(jì)社會(huì)發(fā)展的新動(dòng)力
- 傳感器原理及實(shí)用技術(shù)
- 樂高創(chuàng)意機(jī)器人教程(中級(jí) 上冊(cè) 10~16歲) (青少年iCAN+創(chuàng)新創(chuàng)意實(shí)踐指導(dǎo)叢書)
- Eclipse RCP應(yīng)用系統(tǒng)開發(fā)方法與實(shí)戰(zhàn)
- 大數(shù)據(jù):從基礎(chǔ)理論到最佳實(shí)踐
- 牛津通識(shí)讀本:大數(shù)據(jù)(中文版)
- 實(shí)戰(zhàn)突擊
- PVCBOT零基礎(chǔ)機(jī)器人制作(第2版)
- 暗戰(zhàn)強(qiáng)人:黑客攻防入門全程圖解
- Microsoft Power BI Complete Reference