Metonymical Deflection

ゆるく日々のコト・たまにITインフラ

CentOS7でNexus9000vのセットアップ

CentOS7でCisco Nexus9000vのセットアップを実施したため、その手順を記載しておきます。

n9kvはqcow2ファイルをデプロイできるので、vMXよりは敷居が下がると思います。

以下の公式Docに沿って記載したいところですが、qemu直叩き方法しか記載がないため、直観的にはあまり役に立たないかもしれません。
Cisco Nexus 9000v Guide - Cisco Nexus 9000v [Cisco Nexus 9000 Series Switches] - Cisco

また、n9kvはBIOSではなくUEFIによる起動となるため、その準備をしっかり書きたいと思います。
さらに、ライセンス上、検証用途やコマンド確認用途に制限されているためなのか?足回りとしては、virtio(正確にはe1000)でのみ構成可能です。SR-IOVのVF直掴みはできませんでした。

1.環境

筐体                             : ProLiant DL360e Gen8
System ROM                       : P73 01/22/2018
NIC                              : Intel X540-AT2
OS                               : CentOS7.4(1708)
Kernel                           : kernel-3.10.0-693.21.1.el7.x86_64
Installed Environment Groups     : Server with GUI
Add-Ons for Selected Environment : Virtualization Client, Virtualization Hypervisor, Virtualization Tools 

2.UEFIの準備

以下のサイトを参考にさせて頂きました。
CentOS 7 : KVM : UEFI で起動する : Server World

2-1.リポジトリの作成
[root@ ~]# vi /etc/yum.repos.d/kraxel.repo

[qemu-firmware-jenkins]
name=firmware for qemu, built by jenkins, fresh from git repos
baseurl=https://www.kraxel.org/repos/jenkins/
enabled=0
gpgcheck=0
2-2.OVMF(Open Virtual Machine Firmware)のインストールと確認
yum --enablerepo=qemu-firmware-jenkins -y install OVMF

[root@ ~]#  ls -Fal /usr/share/OVMF/
total 6624
drwxr-xr-x    2 root root      75 Apr 24 09:32 ./
drwxr-xr-x. 263 root root    8192 Apr 24 09:32 ../
-rw-r--r--    1 root root 3653632 Aug  4  2017 OVMF_CODE.secboot.fd
-rw-r--r--    1 root root  540672 Aug  4  2017 OVMF_VARS.fd
-rw-r--r--    1 root root 2576384 Aug  4  2017 UefiShell.iso
2-3.qemu.confファイルの編集

vi /etc/libvirt/qemu.conf
で開いて、
682行目に以下を追記。もしくはコメントアウトでも可能。
nvram = [
"/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd"
]

[root@ ~]# vi /etc/libvirt/qemu.conf
~・~中略~・~
# Location of master nvram file
#
# When a domain is configured to use UEFI instead of standard
# BIOS it may use a separate storage for UEFI variables. If
# that's the case libvirt creates the variable store per domain
# using this master file as image. Each UEFI firmware can,
# however, have different variables store. Therefore the nvram is
# a list of strings when a single item is in form of:
#   ${PATH_TO_UEFI_FW}:${PATH_TO_UEFI_VARS}.
# Later, when libvirt creates per domain variable store, this list is
# searched for the master image. The UEFI firmware can be called
# differently for different guest architectures. For instance, it's OVMF
# for x86_64 and i686, but it's AAVMF for aarch64. The libvirt default
# follows this scheme.
#nvram = [                                 ←ここをコメントアウトしても可能
#   "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd",
#   "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd", ←ここをコメントアウトして「,」を削除でも可能
#   "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd"
#]                                     ←ここをコメントアウトしても可能
nvram = [
   "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd"
]

# The backend to use for handling stdout/stderr output from
# QEMU processes.
2-4.一旦、libvirtdのリスタート

systemctl restart libvirtd
で、リスタート

[root@ ~]# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
   Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2018-04-24 09:34:28 JST; 6s ago
     Docs: man:libvirtd(8)
           http://libvirt.org
 Main PID: 3616 (libvirtd)
   CGroup: /system.slice/libvirtd.service
           tq1879 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/...
           tq1880 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/...
           mq3616 /usr/sbin/libvirtd

Apr 24 09:34:28 c74x645 systemd[1]: Starting Virtualization daemon...
Apr 24 09:34:28 c74x645 systemd[1]: Started Virtualization daemon.
Apr 24 09:34:28 c74x645 dnsmasq[1879]: read /etc/hosts - 2 addresses
Apr 24 09:34:28 c74x645 dnsmasq[1879]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Apr 24 09:34:28 c74x645 dnsmasq-dhcp[1879]: read /var/lib/libvirt/dnsmasq/default.hostsfile
2-5.qemu-kvmのアップデート
yum -y install centos-release-qemu-ev
sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-QEMU-EV.repo

yumcentos-release-qemu-evをインストール
通常時はrelease-qemu-evを使用しないよう無効化に設定

[root@ ~]# /usr/libexec/qemu-kvm -version
QEMU emulator version 1.5.3 (qemu-kvm-1.5.3-141.el7_4.6), Copyright (c) 2003-2008 Fabrice Bellard

yum --enablerepo=centos-qemu-ev -y install qemu-kvm-ev
systemctl restart libvirtd

[root@ ~]# /usr/libexec/qemu-kvm -version
QEMU emulator version 2.9.0(qemu-kvm-ev-2.9.0-16.el7_4.13.1)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers

qemu-kvmのアップデート前のVer確認
qemu-kvmのアップデート(qemu-kvm-evのインストール)
libvirtdのリスタート
qemu-kvmのアップデート後のVer確認

◆補足
以下のコマンドを打った時

yum --enablerepo=centos-qemu-ev -y install qemu-kvm-ev

以下のエラーでqemu-kvm-evがインストールできなかったときの対処法

failure: repodata/repomd.xml from centos-qemu-ev: [Errno 256] No more mirrors to try.
http://mirror.centos.org/altarch/7/virt/x86_64/kvm-common/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

以下のようにbaseurlを変更してください。*1

[root@c75x645 vm]# vi /etc/yum.repos.d/CentOS-QEMU-EV.repo

# CentOS-QEMU-EV.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/Virtualization for more
# information

[centos-qemu-ev]
name=CentOS-$releasever - QEMU EV
#baseurl=http://mirror.centos.org/$contentdir/$releasever/virt/$basearch/kvm-common/ ←この行をコメントアウト
baseurl=http://mirror.centos.org/centos-7/7/virt/x86_64/kvm-common/ ←追記
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization

[centos-qemu-ev-test]
name=CentOS-$releasever - QEMU EV Testing
baseurl=http://buildlogs.centos.org/centos/$releasever/virt/$basearch/kvm-common/
gpgcheck=0
enabled=0

これでUEFIによる起動の準備が整いました。

3.Nexus9000vのインストール

公式Docを読む限り、qemu直叩きしてね、と記載があります。
試しにGNS3で起動させた際の ps -auxから引っ張ってきました。
(視認性を良くするため改行してますが、実際は1行になってます)

/usr/bin/qemu-system-x86_64
 -name CiscoNX-OSv9000nxosv-final.7.0.3.I7.3-1
 -m 8096M 
 -smp cpus=2 
 -enable-kvm 
 -machine smm=off 
 -boot order=c 
 -bios /opt/gns3/images/QEMU/OVMF-20160813.fd 
 -device ahci,id=ahci0,bus=pci.0 
 -drive file=/opt/gns3/projects/0d26cd09-1bdb-4be5-8587-28e02306ae72/project-files/qemu/47ac28d1-4e7e-4433-8722-ba7b1feacb2f/hda_disk.qcow2,if=none,id=drive-sata-disk0,index=0,media=disk 
 -device ide-drive,drive=drive-sata-disk0,bus=ahci0.0,id=drive-sata-disk0 
 -uuid 47ac28d1-4e7e-4433-8722-ba7b1feacb2f 
 -serial telnet:127.0.0.1:5001,server,nowait 
 -monitor tcp:127.0.0.1:46521,server,nowait 
 -net none 
 -device e1000,mac=52:ae:72:cb:2f:00,netdev=gns3-0 
 -netdev socket,id=gns3-0,udp=127.0.0.1:10001,localaddr=127.0.0.1:10000 
 -device e1000,mac=52:ae:72:cb:2f:01,netdev=gns3-1 
 -netdev socket,id=gns3-1,udp=127.0.0.1:10003,localaddr=127.0.0.1:10002 
 -device e1000,mac=52:ae:72:cb:2f:02,netdev=gns3-2 
 -netdev socket,id=gns3-2,udp=127.0.0.1:10005,localaddr=127.0.0.1:10004 
 -nographic

これを毎回打つのは辛いので、virt-managerによるGUIでのインストール方法をご紹介します。
IPMIなどが無ければ、tigervncなどを起動させておきましょう。*2
そこで、まずはqcow2ファイルを/var/lib/libvirt/images/直下にコピー

cp nxosv-final.7.0.3.I7.3.qcow2 /var/lib/libvirt/images/
cd /var/lib/libvirt/images/
cp nxosv-final.7.0.3.I7.3.qcow2 n9kv01.qcow2

cd後、qcow2ファイルをコピー。失敗したときにやり直しが可能なので。

3-1.virt-managerによるインストール

File>New Virtual Machineを選択
f:id:metonymical:20180428192118j:plain

Import existing disk imageを選択して、Forwardをクリック
f:id:metonymical:20180428192255j:plain

前項でコピーしたn9kv01.qcow2を選択して、Choose Volumeをクリック
f:id:metonymical:20180428192346j:plain

下図の通りであることを確認して、Forwardをクリック
f:id:metonymical:20180428192735j:plain

下図の通りであることを確認して、Forwardをクリック
エラー出まくりですが4GBでも起動します。
CPUsは1でも起動します
f:id:metonymical:20180428192839j:plain

Nameに任意の名前を入力
Customize configuration before installにチェック(必須)
Network selectionは任意のインターフェースを選択(mgt用なので後で変更可)
f:id:metonymical:20180428193019j:plain

FirmwareUEFI x86_64: を選択(必須)
ChipsetはQ35を選択(必須)
Applyをクリック
f:id:metonymical:20180428193223j:plain

Disk busにSATAを選択(必須)
Applyをクリック
f:id:metonymical:20180428193745j:plain

Device modelにe1000を選択(必須)*3
Applyをクリック
f:id:metonymical:20180428193834j:plain

本項は、n9kvの仕様上、virt-manager上にConsole画面が表示されないため*4、ホストOSからlocalhostに対してtelnet接続をすることによりConsole画面を呼び出すため必須設定となります。

画面左下のAdd Hardwareをクリック
Serialを選択
Device TypeにTCPを選択
Hostに0.0.0.0を入力*5
Portに8888など任意のポート番号を入力
ModeにServer mode(bind)を選択
Use Telnetにチェック
Finishをクリック
f:id:metonymical:20180428194127j:plain

Begin Installationをクリックすると、以下のUEFIにて起動され、n9kv01.qcow2の読み込みが開始されます。
f:id:metonymical:20180428195018j:plain

下画面が表示されたあたりで、以降はTelnet接続したSerialConsoleへの出力オンリーとなります。
f:id:metonymical:20180428195031j:plain

3-2.初期起動時のConsole出力画面

Telnet接続したSerialConsoleに出力されるBootLogを貼り付けておきます。
n9kvのBootLog

4.n9kvへのログインと必須設定

4-1.n9kvへのログイン

以下のように、skipした後、公式Doc記載の通り、admin/パスワード無しで進みます。

Abort Power On Auto Provisioning [yes - continue with normal setup, skip - bypass password and basic configuration, no - continue with Power On Auto Provisioning] (yes/skip/no)[no]: skip
!!! NOTE: You have selected skip option. POAP will be aborted and password configuration will be skipped !!!
Disabling POAP.......
Disabling POAP

2018 Apr 28 08:37:37 switch %$ VDC-1 %$ %POAP-2-POAP_INFO: [9DPJ22T32GT-52:54:00:87:D2:95] - USB Initializing Success
2018 Apr 28 08:37:37 switch %$ VDC-1 %$ %POAP-2-POAP_INFO: [9DPJ22T32GT-52:54:00:87:D2:95] - USB disk not detected
2018 Apr 28 08:37:37 switch %$ VDC-1 %$ last message repeated 1 time
2018 Apr 28 08:37:37 switch %$ VDC-1 %$ %POAP-2-POAP_DHCP_DISCOVER_START: [9DPJ22T32GT-52:54:00:87:D2:95] - POAP DHCP Discover phase started

2018 Apr 28 08:38:17 switch %$ VDC-1 %$ %ACLQOS-SLOT1-2-ACLQOS_FAILED: ACLQOS failure: TCAM region is not configured for feature QoS class IPv4 direction ingress. Please configure TCAM region Ingress COPP [copp] and retry the command. 

Error: There was an error executing atleast one of the command
Please verify the following log for the command execution errors.
2018 Apr 28 08:38:20 switch %$ VDC-1 %$ %PLATFORM-2-MEMORY_ALERT_RECOVERED: Memory Status Alert : CRITICAL ALERT RECOVERED
TCAM region is not configured. Please configure TCAM region and retry the command

2018 Apr 28 08:38:21 switch %$ VDC-1 %$ %PLATFORM-2-MEMORY_ALERT: Memory Status Alert : SEVERE.  Usage 84% of Available Memory

User Access Verification
 login: admin
Password: パスワード無しでそのままEnter

