简体   繁体   English

Shell访问Google Cloud中的持久卷

[英]Shell access to Persistent Volume in Google Cloud

I would like to get shell access to the Persistent Volume I created on the Google Cloud Platform. 我想获得对我在Google Cloud Platform上创建的持久卷的shell访问权限。

I tried using Google Cloud Shell for this. 我尝试使用Google Cloud Shell。 But to be able to do that I need to attach the Persistent Volume through the gcloud commands, and the command requires the instance name. 但是为了能够做到这一点,我需要通过gcloud命令附加持久卷,并且该命令需要实例名称。 But I don't see the instance name of the Google Cloud Shell when I list the instance names (in gcloud). 但是当我列出实例名称(在gcloud中)时,我没有看到Google Cloud Shell的实例名称。

Is it possible to get shell access over Google Cloud Shell to the persistent disks? 是否可以通过Google Cloud Shell对永久磁盘进行shell访问? If not how can I get access to the Persistent Volume that I created? 如果不是,我怎样才能访问我创建的持久卷?

Yes, all disks need to be attached to an instance to allow access to them - you will need to create a compute instance and mount the persistent disk with gcloud compute instances attach-disk [INSTANCE_NAME] --disk [DISK_NAME] . 是的,所有磁盘都需要连接到实例以允许访问它们 - 您需要创建一个计算实例并使用gcloud compute instances attach-disk [INSTANCE_NAME] --disk [DISK_NAME]挂载永久磁盘。

Once you create the new instance the instance name will become visible to you for usage by running gcloud compute instances list 创建新实例后,通过运行gcloud compute instances list ,您可以看到实例名称的使用gcloud compute instances list

You will then be able to access the disk by ssh'ing into the instance and mounting it. 然后,您可以通过ssh进入实例并安装它来访问磁盘。

The following will help with mounting: 以下内容有助于安装:

https://cloud.google.com/compute/docs/disks/add-persistent-disk https://cloud.google.com/compute/docs/disks/add-persistent-disk

You don't see the Cloud Shell's instance name in your list of VMs because it isn't owned by your project (and thus, to answer your question, you won't have permission to attach your persistent disks to it). 您没有在VM列表中看到Cloud Shell的实例名称,因为它不属于您的项目(因此,为了回答您的问题,您将无权将永久磁盘附加到其中)。 You can verify this by querying the "/zone" endpoint of the Cloud Shell's metadata server, via curl "http://metadata.google.internal/computeMetadata/v1/instance/zone" as described in the GCE docs . 您可以通过curl "http://metadata.google.internal/computeMetadata/v1/instance/zone"查询Cloud Shell的元数据服务器的“/ zone”端点来验证这一点, 如GCE文档中所述

As Ryank mentioned, you'd need to attach the disk to an instance owned by your project, then SSH into it. 正如Ryank所提到的,您需要将磁盘附加到项目拥有的实例,然后将SSH连接到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM