附录:配置 Linux 以识别多个网络接口的以太网设备 - SAP HANA 开启 Amazon
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

附录:配置 Linux 以识别多个网络接口的以太网设备

按照以下步骤配置 Linux 操作系统,以识别和命名与为逻辑网络分隔而创建的新弹性网络接口相关联的以太网设备,本白皮书前面已经讨论过。

  1. 使用 SSH 以 ec2-user 身份连接到 SAP HANA 主机,使用 sudo 连接到 root。

  2. 删除现有 udev 规则;例如:

    hanamaster:# rm -f /etc/udev/rules.d/70-persistent-net.rules
  3. 创建新 udev 规则,基于 MAC 地址而不是其他设备属性编写规则。这将确保在重新启动时,eth0 仍然是 eth0eth1eth1,依此类推。例如:

    hanamaster:# cat <<EOF >/etc/udev/rules.d/75-persistent-net- generator.rules # Copyright (C) 2012 Amazon.com, Inc. or its affiliates. # 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. # A copy of the License is located at # # https://aws.amazon.com/apache2.0/ # # or in the "license" file accompanying this file. This file 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. # these rules generate rules for persistent network device naming SUBSYSTEM!="net", GOTO="persistent_net_generator_end" KERNEL!="eth*", GOTO="persistent_net_generator_end" ACTION!="add", GOTO="persistent_net_generator_end" NAME=="?*", GOTO="persistent_net_generator_end" # do not create rule for eth0 ENV{INTERFACE}=="eth0", GOTO="persistent_net_generator_end" # read MAC address ENV{MATCHADDR}="\$attr{address}" # do not use empty address ENV{MATCHADDR}=="00:00:00:00:00:00", GOTO="persistent_net_generator_end" # discard any interface name not generated by our rules ENV{INTERFACE_NAME}=="?*", ENV{INTERFACE_NAME}="" # default comment ENV{COMMENT}="elastic network interface" # write rule IMPORT{program}="write_net_rules" # rename interface if needed ENV{INTERFACE_NEW}=="?*", NAME="\$env{INTERFACE_NEW}" LABEL="persistent_net_generator_end" EOF
  4. 确保接口属性正确。例如:

    hanamaster:# cd /etc/sysconfig/network/ hanamaster:# cat <<EOF >/etc/sysconfig/network/ifcfg-ethN BOOTPROTO='dhcp4' MTU="9000" REMOTE_IPADDR='' STARTMODE='onboot' LINK_REQUIRED=no LINK_READY_WAIT=5 EOF
  5. 确保最多可再容纳七个以太网设备或网络接口,然后重新启动 wicked。例如:

    hanamaster:# for dev in eth{1..7} ; do ln -s -f ifcfg-ethN /etc/sysconfig/network/ifcfg-${dev} done hanamaster:# systemctl restart wicked
  6. 创建新的网络接口并将其附加到实例。

  7. 重新启动。

  8. 修改 /etc/iproute2/rt_tables

    重要

    对连接到实例的每个 ENI 重复以下操作。

    例如:

    hanamaster:# cd /etc/iproute2 hanamaster:/etc/iproute2 # echo "2 eth1_rt" >> rt_tables hanamaster:/etc/iproute2 # ip route add default via 172.16.1.122 dev eth1 table eth1_rt hanamaster:/etc/iproute2 # ip rule 0: from all lookup local 32766: from all lookup main 32767: from all lookup default hanamaster:/etc/iproute2 # ip rule add from <ENI IP Address> lookup eth1_rt prio 1000 hanamaster:/etc/iproute2 # ip rule 0: from all lookup local 1000: from <ENI IP address> lookup eth1_rt 32766: from all lookup main 32767: from all lookup default