NetApp ONTAP CLI Cheat Sheet: Essential Storage Commands - 夜莺博客

NetApp ONTAP CLI Cheat Sheet: Essential Storage Commands

NetApp clustered ONTAP (formerly Data ONTAP) manages everything from the CLI, and most daily storage operations - checking hardware, inspecting aggregates, monitoring performance, configuring network interfaces - boil down to a handful of command families. This cheat sheet collects the essential ONTAP commands for storage administrators, from the boot menu to stats collection.

NetApp clustered ONTAP CLI cheat sheet

Two conventions run through everything below. First, commands shown in their short form (aggr, snap) also work with their full names (storage aggregate, snapshot) — ONTAP accepts the shortest unambiguous prefix, so the short form is safe to type but the long form is safer in scripts and documentation. Second, a large part of the classic 7-Mode toolkit (sysconfig, ifconfig, aggr status, storage show disk) still works, but only inside the node shell, which you reach with node run or system node run and which requires diagnostic privilege for some commands.

Boot Menu and Startup Modes

1) Normal Boot
2) Boot without /etc/rc
3) Change password
4) Clean configuration and initialize all disks
5) Maintenance mode boot
6) Update flash from backup config
7) Install new software first
8) Reboot node

Option 4 resets the filer to factory defaults; option 5 enters maintenance mode with a limited command set.

Maintenance mode is what you use when the node cannot boot far enough to accept normal commands: it gives you halt, boot, and a small set of disk and aggregate commands, including the ability to replace a failed boot device. Option 4 should be treated as destructive — it wipes configuration and disks — and option 6 is the recovery path when the compact flash or boot device has lost its configuration but the disks are intact.

System Information

version -b                    ! software version incl. diagnostic kernels
sysconfig                      ! general system info
sysconfig -v                   ! detailed
sysconfig -c                   ! configuration errors
sysconfig -d                   ! disk devices
sysconfig -V                   ! RAID group information
sysconfig -r                   ! aggregates and plexes
priv set advanced              ! enable advanced commands
systemshell                    ! access the system shell (diag user)

In a clustered system the equivalent high-level views are much simpler to read than raw sysconfig output: cluster show lists the nodes and their health, node show -fields node,health,uptime,model gives a one-line summary per node, and system node show adds the serial number and system ID you will be asked for when opening a support case. Keep both worlds in mind — the cluster commands are for reporting, the node commands are for diagnosis.

Storage and Disk Commands

storage show disk
storage show shelf
storage show port
storage show fault
storage show initiators
sasstat shelf
sasstat expander
sasstat dev_stats
storage enable adapter
storage disable adapter

storage show fault is the fastest way to answer "is anything broken right now", and sasstat dev_stats is the fastest way to confirm that what looks like a fault is not simply a busy expander path. On a clustered system the corresponding commands are storage disk show -broken for failed disks, storage shelf show for shelf inventory, and storage disk show -fields disk,container-type,owner when you need to know which node owns which disk.

Aggregate Management

aggr status
aggr status -s                    ! check for spare disks
aggr create newaggr -r 8 -d 8a.16 8a.17 8a.18 8a.19
aggr create newfastaggr -R 15000 20
aggr create newFCALaggr -T FCAL 15
aggr offline <aggregate>
aggr destroy <aggregate>

Key flags for aggr create: -r RAID group size, -T disk type (ATA/SATA/SAS/BSAS/FCAL/LUN), -R RPM, -m SyncMirror, -n dry run.

In ONTAP 9 the same operations have cluster-level equivalents that are generally preferred because they are Vserver and policy aware: storage aggregate create, storage aggregate add-disks, storage aggregate show -fields size,availsize,used, and storage aggregate show-space for the capacity breakdown. The -n dry-run habit is worth keeping in either syntax: creating an aggregate with the wrong RAID group size is expensive to undo.

Monitoring with stats show

stats show system
stats show processor
stats show disk
stats show volume
stats show lun
stats show aggregate
stats show iscsi
stats show cifs
stats show ifnet

stats show is the object-oriented statistics interface: each family maps to a counter group, and adding -interval 1 turns the one-shot sample into a live readout. For a single value in a script, stats show volume:total_ops-style object and counter names produce machine-readable output; for a human, the statistics show-periodic, sysstat and statit commands covered in the performance guide give a better layout. Memory: stats show system with the memory counters is how you watch buffer growth before it becomes a consistency-point problem.

Network Interface Configuration

ifconfig -a
ifconfig e0a netmask 255.255.255.0
ifconfig e8 mtusize 9000
ifconfig e0 alias 192.0.2.30
ifconfig e0 -alias 192.0.2.30
ifconfig e8 flowcontrol full
ifconfig e8 partner <IP Address>     ! HA pair failover IP
route add default 192.168.0.254 1
netstat -rn

These are node-shell commands, and they configure physical ports and their addresses. In ONTAP 9 the supported way to publish an address to clients is a logical interface: network interface create -vserver svm1 -lif nfs_lif1 -role data -data-protocol nfs -home-node node1 -home-port e0c -address 192.0.2.30 -netmask 255.255.255.0, followed by network interface show -fields address,curr-node,curr-port,status-admin,is-home and network port show -fields mtu,flowcontrol-admin. Use the LIF commands for anything a client will connect to, and the ifconfig family only when you are inside a node shell doing low-level diagnosis.

Volume, Snapshot and Efficiency Commands

volume create -vserver svm1 -volume vol1 -aggregate aggr1 -size 500g -junction-path /vol1
volume show -vserver svm1 -fields size,used,available,percent-used
volume move start -vserver svm1 -volume vol1 -destination-aggregate aggr2
volume offline -vserver svm1 -volume vol1
volume snapshot create -vserver svm1 -volume vol1 -snapshot snap_daily
volume snapshot show -vserver svm1 -volume vol1 -fields size
volume efficiency on -vserver svm1 -volume vol1
volume efficiency show -vserver svm1 -volume vol1
volume show-footprint -volume vol1

volume move start is the non-disruptive migration workhorse: it copies a volume to another aggregate and performs a brief cutover, which is how you evacuate an aggregate before maintenance. volume efficiency on enables deduplication and compression in one step, and volume show-footprint is the honest answer to "how much of the aggregate is this volume really consuming".

LUN, igroup and SAN Presentation

lun create -vserver svm1 -volume vol1 -lun lun1 -size 100g -ostype vmware
lun show -vserver svm1 -fields size,used,online,mapped
lun map -vserver svm1 -volume vol1 -lun lun1 -igroup ig1
igroup create -vserver svm1 -igroup ig1 -protocol iscsi -ostype vmware
igroup add -vserver svm1 -igroup ig1 -initiator iqn.1998-01.com.vendor:host1
iscsi session show
iscsi initiator show
fcp adapter show -fields node,adapter,status,data-link-rate
fcp lun show

The SAN commands follow a strict create-then-map sequence: the LUN exists in a volume, the igroup identifies the hosts, and only the map makes it visible. When a host cannot see a LUN, walk that order backwards — check lun show for the LUN and its mapping, iscsi session show or fcp lun show for the session, then compare the WWPN or IQN in the igroup against what the host actually presents. Nine out of ten SAN visibility faults are a mismatch in that last comparison.

SnapMirror and SnapVault

snapmirror initialize -destination-path svm_dr:vol1
snapmirror update -destination-path svm_dr:vol1
snapmirror show -fields source-path,destination-path,state,status,lag-time
snapmirror break -destination-path svm_dr:vol1
snapmirror resync -destination-path svm_dr:vol1
snapmirror policy show

snapmirror show with -fields lag-time is the health check that matters: a relationship that is "Snapmirrored" but hours behind is not a disaster-recovery relationship. break makes the destination writable for testing or for an actual failover, and resync returns it to service afterwards. Always confirm the relationship is idle and up to date with snapmirror show before taking a destination for a drill, otherwise the drill ingests a stale copy.

High Availability and Cluster Administration

storage failover show
storage failover show -fields node,partner,takeover-possible
storage failover takeover -ofnode node1
storage failover giveback -ofnode node1
cluster show
vserver show
security login show -vserver cluster
event log show -severity ERROR -time-reverse

storage failover show is the pre-flight check before any disruptive maintenance: if takeover-possible is false for either node, do not proceed. event log show -severity ERROR with -time-reverse puts the newest message at the top, which is the single most useful diagnostic command in ONTAP when something has just gone wrong.

Cluster-Mode versus 7-Mode Command Map

Task 7-Mode / node shell ONTAP 9 cluster
Software version version version
Hardware inventory sysconfig -v system node show
Disk inventory storage show disk storage disk show
Aggregate list aggr status storage aggregate show
Aggregate space df -A (node shell) storage aggregate show-space
Volume list vol status volume show
Snapshot list snap list volume snapshot show
Interface address ifconfig e0a network interface create
Route table route add default network route show
HA state cf status storage failover show
Replication snapmirror status snapmirror show

The table is worth keeping next to the cheat sheet because the two worlds coexist on every ONTAP 9 system. Cluster commands are for policy, provisioning and reporting; node commands are for hardware, and for the diagnostics that ONTAP still reserves for the node shell.

Environment and Health

environment status
environment shelf
environment chassis all
environment chassis Temperature
environment chassis Power

environment status collapses the whole cabinet into one screen of OK and not-OK lines and is the right command to run after a power event. The environment chassis variants drill into temperature and power history, which is what you need when a node has rebooted for no obvious reason and the logs point at thermal or power thresholds.

Diagnostic Access

set -privilege diagnostic
node run -node node1 -command sysconfig -r
system node run -node node1 -command ifconfig -a
set -privilege admin

Escalate, run the node-level command, then drop back to admin immediately. Staying in diagnostic privilege is a common cause of accidental configuration change, and every command that requires it is read-only by intent.

Related articles: NetApp ONTAP SnapMirror setup and troubleshooting, FC vs iSCSI SAN comparison, ONTAP performance monitoring commands, and Brocade SAN switch CLI commands.

原文链接:https://www.quickstart.com/blog/netapp/netapp-clustered-ontap-cli-cheat-sheet/