Metonymical Deflection

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

CentOS7でCSR1000vのセットアップ

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

c1kvはisoファイルからインストール or runファイルからインタラクティブインストールができるので、vMXやn9kvよりはさらに敷居が下がると思います。

以下の公式Docに沿って記載したいと思います。
Cisco CSR 1000v Series Cloud Services Router Software Configuration Guide - Installing the Cisco CSR 1000v in KVM Environments [Cisco Cloud Services Router 1000V Series] - Cisco


また、c1kvの足回りとしては、virtioとSR-IOVの両方で構成可能です。
また、インストールした後から諸々変更できるので助かります。

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.CSR1000vのインストール

公式Docを読む限り、isoファイルの場合とrunファイルの場合が記載されていますが、今回はvirt-managerによるGUIでのインストール方法をご紹介します。
IPMIなどが無ければ、tigervncなどを起動させておきましょう。*1

まずはisoファイルを/var/lib/libvirt/images/直下にコピー

cp csr1000v-universalk9.16.08.01a.iso /var/lib/libvirt/images/
2-1.virt-managerによるインストール

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

Local install mediaを選択して、Forwardをクリック
f:id:metonymical:20180429100035j:plain

前項でコピーしたcsr1000v-universalk9.16.08.01a.isoを選択して、Choose Volumeをクリック
f:id:metonymical:20180429100252j:plain

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

下図の通りであることを確認して、Forwardをクリック
最低4GBで起動します。
CPUsは1で起動します
f:id:metonymical:20180429100349j:plain
下図の通りであることを確認して、Forwardをクリック
公式Docを読む限り8GBでOKみたいです。
f:id:metonymical:20180429100429j:plain
Nameに任意の名前を入力
Customize configuration before installにチェック(必須)
Network selectionは任意のインターフェースを選択(mgt用なので後で変更可)
f:id:metonymical:20180429100527j:plain

Device modelにvirtioを選択(必須)*2
Applyをクリック
f:id:metonymical:20180429100801j:plain


c1kvではインストール時およびインストール後にConsole出力をVirtualかSerialかで設定や変更が可能ですが、ここではひとまずSerialからConsole出力できるように設定しておきます。

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

c1kvでは現在のタイミングおよびインストール後にもNICの追加が可能ですが、ここではひとまずSR-IOVのVFを追加しておきます。

画面左下のAdd Hardwareをクリック
PCI Host Deviceを選択
任意のVirtualFunctionを選択*4
Finishをクリック
f:id:metonymical:20180429101259j:plain

Begin Installationをクリックすると、以下の画面でConsole出力方法を選択できます。
VirtualとSerialが選択できますが、ここではSerialを選択して進めます。
ちなみに、Virtualを選択した場合、この画面のままインストールが進みます。
f:id:metonymical:20180429104335j:plain
Serialを選択すると、以下の画面で止まったように見えるため、後はホストOS上からtelnetすることになります。
f:id:metonymical:20180429113936j:plain

2-2.SerialConsoleの出力画面

ホストOS上からTelnetします。
telnet localhost 8889 でも接続可能です。

[root@ ~]# telnet 192.168.12.130 8889
Trying 192.168.12.130...
Connected to 192.168.12.130.
Escape character is '^]'.
%IOSXEBOOT-4-WAIT_FOR_DEVICES: (local/local): Partition "/dev/bootflash1" missing at 20180429013632 Continuing to initialization
%IOSXEBOOT-4-PART_INVALID: (local/local): /dev/bootflash has an invalid partition table that must be repaired.
%IOSXEBOOT-4-PART_REPAIR: (local/local): The system will repair /dev/bootflash now.

この後、自動的にインストールが開始され、一旦c1kvが再起動されます。
再起動と共にtelnetセッションが切断されるため、再度telnet接続します。

%IOSXEBOOT-4-BOOT_SRC: (rp/0): CD-ROM Boot
%IOSXEBOOT-4-BOOT_CDROM: (rp/0): Using Serial console
%IOSXEBOOT-4-BOOT_CDROM: (rp/0): Installing GRUB to /dev/bootflash
%IOSXEBOOT-4-BOOT_CDROM: (rp/0): Copying image to /boot
%IOSXEBOOT-4-BOOT_CDROM: (rp/0): Copying image to /bootflash
%IOSXEBOOT-4-BOOT_CDROM: (rp/0): Creating /boot/grub/menu.lst
%IOSXEBOOT-4-BOOT_CDROM: (rp/0): Ejecting CD-ROM tray
%IOSXEBOOT-4-BOOT_CDROM: (rp/0): CD-ROM Installation finished
%IOSXEBOOT-4-BOOT_CDROM: (rp/0): Rebooting from HD

Connection closed by foreign host.
[root@ ~]# telnet 192.168.12.130 8890
Trying 192.168.12.130...
Connected to 192.168.12.130.
Escape character is '^]'.
The highlighted entry will be booted automatically in 3 seconds.    The highlighted entry will be booted automatically in 2 seconds.    The highlighted entry will be booted automatically in 1 seconds.      Booting 'CSR1000v - packages.conf'

root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83
kernel /packages.conf rw quiet root=/dev/ram console= max_loop=64 HARDWARE=virt
ual SR_BOOT=bootflash:packages.conf
Calculating SHA-1 hash...done
SHA-1 hash:
        calculated   ef2043b5:caad0265:2a268887:a7004ba8:fcfe6506
        expected     ef2043b5:caad0265:2a268887:a7004ba8:fcfe6506
package header rev 3 structure detected
Calculating SHA-1 hash...done
SHA-1 hash:
        calculated   e674e45a:1da6da5e:2e3d73a7:7cf8b076:631b84d8
        expected     e674e45a:1da6da5e:2e3d73a7:7cf8b076:631b84d8
Package type:0x7531, flags:0x0
   [Linux-bzImage, setup=0x3c00, size=0x4c5e00]
   [isord @ 0x7e032000, 0x1fbded6 bytes]

%IOSXEBOOT-4-BOOT_SRC: (rp/0): Checking grub versions 1.0 vs 1.0
%IOSXEBOOT-4-BOOT_SRC: (rp/0): No need for bootloader upgrade.

上記の「%IOSXEBOOT-4-BOOT~」が出力されて、そこそこの時間待たされた後、以下の画面が出力されます。

              Restricted Rights Legend

Use, duplication, or disclosure by the Government is
subject to restrictions as set forth in subparagraph
(c) of the Commercial Computer Software - Restricted
Rights clause at FAR sec. 52.227-19 and subparagraph
(c) (1) (ii) of the Rights in Technical Data and Computer
Software clause at DFARS sec. 252.227-7013.

           Cisco Systems, Inc.
           170 West Tasman Drive
           San Jose, California 95134-1706

Cisco IOS Software [Fuji], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.8.1a, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2018 by Cisco Systems, Inc.
Compiled Tue 03-Apr-18 18:43 by mcpre

PLEASE READ THE FOLLOWING TERMS CAREFULLY. INSTALLING THE LICENSE OR
LICENSE KEY PROVIDED FOR ANY CISCO SOFTWARE PRODUCT, PRODUCT FEATURE,
AND/OR SUBSEQUENTLY PROVIDED SOFTWARE FEATURES (COLLECTIVELY, THE
"SOFTWARE"), AND/OR USING SUCH SOFTWARE CONSTITUTES YOUR FULL
ACCEPTANCE OF THE FOLLOWING TERMS. YOU MUST NOT PROCEED FURTHER IF YOU
ARE NOT WILLING TO BE BOUND BY ALL THE TERMS SET FORTH HEREIN.

Your use of the Software is subject to the Cisco End User License Agreement
(EULA) and any relevant supplemental terms (SEULA) found at
http://www.cisco.com/c/en/us/about/legal/cloud-and-software/software-terms.html.

You hereby acknowledge and agree that certain Software and/or features are
licensed for a particular term, that the license to such Software and/or
features is valid only for the applicable term and that such Software and/or
features may be shut down or otherwise terminated by Cisco after expiration
of the applicable license term (e.g., 90-day trial period). Cisco reserves
the right to terminate any such Software feature electronically or by any
other means available. While Cisco may provide alerts, it is your sole
responsibility to monitor your usage of any such term Software feature to
ensure that your systems and networks are prepared for a shutdown of the
Software feature.

% Failed to initialize nvram
cisco CSR1000V (VXE) processor (revision VXE) with 2186344K/3075K bytes of memory.
Processor board ID 9MJXF16X1D5
1 Gigabit Ethernet interface
32768K bytes of non-volatile configuration memory.
3985000K bytes of physical memory.
20357119K bytes of virtual hard disk at bootflash:.
0K bytes of WebUI ODM Files at webui:.

%INIT: waited 0 seconds for NVRAM to be available
PARSER-ERROR: (3) unexpected stale csb (0)


Press RETURN to get started!

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

3.c1kvへのログインとその他諸々

3-1.n9kvへのログイン

c1kvへのログインはパスワード無しでログイン可能ですので、あとは通常のCiscoIOSライクに扱ってください。

3-2.tftp config取得サービスの停止

起動直後に以下の出力でちょいちょい止まる場合がありますが、

%Error opening tftp://192.168.122.1/Router-confg (Timed out)
%Error opening tftp://192.168.122.1/Router-confg (Timed out)

以下のコマンドで停止することが可能です。

Router#conf t
Router(config)#no service config
3-3.Console出力の変更方法

Console出力ですが、以下のコマンドでSerial or Virtualの変更が可能です。
autoがどのような挙動になるかは未検証なので実際にやってみてください。

Router(config)#platform console ?
  auto     Autodetect console (Serial,VGA) for IOS output
  serial   Use Serial console for IOS output
  virtual  Use VM (VGA) console for IOS output
       
3-4.SR-IOVの確認

インストール時にアサインした2つ目以降のNICはSR-IOVのVFを指定しましたが、正常に認識されているかはshow interfacesで確認可能です。

Router#sh int g2
GigabitEthernet2 is administratively down, line protocol is down 
  Hardware is CSR vNIC, address is 0011.2233.4455 (bia 0011.2233.4455)
  MTU 1500 bytes, BW 1000000 Kbit/sec, DLY 10 usec, 
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation ARPA, loopback not set
  Keepalive set (10 sec)
  Full Duplex, 1000Mbps, link type is auto, media type is Virtual
  output flow-control is unsupported, input flow-control is unsupported
  ARP type: ARPA, ARP Timeout 04:00:00
  Last input never, output never, output hang never
  Last clearing of "show interface" counters never
  Input queue: 0/375/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: fifo
  Output queue: 0/40 (size/max)

ポイントはホストOS上のip link showで表示されるVFのMACアドレスと同一か?という点です。

[root@ ~]# ip link show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno1:  mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
    link/ether ac:16:2d:bb:9e:c0 brd ff:ff:ff:ff:ff:ff
3: eno2:  mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
    link/ether ac:16:2d:bb:9e:c1 brd ff:ff:ff:ff:ff:ff
4: ens1f0:  mtu 9198 qdisc mq state UP mode DEFAULT qlen 1000
    link/ether a0:36:9f:3e:6d:68 brd ff:ff:ff:ff:ff:ff
    vf 0 MAC 00:11:22:33:44:55, spoof checking off, link-state auto, trust off, query_rss off
    vf 1 MAC 00:11:22:33:44:56, spoof checking off, link-state auto, trust off, query_rss off
5: eno3:  mtu 1500 qdisc mq state DOWN mode DEFAULT qlen 1000
    link/ether ac:16:2d:bb:9e:c2 brd ff:ff:ff:ff:ff:ff
6: eno4:  mtu 1500 qdisc mq state DOWN mode DEFAULT qlen 1000
    link/ether ac:16:2d:bb:9e:c3 brd ff:ff:ff:ff:ff:ff
7: ens1f1:  mtu 9198 qdisc mq state UP mode DEFAULT qlen 1000
    link/ether a0:36:9f:3e:6d:6a brd ff:ff:ff:ff:ff:ff
    vf 0 MAC 00:11:22:33:44:57, spoof checking off, link-state auto, trust off, query_rss off
    vf 1 MAC 00:11:22:33:44:58, spoof checking off, link-state auto, trust off, query_rss off

以上です。

4.最後に

仮想マシンのインストールはいくつかのパターンがあるので、実際にインストールしてみて&壊してを繰り返していくうちにフィーリングがわかってくると思います。ただ、一度も成功したことがないと、今の状態は正常なのか?といった判断がつかないと思うので、何度か試してみることをお勧めします。

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

*2:公式Docに従ってvirtioにしています。e1000では未検証です。

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

*4:SR-IOVの設定は事前に行っておいてください。 metonymical.hatenablog.com