存档

2021年4月 的存档

GCP学习笔记01

2021年4月8日 没有评论

记录使用GCP的过程。首先在Google Cloud上激活服务,可以使用国内的VISA信用卡。信用卡将扣费1美元,也不能在GCP的“结算”中清除,除非使用一张新的信用卡。创建虚拟机很快,10G的Ubuntu 20.04LTS用了不到10秒。可以在云平台的虚拟机管理界面用SSH方式登录访问。在第一次使用Cloud Storage时遇到一些小问题。Cloud Storage按照Google的说法是做为一个内外交互的存储中转站。在GCP的Web界面中创建后,可以在虚拟机中通过gsutil cp gs://cloudstoragetestlink/xxx /home/test访问。后面虚拟机中使用gsutil创建Cloud Storage存储分区就总是报错:

instance-2:~$gsutil mb -b on -l us-east1 gs://my-awesome-bucket/0012
Creating gs://my-awesome-bucket0012/...
AccessDeniedException: 403 Insufficient Permission

找到解决方法是gcloud auth login:

instance-2:~$ gsutil mb -b on -l us-east1 gs://my-awesome-bucket0012/
Creating gs://my-awesome-bucket0012/...
AccessDeniedException: 403 Insufficient Permission
instance-2:~$ gcloud auth login
You are running on a Google Compute Engine virtual machine.
It is recommended that you use service accounts for authentication.
You can run:
  $ gcloud config set account `ACCOUNT`
to switch accounts if necessary.
Your credentials may be visible to others with access to this
virtual machine. Are you sure you want to authenticate with
your personal account?
Do you want to continue (Y/n)?  y
Go to the following link in your browser:
# 一串很长很长的链接
https://accounts.google.com/o/oauth2/xxxx   
# 输入上述链接在浏览器中打开后的验证码
Enter verification code: xxxx
You are now logged in as [xxxx@gmail.com].
Your current project is [trans-cosine-310015].  You can change this setting by running:
  $ gcloud config set project PROJECT_ID
instance-2:~$ 
instance-2:~$ 
instance-2:~$ 
instance-2:~$ gsutil mb -b on -l us-east1 gs://my-awesome-bucket0012/
Creating gs://my-awesome-bucket0012/...
# 创建成功,可以用 gsutil ls查看
分类: 云平台 标签: