Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 无法从计算引擎访问BigQuery_Google Cloud Platform_Google Bigquery_Google Compute Engine - Fatal编程技术网

Google cloud platform 无法从计算引擎访问BigQuery

Google cloud platform 无法从计算引擎访问BigQuery,google-cloud-platform,google-bigquery,google-compute-engine,Google Cloud Platform,Google Bigquery,Google Compute Engine,我已经通过GCP上的计算引擎设置了一个标准的DebianLinuxVM。虚拟机没有外部IP地址。我可以使用浏览器通过ssh连接到它。我允许输入ssh(端口22)流量和所有输出流量。我通过浏览器界面执行查询来测试BigQuery,它可以工作。我已经通过设置->云API访问范围为VM配置了BigQuery。现在我想做一件简单的事情如下: bq show bigquery-public-data:samples.shakespeare I0106 15:29:47.271125 1402586879

我已经通过GCP上的计算引擎设置了一个标准的DebianLinuxVM。虚拟机没有外部IP地址。我可以使用浏览器通过ssh连接到它。我允许输入ssh(端口22)流量和所有输出流量。我通过浏览器界面执行查询来测试BigQuery,它可以工作。我已经通过设置->云API访问范围为VM配置了BigQuery。现在我想做一件简单的事情如下:

bq show bigquery-public-data:samples.shakespeare
I0106 15:29:47.271125 140258687915840 bigquery_client.py:1205] Requesting discovery document from https://www.googleapis.com/discovery/v1/apis/bigquery/v2/rest
I0106 15:29:47.271456 140258687915840 transport.py:158] Attempting refresh to obtain initial access_token
但什么也没发生。我尝试执行以下操作以获取更多信息:

bq --apilog=stdout show bigquery-public-data:samples.shakespeare
输出如下:

bq show bigquery-public-data:samples.shakespeare
I0106 15:29:47.271125 140258687915840 bigquery_client.py:1205] Requesting discovery document from https://www.googleapis.com/discovery/v1/apis/bigquery/v2/rest
I0106 15:29:47.271456 140258687915840 transport.py:158] Attempting refresh to obtain initial access_token
没有更多的事情发生。你知道这是什么问题吗


在阅读了文档之后,我觉得通过BigQuery命令行工具的连接应该可以自己工作。

首先,为什么它不能工作。事实上,当您使用bq CLI时,它只是一个调用BigQuery API的包装器:
https://bigquery.googleapis.com
。域名是公共的。计算机引擎试图在公共互联网上解决这个问题。但计算引擎没有公共IP,无法在internet上运行(internet服务器不知道如何路由回答案,因为无法访问VM!)

那么,如何解决。2种解决方案:

  • 您可以在计算引擎上设置一个,从而授予它一个可共享的公共IP,仅用于启动传出流量
  • 您可以使用一个不为人所知的技巧:激活子网中的Google私有API访问。为此,请注意计算引擎的子网。然后转到VPC并选择此子网。编辑它并设置为在私有谷歌访问

谢谢!第二个解决方案非常完美,因为我们不打算访问任何internet,因为vm应该只与BigQuery工作/交互。