【问题标题】:Hostname not resolving for CE in same network主机名无法解析同一网络中的 CE
【发布时间】:2019-12-01 14:07:09
【问题描述】:

我正在 2 个不同的区域(europe-west1-c 中的堡垒和 europe-west2-c 中的其他堡垒)部署 4 个 CE。我可以使用主机名从 cassandra-node-1 SSH 到 cassandra-node-2:

pedro_gordo_gmail_com@cassandra-node-1:~$ ssh cassandra-node-2
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.15.0-1049-gcp x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


0 packages can be updated.
0 updates are security updates.

New release '18.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Sun Dec  1 13:48:17 2019 from 10.154.0.14
groups: cannot find name for group ID 926993188

但我不能从堡垒 CE 做同样的事情:

pedro_gordo_gmail_com@bastion:~$ ssh cassandra-node-1
ssh: Could not resolve hostname cassandra-node-1: Name or service not known

但我可以使用内部/外部 IP 进行 ssh:

pedro_gordo_gmail_com@bastion:~$ ssh 10.154.0.14
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.15.0-1049-gcp x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

 * Overheard at KubeCon: "microk8s.status just blew my mind".

     https://microk8s.io/docs/commands#microk8s.status

0 packages can be updated.
0 updates are security updates.

New release '18.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Sun Dec  1 13:48:10 2019 from 173.194.92.32
groups: cannot find name for group ID 926993188

根据this GCP documentation,如果我为我的 CE 选择自定义名称,那么我需要编辑 DNS。但另一方面,如果我没有在我的部署管理器配置中提供name:,那么我在尝试部署时会收到以下错误:

gcloud deployment-manager deployments create cluster --config create-vms.yaml
ERROR: (gcloud.deployment-manager.deployments.create) ResponseError: code=412, message=Missing resource name in resource "type: compute.v1.instance          

这是我的部署管理器配置。如何更改此设置,以便仅使用主机名就可以从堡垒 ssh 到 cassandra-node-1/2/3?

# Copyright 2016 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Import all templates used in deployment

# Declare all resources. In this case, one highly available service
# as defined in the ha-service.py template.
resources:
- type: compute.v1.instance
  name: bastion
  properties:
    zone: europe-west1-c
    machineType: https://www.googleapis.com/compute/v1/projects/affable-seat-213016/zones/europe-west1-c/machineTypes/n1-standard-1
    disks:
    - deviceName: boot
      boot: true
      autoDelete: true
      initializeParams:
        sourceImage: https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20190514
    networkInterfaces:
    - accessConfigs:
      - name: External NAT
        type: ONE_TO_ONE_NAT
    metadata:
      items:
      - key: startup-script
        value: |
          #!/bin/bash
          sudo apt-add-repository -y ppa:ansible/ansible
          sudo apt-get update
          sudo apt-get install -y ansible
- type: compute.v1.instance
  name: cassandra-node-1
  properties:
    zone: europe-west2-c
    machineType: https://www.googleapis.com/compute/v1/projects/affable-seat-213016/zones/europe-west2-c/machineTypes/n1-standard-1 
    disks:
    - deviceName: boot
      boot: true
      autoDelete: true
      initializeParams:
        sourceImage: https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20190514
    - deviceName: data
      boot: false
      autoDelete: true
      initializeParams:
        diskSizeGb: 1
        diskType: zones/europe-west2-c/diskTypes/pd-ssd
    networkInterfaces:
    - accessConfigs:
      - name: External NAT
        type: ONE_TO_ONE_NAT
- type: compute.v1.instance
  name: cassandra-node-2
  properties:
    zone: europe-west2-c
    machineType: projects/affable-seat-213016/zones/europe-west2-c/machineTypes/n1-standard-1
    disks:
    - deviceName: boot
      boot: true
      autoDelete: true
      initializeParams:
        sourceImage: https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20190514
    - deviceName: data                                                                                                                                                                              
      boot: false
      autoDelete: true
      initializeParams:
        diskSizeGb: 1
        diskType: zones/europe-west2-c/diskTypes/pd-ssd
    networkInterfaces:
    - accessConfigs:
      - name: External NAT
        type: ONE_TO_ONE_NAT
- type: compute.v1.instance
  name: cassandra-node-3
  properties:
    zone: europe-west2-c
    machineType: https://www.googleapis.com/compute/v1/projects/affable-seat-213016/zones/europe-west2-c/machineTypes/n1-standard-1
    disks:
    - deviceName: boot
      boot: true
      autoDelete: true
      initializeParams:
        sourceImage: https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20190514
    - deviceName: data
      boot: false
      autoDelete: true
      initializeParams:
        diskSizeGb: 1
        diskType: zones/europe-west2-c/diskTypes/pd-ssd
    networkInterfaces:
    - accessConfigs:
      - name: External NAT
        type: ONE_TO_ONE_NAT

【问题讨论】:

    标签: google-cloud-platform google-deployment-manager


    【解决方案1】:

    您有两种解决方案:

    1. 使用 Google Cloud DNS 并设置专用区域来解析您的 VPC 的主机名。
    2. 使用 Compute Engine 内部 DNS 名称。

    但是,对于方法 #2,我不记得内部名称的主机名解析是否跨区域解析,因为 Compute Engine 内部 DNS 用于名称解析。如果 DNS 设置正确,方法 #1 将始终有效。

    【讨论】:

    • 如果我从文档中正确理解,要使用#2,我需要保留 CE 的默认名称。但是,部署管理器似乎不接受没有 CE 实例名称的配置(检查我帖子底部的问题)。有没有办法解决这个问题?
    • 我认为您遇到了初始错误,因为您需要在 yaml 文件中指定“名称”(INSTANCE_NAME),这是您无法避免的。但是,您是否尝试过通过添加提到的“主机名”字段来编辑相同的 yaml 文件 here,然后尝试通过堡垒主机 establish a connection
    猜你喜欢
    • 1970-01-01
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多