Cisco NX-OS Software
Copyright (c) 2002-2018, Cisco Systems, Inc. All rights reserved.
Nexus 9000v software ("Nexus 9000v Software") and related documentation,
files or other reference materials ("Documentation") are
the proprietary property and confidential information of Cisco
Systems, Inc. ("Cisco") and are protected, without limitation,
pursuant to United States and International copyright and trademark
laws in the applicable jurisdiction which provide civil and criminal
penalties for copying or distribution without Cisco's authorization.

Any use or disclosure, in whole or in part, of the Nexus 9000v Software
or Documentation to any third party for any purposes is expressly
prohibited except as otherwise authorized by Cisco in writing.
The copyrights to certain works contained herein are owned by other
third parties and are used and distributed under license. Some parts
of this software may be covered under the GNU Public License or the
GNU Lesser General Public License. A copy of each such license is
available at
http://www.gnu.org/licenses/gpl.html and
http://www.gnu.org/licenses/lgpl.html
***************************************************************************
*  Nexus 9000v is strictly limited to use for evaluation, demonstration   *
*  and NX-OS education. Any use or disclosure, in whole or in part of     *
*  the Nexus 9000v Software or Documentation to any third party for any   *
*  purposes is expressly prohibited except as otherwise authorized by     *
*  Cisco in writing.                                                      *
***************************************************************************
switch# 
4-2.ログイン後の必須設定

以下のように、起動OSの設定とadminユーザのパスワード設定を行い保存します。

switch(config)# dir bootflash:
       4096    Apr 28 08:15:27 2018  .rpmstore/
       4096    Apr 28 08:15:52 2018  .swtam/
      13176    Apr 28 08:19:09 2018  20180428_081706_poap_30180_init.log
      30602    Apr 28 08:29:41 2018  20180428_082540_poap_30281_init.log
      15451    Apr 28 08:38:03 2018  20180428_083554_poap_30312_init.log
  962771456    Feb 12 19:25:05 2018  nxos.7.0.3.I7.3.bin
          0    Apr 28 08:21:37 2018  platform-sdk.cmd
       4096    Apr 28 08:17:03 2018  scripts/
       4096    Apr 28 08:15:57 2018  virtual-instance/

Usage for bootflash://sup-local
 1242206208 bytes used
 2295013376 bytes free
 3537219584 bytes total
switch(config)# boot nxos bootflash:/nxos.7.0.3.I7.3.bin
Performing image verification and compatibility check, please wait....
switch(config)# username admin password cisco
WARNING: it is based on a dictionary word
WARNING: Configuration accepted because password strength check is disabled
switch(config)# copy running-config startup-config 
[########################################] 100%
Copy complete, now saving to disk (please wait)...
Copy complete.
switch# 
4-3.上記設定の保存が上手くいってなかった場合の対処

起動OSとパスワード設定の保存がうまくいってなかった場合、reloadや次回起動時には「loader>」のプロンプトで止まります。

その場合、以下の通り、dirで.binファイルの名前を確認した後、bootコマンドで手動起動させてください。

                Loader Version 5.01.0
Entering interactive mode

loader > dir
Setting listing for bootflash: 
Number of devices detected by BIOS is 1
Number of devices detected by BIOS is 1
Number of devices detected by BIOS is 1
Going to print files for device bootflash: 1 
 .rpmstore
 nxos.7.0.3.I7.3.bin
Number of devices detected by BIOS is 1
Number of devices detected by BIOS is 1
Number of devices detected by BIOS is 1
Clearing listing for bootflash: 

loader > boot nxos.7.0.3.I7.3.bin
Booting nxos.7.0.3.I7.3.bin 
Trying diskboot 
dev_str: bootflash: partition_str: 3 filename_str /nxos.7.0.3.I7.3.bin 
command = root (hd0,3)
 Filesystem type is ext2fs, partition type 0x83
Formed cmdline  console=ttyS0,115200n8nn  loader_ver="5.01.0"  quiet debug  
Formed cmdline  console=ttyS0,115200n8nn  loader_ver="5.01.0"  quiet debug  ksimg=nxos.7.0.3.I7.3.bin  card_index=21099 dummy_sprom swiotlb=48000  
Booting kickstart image: bootflash::3:/nxos.7.0.3.I7.3.bin....
Number of devices detected by BIOS is 1
NBI header
magic: 1b031336, len: 54, location: 94400000 (bx=0, ds=9440), exec addr: 92800000 16 16 

5.インターフェースの追加

上記までのインストール方法だとmgt用インターフェースしかないため、足回り用インターフェースを追加しますので、一旦n9kvをforce offするなどして停止させてください。

5-1.インターフェース追加設定

Add Hardwareを選択
Networkを選択
Network sourceから任意のbrインターフェースを選択
Device modelからe1000を選択
Finishをクリック
f:id:metonymical:20180428195056j:plain
下図の通り、とりあえず2~3個のインターフェースを追加します。
f:id:metonymical:20180428195105j:plain

5-2.インターフェース追加後の確認

インターフェース追加前後のshow int statusを確認してみます。

インターフェース追加前

switch# sh int status

--------------------------------------------------------------------------------
Port          Name               Status    Vlan      Duplex  Speed   Type
--------------------------------------------------------------------------------
mgmt0         --                 connected routed    full    1000    --         

--------------------------------------------------------------------------------
Port          Name               Status    Vlan      Duplex  Speed   Type
--------------------------------------------------------------------------------
Eth1/1        --                 notconnec 1         auto    auto    10g        
Eth1/2        --                 notconnec 1         auto    auto    10g        
Eth1/3        --                 notconnec 1         auto    auto    10g        
Eth1/4        --                 notconnec 1         auto    auto    10g        
Eth1/5        --                 notconnec 1         auto    auto    10g        
Eth1/6        --                 notconnec 1         auto    auto    10g        
Eth1/7        --                 notconnec 1         auto    auto    10g        
Eth1/8        --                 notconnec 1         auto    auto    10g        
Eth1/9        --                 notconnec 1         auto    auto    10g        
Eth1/10       --                 notconnec 1         auto    auto    10g        

インターフェース追加後

switch# sh int status

--------------------------------------------------------------------------------
Port          Name               Status    Vlan      Duplex  Speed   Type
--------------------------------------------------------------------------------
mgmt0         --                 connected routed    full    1000    --         

--------------------------------------------------------------------------------
Port          Name               Status    Vlan      Duplex  Speed   Type
--------------------------------------------------------------------------------
Eth1/1        --                 connected 1         full    auto    10g        
Eth1/2        --                 connected 1         full    auto    10g        
Eth1/3        --                 notconnec 1         auto    auto    10g        
Eth1/4        --                 notconnec 1         auto    auto    10g        
Eth1/5        --                 notconnec 1         auto    auto    10g        
Eth1/6        --                 notconnec 1         auto    auto    10g        
Eth1/7        --                 notconnec 1         auto    auto    10g        
Eth1/8        --                 notconnec 1         auto    auto    10g        
Eth1/9        --                 notconnec 1         auto    auto    10g        
Eth1/10       --                 notconnec 1         auto    auto    10g        

6.最後に

6-1.足回りに関する考察

n9kvのPCI Host DeviceからSR-IOVのVFを直接指定した場合、show int statusでは認識されませんでした。このため、インターフェースを増やしていくには、もう少し検証が必要かなと考えています。

パッと思いつくのは、

  • ixgbevfをmodprobeしてホストOS上でVFとして認識させる
  • brインターフェースを作成しUpLinkとしてVFを指定する
  • NIC追加時のNetwork sourceに作成したbrインターフェースを指定する

といった方法です。

しかし、この方法だとixgbevfをmodprobeしなければならないため、VFを直掴みさせたい子(仮想マシン)とn9kvを共存させることができないなぁ・・・と考えており、ちょっと悩んでいます。
ただ、単なる思い付きですが、ネストしたKVM上にn9kvを展開するって方法はアリかもしれません。

               :第1階層 :第2階層
物理SW-ホストOS:NestedKVM:Nexus9000v
        :vMX
        :CSR1000v
        :vThunder
  • 第1階層ではixgbevfをmodprobeせず、全員VFを直掴みさせる
  • 第2階層ではNestedKVMでbrを作成し、それを掴ませる

AWS VPC内であれば

aws ec2 modify-instance-attribute --instance-id instance_id --sriov-net-support simple

ってな感じで、ネスト上でVFをさらにパススルーさせてるっぽい。
って考えると、ネスト上でパススルーさせなくても、brインターフェースを掴ませるくらいなら、できるかもしれないので、ダメ元でやってみる価値はありそう?

*1:URL直書きなため少々ダサい方法ですが、$basearch=x86_64のディレクトリが別なPathに移動しているようなので。

*2:VNCサーバのインストール方法について、ここではあえて触れません、あしからず。

*3:これをvirtioにすると、そもそもn9kvが起動せず「loader>」のプロンプトになります。また、後で追加するインターフェースも全てe1000で統一してください

*4:.binファイルの読み込み途中で画面が止まります。

*5:ホストOS自身に設定されたIPであれば127.0.0.1でも192.168~でも可。0.0.0.0は自身のどのIPからでも要求を受け付けるために設定しています。