如何下载Google Compute Engine磁​​盘内容?

时间:2016-06-03 04:19:08

标签: neo4j google-compute-engine kubernetes persistent-storage

我已将持久卷链接到我的Kubernetes Neo4j复制控制器以存储数据库数据。现在我想在本地下载该数据以在我的系统上运行生产数据库。我无法找到下载磁盘内容的方法。有人能指出我正确的方向吗?

更新(使用Kubernetes创建持久卷):

persistent-volume-db.json
{
  "kind": "PersistentVolume",
  "apiVersion": "v1",
  "metadata": {
    "name": "pv-db"
  },
  "spec": {
    "capacity": {
      "storage": "500Gi"
    },
    "accessModes": [
      "ReadWriteMany"
    ],
    "gcePersistentDisk": {
      "pdName": "tuwa-db-data-disk",
      "fsType": "ext4"
    }
  }
}

persistent-volume-claim-db.json
{
  "kind": "PersistentVolumeClaim",
  "apiVersion": "v1",
  "metadata": {
    "name": "pvc"
  },
  "spec": {
    "accessModes": [
      "ReadWriteMany"
    ],
    "resources": {
      "requests": {
        "storage": "500Gi"
      }
    }
  }
}

然后用法:

neo4j-controller.json
{
  "kind": "ReplicationController",
  "apiVersion": "v1",
  "metadata": {
    "name": "neo4j-controller",
    "labels": {
      "name": "neo4j"
    }
  },
  "spec": {
    "replicas": 1,
    "template": {
      "metadata": {
        "labels": {
          "name": "neo4j"
        }
      },
      "spec": {
        "containers": [
          {
            "name": "neo4j",
            "image": "neo4j/neo4j",
            "ports": [
              {
                "name": "neo4j-server",
                "containerPort": 7474
              }
            ],
            "volumeMounts": [
              {
                "mountPath": "/data/databases",
                "name": "pv-db"
              }
            ]
          }
        ],
        "volumes": [
          {
            "name": "pv-db",
            "persistentVolumeClaim": {
              "claimName": "pvc-db"
            }
          }
        ]
      }
    }
  }
}

2 个答案:

答案 0 :(得分:4)

GCE的管理员面板没有"下载"永久磁盘按钮,但gcloud可以轻松地将文件从实例复制到本地计算机:

gcloud compute copy-files example-instance:~/REMOTE-DIR ~/LOCAL-DIR --zone us-central1-a

这会将~/REMOTE-DIR从远程实例复制到您计算机上的~/LOCAL-DIR。只需将目录名称example-instance替换为您的实例名称,然后根据需要调整您的区域。更多信息请参见docs

答案 1 :(得分:0)

gcloud compute copy-files  #has been deprecated

请改用 gcloud compute scp。请注意,默认情况下 gcloud compute scp 没有递归复制。要打开递归,请使用 --recurse 标志。

gcloud compute scp --recurse example-instance:~/instance-1_path  ~/locad_path --zone=us-central1-a

这会将远程计算实例中的 ~/instance-1_path 复制到您个人计算机上的 ~/local_path 中。只需将目录名称、example-instance 替换为您的实例名称,并在必要时调整您的区域。

可以找到此 SDK 的完整文档here