当前位置: 首页 > 工具软件 > Reachability > 使用案例 >

Google Cloud SDK配置 解决ERROR: Reachability Check failed问题

麹渊
2023-12-01

安装google cloud sdk的时候第一次需要初始化,而初始化的时候因为一些原因,
会报错:

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.                                                                                                                                                                               
ERROR: Reachability Check failed.
    Cannot reach https://www.google.com (ServerNotFoundError)
    Cannot reach https://accounts.google.com (ServerNotFoundError)
    Cannot reach https://cloudresourcemanager.googleapis.com/v1beta1/projects (ServerNotFoundError)
    Cannot reach https://www.googleapis.com/auth/cloud-platform (ServerNotFoundError)
    Cannot reach https://dl.google.com/dl/cloudsdk/channels/rapid/components-2.json (ServerNotFoundError)
Network connection problems may be due to proxy or firewall settings.
。

或者下面卡很久

Network diagnostic detects and fixes local network connection issues.
Checking network connection...

自己的电脑直接科学上网也不行,谷歌文档中是这么说的:
如果您位于公司代理或防火墙后面,gcloud 命令行工具可能无法使用默认设置访问互联网。

以下是正确配置google cloud sdk的方法,首先自己的电脑能够科学上网,其次通过以下三行配置sdk的proxy

config set proxy/type socks5
config set proxy/address 127.0.0.1
gcloud config set proxy/port 1080

以下是全部命令与流程

Welcome to the Google Cloud SDK! Run "gcloud -h" to get the list of available commands.
---

D:\Programming\Tools\cloud\google_cloud\cloud_sdk>gcloud config set proxy/type socks5
Updated property [proxy/type].

D:\Programming\Tools\cloud\google_cloud\cloud_sdk>gcloud config set proxy/address 127.0.0.1
Updated property [proxy/address].

D:\Programming\Tools\cloud\google_cloud\cloud_sdk>gcloud config set proxy/port 1080
Updated property [proxy/port].

D:\Programming\Tools\cloud\google_cloud\cloud_sdk>gcloud init
Welcome! This command will take you through the configuration of gcloud.

Settings from your current configuration [proxyconfig0] are:
core:
  disable_usage_reporting: 'False'
proxy:
  address: 127.0.0.1
  port: '1080'
  type: socks5

Pick configuration to use:
 [1] Re-initialize this configuration [proxyconfig0] with new settings
 [2] Create a new configuration
 [3] Switch to and re-initialize existing configuration: [default]
Please enter your numeric choice:  1

Your current configuration has been set to: [proxyconfig0]

You can skip diagnostics next time by using the following flag:
  gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).

You must log in to continue. Would you like to log in (Y/n)?  y

Your browser has been opened to visit:

    https://accounts.google.com/o/oauth2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&prompt=select_account&response_type=code&client_id=32555940559.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&access_type=offline


You are logged in as: [dreammax1997@gmail.com].

Pick cloud project to use:
 [1] tonal-run-227315
 [2] Create a new project
Please enter numeric choice or text value (must exactly match list
item):  1

Your current project has been set to: [tonal-run-227315].

Do you want to configure a default Compute Region and Zone? (Y/n)?  y

Which Google Compute Engine zone would you like to use as project
default?
If you do not specify a zone via a command line flag while working
with Compute Engine resources, the default is assumed.
 [1] us-east1-b
 [2] us-east1-c
 [3] us-east1-d
 [4] us-east4-c
 [5] us-east4-b
 [6] us-east4-a
 [7] us-central1-c
 [8] us-central1-a
 [9] us-central1-f
 [10] us-central1-b
 [11] us-west1-b
 [12] us-west1-c
 [13] us-west1-a
 [14] europe-west4-a
 [15] europe-west4-b
 [16] europe-west4-c
 [17] europe-west1-b
 [18] europe-west1-d
 [19] europe-west1-c
 [20] europe-west3-b
 [21] europe-west3-c
 [22] europe-west3-a
 [23] europe-west2-c
 [24] europe-west2-b
 [25] europe-west2-a
 [26] asia-east1-b
 [27] asia-east1-a
 [28] asia-east1-c
 [29] asia-southeast1-b
 [30] asia-southeast1-a
 [31] asia-southeast1-c
 [32] asia-northeast1-b
 [33] asia-northeast1-c
 [34] asia-northeast1-a
 [35] asia-south1-c
 [36] asia-south1-b
 [37] asia-south1-a
 [38] australia-southeast1-b
 [39] australia-southeast1-c
 [40] australia-southeast1-a
 [41] southamerica-east1-b
 [42] southamerica-east1-c
 [43] southamerica-east1-a
 [44] asia-east2-a
 [45] asia-east2-b
 [46] asia-east2-c
 [47] europe-north1-a
 [48] europe-north1-b
 [49] europe-north1-c
 [50] northamerica-northeast1-a
Did not print [6] options.
Too many options [56]. Enter "list" at prompt to print choices fully.
Please enter numeric choice or text value (must exactly match list
item):  1

Your project default Compute Engine zone has been set to [us-east1-b].
You can change it by running [gcloud config set compute/zone NAME].

Your project default Compute Engine region has been set to [us-east1].
You can change it by running [gcloud config set compute/region NAME].

Created a default .boto configuration file at [C:\Users\DreamMax\.boto]. See this file and
[https://cloud.google.com/storage/docs/gsutil/commands/config] for more
information about configuring Google Cloud Storage.
Your Google Cloud SDK is configured and ready to use!

* Commands that require authentication will use dreammax1997@gmail.com by default
* Commands will reference project `tonal-run-227315` by default
* Compute Engine commands will use region `us-east1` by default
* Compute Engine commands will use zone `us-east1-b` by default

Run `gcloud help config` to learn how to change individual settings

This gcloud configuration is called [proxyconfig0]. You can create additional configurations if you work with multiple accounts and/or projects.
Run `gcloud topic configurations` to learn more.

Some things to try next:

* Run `gcloud --help` to see the Cloud Platform services you can interact with. And run `gcloud help COMMAND` to get help on any gcloud command.
* Run `gcloud topic --help` to learn about advanced features of the SDK like arg files and output formatting

 类似资料: