derived from vmware education services course ‘virtual...
TRANSCRIPT
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
PAC 448 ESX Server Command Line Tips
Liz Laughlin, VCPTechnical Trainer
VMware, Inc.
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
This presentation may contain VMware confidential information.
Copyright © 2005 VMware, Inc. All rights reserved. All other marks and names mentioned herein may be trademarks of their respective
companies.
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Goal of This Presentation
To acquaint you with two categories of commands that can be run within the ESX Server Service Console:
Basic Linux commands ESX Server commands
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Command Formatcommand [-options] [arguments]
ls no options, no argumentsls –l single option, no argumentsls –alR multiple options, no argumentsls /tmp one argument, no optionsls –l /tmp one option, one argumentcp f1 f2 two required argumentscp -R d1 d2 one option, 2 required argumentsman command on-line manual pageman cpman -k copy key word search of man files
(makewhatis generates database)
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Sample Man OutputNAME
cp - copy files and directories
SYNOPSIScp [OPTION]... SOURCE DESTcp [OPTION]... SOURCE... DIRECTORYcp [OPTION]... --target-directory=DIRECTORY SOURCE...
DESCRIPTIONCopy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.……………..-p, --preserve preserve file attributes if possible…………….
-r copy recursively, non-directories as files WARNING:use -R instead when you might copy special fileslike FIFOs or /dev/zero
…………..:
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
No Man Page# man vmkpcidivy
No manual entry for vmkpcidivy# vmkpcidivy [-h]Usage: /usr/sbin/vmkpcidivy [ -i[nteractive]] [-l[abel] name] [-m[emory]
memsize] [ -q[uery]] [ -r[efreshnames]] [-[csv][dev] bus:slot:fcn][-d[rootdev] rootdev]
interactive: Interactively go through the PCI divy processlabel: Perform operations on configuration with specified labelmemory: Specify memory (in megabytes) given to Service Consolequery: Execute query. Valid queries: vmkmod, vmkdump_part, vmkdump_dev labels
vmfs_part vmhba_dev vmhba_devsrefreshnames: creates or updates device names[csv]dev: Assign specified device exclusively to console, shared or virtual machines
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Understanding PathsAbsolute path
Describes where a file exists in the directory structure when beginning at the top level or “root” directoryPath always begins with a “/”Valid anywhere in the file systems
Relative pathDescribes where a file exists in the directory structure relative to the current directoryNever begins with a “/”Must be different in each directory in the file systems
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
File and Directory Commandspwd print working directorycd change directoryls list contents (dir)
[root@esx1 bin]# pwd/usr/local/bin
[root@esx1 bin]# cd /etc[root@esx1 etc]# pwd
/etc[root@esx1 vmware]# ls vmware
config license-16-0.esx.2.0 devnames.conf license-16-2.esx-smp.2.0 ….
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
File and Directory Commandsmkdir make (create) directory
rmdir remove directory
[root@esx1 vmimages]# mkdir win2k_templates[root@esx1 vmimages]# ls
win2k_templates winxp[root@esx1 vmimages]# rmdir win2k_templates winxp
rmdir: `winxp': Directory not empty
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
File and Directory Commandscp copy files or directories
[root@esx1 vmware]# cp win2k.vmx win2k.vmx.bk[root@esx1 vmimages]# cp f1 f2 f3 mydir
rm remove files or directories
[root@esx1 vmware]# rm win2k.vmx.bk /vmimages/mydir/f3[root@esx1 vmimages]# rm -r winxp
mv move or rename files/directories
[root@esx1 vmware]# mv win2k.vmx win2k.vmx.bk[root@esx1 vmware]# mv win2k.vmx.bk /vmimages/mydir/
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
File Display Commands
cat file display utility (no scroll)
more provides scrolling through large files
less provides scrolling with additional features
head displays first 10 lines of a file
tail displays last 10 lines of a file
tail -f display last 10 lines of a file and keep the file open
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Viewing Disk Spacevdf -h free disk space on filesystems[root@esx1 root]# vdf -hFilesystem Size Used Avail Use% Mounted on/dev/ida/c0d0p2 1.7G 663M 1019M 40% //dev/ida/c0d0p1 50M 12M 36M 24% /boot/dev/ida/c0d0p7 1008M 17M 940M 2% /homenone 93M 0 93M 0% /dev/shm/dev/ida/c0d0p5 7.9G 6.1G 1.4G 82% /vmimagesvmhba0:0:0:8 21G 14G 6.1G 70% /vmfs/vmhba0:0:0:8
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
vmkpcidivy SyntaxCommand for managing device allocation
between the Service Console and the VMkernel
vmkpcidivy [ -i[nteractive]] [-l[abel] name] [m[emory] memsize] [ -q[uery]] [-r[efreshnames]] [-[csv][dev] bus:slot:fcn][-d[rootdev] rootdev]
query: Execute query. Valid queries: vmkmod, vmkdump_part, vmkdump_dev, labels, vmfs_part, vmhba_dev, vmhba_devs
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Command Examples[root@esx1 root]# vmkpcidivy -iBoot image configuration: esx
Image file: /boot/vmlinuz-2.4.9-vmnix2Memory: 192MService Console devices:Ethernet controller: Intel Corporation 82557 Amount of memory (in megs) to allocate to the Service Console [192]:. . .
Type 'c' to allocate to the Service Console or 'v' to allocate to the virtual machines, or 's' to share between both
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Command ExamplesTo map from VMkernel disk to a Linux device file:# vmkpcidivy –refreshnames# vmkpcidivy –q vmhba_devs
vmhba0:0:8 /dev/sdavmhba1:0:0 /dev/cciss/c0d0
To create a new partition or view existing partitions:# fdisk /dev/sda
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
vmkfstools SyntaxCommand for VMware ESX Server file system
management on SCSI disks
vmkfstools -OPTION [arg…] VMkernel-path
The last argument is always a path using the VMkernel’s device spaceEither a VMFS name (physical or friendly)vmhba0:1:0:5 /vmfs/vmhba0:1:0:5myvmfs /vmfs/myvmfsOr a VMFS name followed by a virtual disk file namevmhba0:1:0:5:a.dsk /vmfs/vmhba0:1:0:5/a.dskmyvmfs:a.dsk /vmfs/myvmfs/a.dsk
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Command ExamplesTo build a new VMFS:# vmkfstools –C vmfs2 vmhba0:8:0:1
To set the volume label# vmkfstools –S sanV3 vmhba0:8:0:1
To create a new virtual disk:# vmkfstools –c 4096 sanV3:websvr.vmdk
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Command ExamplesTo export:# vmkfstools –e /vmimages/ws.vmdk
sanV3:ws.vmdk
To extend the virtual disk:# vmkfstools –X 8192M sanV3:windata.vmdk
To import:# vmkfstools –i /vmimages/disk2.vmdk
sanV3:other.vmdk
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
vmware-mount.pl SyntaxTo display the partition table inside a virtual disk:
# vmware-mount.pl –p /vmfs/sanV3/db.vmdk
Nr Start Size Type Id System-- ----- ------- ---- --- ---------------1 63 4176837 BIOS 7 HPFS/NTFS
# vmware-mount.pl –p /vmfs/sanV3/mail.vmdk
Nr Start Size Type Id System-- ----- ------- ---- --- ---------------1 32 81888 BIOS 83 Linux2 81920 262144 BIOS 82 Linux swap3 344064 972800 BIOS 83 Linux
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Command Examples# mkdir /myntfs
# vmware-mount.pl /vmfs/sanV3/db.vmdk 1
-t ntfs -o ro /myntfs
In another window:
# ls /myntfsAUTOEXEC.BAT CONFIG.SYS IO.SYSboot.ini Documents and Settings MSDOS.SYS
Press Ctrl-C to kill vmware-mount.pl when done
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
vmware-cmd SyntaxVirtual machine operations
/usr/bin/vmware-cmd <options> <vm-cfg-path> <vm-action> <arguments>
Server operations/usr/bin/vmware-cmd -s <options> <server-action> <arguments>
See VMware Scripting API User’s Manual on http://www.vmware.com
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Command ExamplesTo list registered virtual machines:vmware-cmd –l
To register a virtual machine:vmware-cmd –s register /home/a/b/b.vmx
To start a virtual machine:vmware-cmd /home/a/b/b.vmx start
To check for heartbeat:vmware-cmd /home/fred/…/b.vmx
getheartbeatwait a few seconds, then repeat
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
vmsnap.pl and vmres.plTo back up:vmsnap.pl -a archiveserver -c
/home/vmware/name/name.vmx
To restore:vmres.pl -a archiveserver -d
/home/vmware/name/name.vmx-o owner -g group -v VMFS
More details on this in the “Virtual Infrastructure in Production: Backup and Disaster Recovery” lab.
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Sample Script
for vm in $(vmware-cmd -l)do
vmware-cmd $vm start softdone
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
Sample Script
for vm in $(vmware-cmd -l)do
cp $vm /vmimages/backup_config/done
Derived from VMware Education Services course ‘Virtual Infrastructure’See http://www.vmware.com/services/education.html for course schedule
PAC879: The Next Phase of Virtual Infrastructure: Introducing ESX Server 3.0 and VirtualCenter 2.0
PAC177: Distributed Availability Services ArchitecturePAC484: Consolidated Backup with ESX Server:
In-Depth ReviewPAC485: Managing Data Center Resources Using the
VirtualCenter Distributed Resource SchedulerPAC532: iSCSI and NAS in ESX Server 3
This presentation covers the current versions of our products. Details about
future releases of our products are available in select sessions at VMworld, including: