Sunteți pe pagina 1din 13

SOLARIS QUICK TIPS Quick links to sections Lights out Management ZFS DTrace Package Management Live Update

Solaris Volume Management Backup and restore Misc useful stuff Lights out management Iloms seem to be a popular google search term Sun ILOM on v20z

To setup the ilom you can select Use Defaults from front panel and then add an admin user with ssh setup@ipaddress To enable serial over lan ssh admin@ipaddress platform set console -s sp -e -S 9600 To disable ssh admin@ipaddress platform set console -s platform Connect to the ilom with ssh then to start the console platform console To exit the console and return to the ilom CTRL-E c . or you can disconnect the ssh session with ~. To power on/off the system platform set power state on platform set power state off To display the mac address platform get mac

Sun ILOM on x4100


To set static ip address log in cd /SP/network set pendingipaddrss=x.x.x.x set pendingnetmask=255.255.255.x set pendinggateway=y.y.y.y set commitpending=true show /SP/network

To get to the console start /SP/console To exit from console ESC-SHIFT-9 To power on/off and reset the system start /SYS stop /SYS reset /SYS show /SYS To reboot the ilom reset /SP

Sun x4150 ILOM

Show the IP address info for the ilom show /SP/network Set set set set set the IP address for the ilom /SP/network IPSource=static /SP/network IPAddress=xxx.xxx.xxx.xxx /SP/network Netmask=xxx.xxx.xxx.xxx /SP/network Gateway=xxx.xxx.xxx.xxx

Power on, off and reset the host start /SYS stop /SYS reset /SYS Power off the host gracefully set /SYS/CtrlInfo PowerCtrl=graceful_off Reboot to the BIOS set /SYS/CtrlInfo PowerCtrl=BIOSSetup Reboot to the diagnosis program set /SYS/CtrlInfo PowerCtrl=PCCheck_enable Start the console start /SP/AgentInfo/Console When started use ESC-SHIFT-9 to return to the SP (may need to try a few times) Stop the console stop /SP/AgentInfo/Console Display information on serial port settings (external and host) show /SP/serial/external show /SP/serial/host Set the serial port settings for terminal access set /SP/serial/host pendingspeed=57600 commitpending=true

Sun T5120 ILOM

# Show the IP address info for the ilom show /SP/network # Set the IP address for the ilom -> set /SP/network state=enabled -> set /SP/network pendingipdiscovery=static -> set /SP/network pendingipaddress=10.8.31.163 -> set /SP/network pendingipnetmask=255.255.252.0 -> set /SP/network pendingipgateway=10.8.31.248 -> set /SP/network commitpending=true -> set/SP/pendingipdiscovery=dhcp -> set /SP/network commitpending=true # Power on, off and reset the host start /SYS stop /SYS reset /SYS # Start the console start /SP/AgentInfo/Console When started use #. to return to the SP (may need to try a few times) # Create a user that has the ALOM interface - Needed if you want to upgrade the system firmware create /SP/users/admin role=Administrator cli_mode=alom

ZFS ZFS zfs tasks Just enter zpool or zfs to get a help screen. Here are some commands that are often useful.
# Some reminders on command syntax root@server:# zpool create stuff c0d0s0 root@server:# zpool create stuff mirror c0d0s3 c1d0s0 root@server:# zfs create stuff/www root@server:# zfs set mountpoint=/var/www stuff/www root@server:# zfs create stuff/home root@server:# zfs set mountpoint=/export/home stuff/home root@server:# zfs create stuff/home/peter root@server:# zfs create stuff/home/paul root@server:# zfs create stuff/home/mary root@server:# zfs set compression=on stuff/home root@server:# zfs set quota=5g stuff/home/paul root@server:# zfs set reservation=10g stuff/home/mary root@server:# zfs set sharenfs=rw stuff/home root@server:# zpool scrub stuff root@server:# zpool add stuff mirror c3d0s4 c4d1s2 # to set the filesystem block size to 8k root@server:# zfs set recordsize=8k stuff/home

Solaris Volume Management Create a raid mirror of two empty partitions

# create one side of the mirror on the partition root@server:# metainit d11 1 1 c0t1d0s0 # and the other side of the mirror root@server:# metainit d12 1 1 c0t2d0s0 # now create a one sided mirror root@server:# metainit d10 -m d11 # attach the second side to the existing one sided mirror root@server:# metattach d10 d12

SVM Raid an existing single partition


# Make sure both disks have the same partition layout and create slices for the replica database (2 cylinders) # Check the disks and the layout root@server:# format # You can copy the vtoc from one disk to another with this. # You can also copy the vtoc to/from a file root@server:# prtvtoc /dev/rdsk/c?t?d?s? | fmthard -s - /dev/rdsk/c?t? d?s? # For x86 machines set the active partition for the disks root@server:# fdisk -b /usr/lib/fs/ufs/mboot /dev/rdsk/c?t?d?p? # If making root partition raid then make second disk bootable # For x86 machines root@server:# /sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c?t?d?s? # And for Sparc machines root@server:# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c?t?d?s? # Add the State Database Replicas to a slice (normally s7) - may need -f to force if partition mounted root@server:# metadb -a -f c?t?d?s? # Need more than one copy. Spread accross disks/controllers etc - see docs for details root@server:# metadb -a -f c?+1t?d?s? # We will use d0 with d10 and d20 as the two mirrors # Initialise the first mirror in the array. -f to force and "1 1" for one stripe and one slice root@server:# metainit -f d10 1 1 c?t?d?s? # Initialise the second mirror in the array root@server:# metainit d20 1 1 c?t?d?s? # Add the first mirror to the raid array root@server:# metainit d0 -m d10

# If doing the root partition this will update /etc/vfstab to point to new root partition location. If doing non-root partitions then vi the file root@server:# metaroot d0 # Reboot so system uses half of the new raid 1 array root@server:# reboot # Add the second mirror to the raid array root@server:# metattach d0 d20 # To check on the status of the array and make sure it is syncing root@server:# metastat # Misc commands # To delete an SDR root@server:# metadb -d -f c?t?d?s? # Detach a mirror from an array root@server:# metadetach d0 d10 # Take mirror off line root@server:# metaoffline d0 d20 # Put mirror back in array and resync root@server:# metaonline d0 d20 # Create a UFS file system on the new array root@server:# newfs /dev/md/dsk/d? # Backup your metadb information root@server:# metastat -p > /etc/lvm/md.tab

Replace a faulty drive from an array


# Detach the faulty disk root@server:# metadetach -f d0 d10

# Array was d0 with d10 and d20 as submirrors

# and remove the disk from the array root@server:# metaclear d10 # delete the SDR from the disk root@server:# metadb -f -d c?t?d?s? # If hot swap then replace the disk # Copy the vtoc from the good disk to a file root@server:# prtvtoc /dev/rdsk/c?t?d?s? > vtoc.c?t?d?s? # and copy to the new disk root@server:# fmthard -s vtoc.c?t?d?s? /dev/rdsk/c?t?d?s? # Add the new disk to the array root@server:# metainit d10 1 1 c?t?d?s? # and atach to the array. Will sync to existing drive

root@server:# metattach d0 d10 # add an SDR to the new disk root@server:# metadb -a -c 1 c?t?d?s?

Procedure to hot swap a disk from an array The following is a procedure I used to hot swap a disk that was part of a mirror on a system.
# remove d1 and d4 devices from the arrays root@server:# metadetach -f d0 d1 root@server:# metadetach -f d3 d4 # clear the data from the faulty disks root@server:# metaclear d1 root@server:# metaclear d4 # clear the svm database from the faulty disk root@server:# metadb -f -d c1t0d0s7 root@server:# format # find where the faulty disk is root@server:# cfgadm -alv # remove the disk from the kernel root@server:# cfgadm -c unconfigure c1::dsk/c1t0d0 # check the disk no longer appears ### If disk has gone then hot swap the disk ### root@server:# format # Tell the kernel about the device root@server:# cfgadm -c configure c1::dsk/c1t0d0 # copy the vtoc from existing disk to new disk root@server:# prtvtoc /dev/rdsk/c1t1d0s0 > /vtoc.c1t1d0s0 root@server:# fmthard -s /vtoc.c1t1d0s0 /dev/rdsk/c1t0d0s0 # Initialize and add the new disk to each array root@server:# metainit d1 1 1 c1t0d0s1 root@server:# metattach d0 d1 root@server:# metainit d4 1 1 c1t0d0s0 root@server:# metattach d3 d4 # create the svm databases root@server:# metadb -a -c 3 c1t0d0s7 # make the new disk bootable root@server:# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t0d0s0

Delete an array
# Delete all replica databases root@server:# metadb -d -f c?t?d?s7

# Now clear all devices root@server:# metaclear d10 root@server:# metaclear d0

Mount an SVM array from a live CD


On Solaris 9 or 10 # You need to mount one of the disks read only to get a copy of the original config root@server:# mount -o ro /dev/dsk/c?t?d?s? /a root@server:# cp -p /a/kernel/drv/md.conf /kernel/drv/md.conf root@server:# umount /a # Now load SVM: # First remove existing root@server:# modinfo | 154 7bb93000 2a140 85 1 root@server:# modunload module grep md md (Solaris Volume Manager base mod) -i 154

# Now load the md module #### For Solaris 9 root@server:# modload /kernel/drv/md #### For Solaris 10 root@server:# modload /kernel/drv/md OR update_drv -f md # and scan the disks root@server:# metainit -r # Make sure it all looks fine root@server:# metastat -p # If you change anything in md.conf then you MUST copy it back to the disks

Live Update Live update Pre-req's Read the Sun docs. There are many different options available and forward planning is the best solution. My setup Current root exists on SVM raid 1 array using c?t?d?s0 on two disks New boot ebvironment was to use SVM and c?t?d?s3 on the same disks Create the new boot environment
root@server:# lucreate -c "be1" -m /:/dev/md/dsk/d10:ufs,mirror -m /:/dev/dsk/c?t?d?s3:attach -m /:/dev/dsk/c?t?d?s3:attach -n "be2" Above does: - Create new boot environment be2 - Name existing environment be1

- create raid array called d10 and make it ufs - add c?t?d?s3 of two disks to the array

See how things went

root@server:# lustatus

Change to the new boot environment


root@server:# luactivate be2 root@server:# init 6

Live update from Solaris 10 to Solaris Express To upgrade from Solaris 10 to Solaris Express Create a new boot environment as above then mount the iso image. Then install the live update packages from Solaris Express
root@server:# /mnt/Solaris_11/Tools/Installers/liveupgrade20 -noconsole -nodisplay

Now upgrade the new boot environment


root@server:# luupgrade -u -n be2 -s /mnt

Change to the new boot environment


root@server:# luactivate be2 root@server:# init 6

Backup and restore File system snap shots


# Take a snapshot of a filesystem so you can back it up. command will return the virtual device to backup root@server:# fssnap -F ufs -o bs=/path/to/snapshot-storage-file /mountpoint /dev/fssnap/0 #### NOTE!!! ########################################## # If you are running ntp you may get the following error fssnap: ioctl: error 22: Invalid argument # If you do then stop the ntp server and try again ######################################################## # backup the filesystem using virtual device returned root@server:# ufsdump 0uf /path/to/save/ufsdump-output /dev/fssnap/0 # remove virtual device root@server:# fssnap -d /mountpoint

ufsdump and ufsrestore


# backup a filesystem # the number refers to the backup level - i.e. 0 for full to 9 for incremental root@server:# ufsdump 0uf /path/to/save/ufsdump-output /dev/dsk/c?t?d?s? # make a new filesystem to restore to root@server:# newfs /dev/rdsk/c?t?d?s? # restore the complete backup to the CURRENT DIRECTORY root@server:# ufsrestore rf /path/to/save/ufsdump-output root@server:# rm restoresymtable # unmount and check the new filesystem

root@server:# umount /mountpoint root@server:# fsck /dev/dsk/c?t?d?s?

Misc Control the system

# Fast reboot root@server:# init 6 # Shutdown and power off root@server:# init 5 # Shutdown to ok prompt root@server:# init 0 # to be nice to the system root@server:# shutdown -y -g 0 -i [level as above]

Display info about the hardware


# Display kernel info and patch level root@server:# uname -a root@server:# prtdiag -v root@server:# prtconf -v root@server:# psrinfo -v # Show what kernel modules are loaded root@server:# modinfo # Display lots of system info root@server:# sysdef # Display or set the library search path root@server:# crle

Detect new hardware on a system


root@server:# touch /reconfigure; reboot # or from obp root@server:# reboot -- -r # Solaris 10 root@server:# devfsadm

Find number of free blocks on a UFS filesystem


root@server:# fstyp -v /dev/md/dsk/d0 | head -20

Boot Solaris x86 in single user mode


At grub screen type e to edit select entry to boot edit and type e add -s to end, exit edit mode and reboot

Mount an iso image

# Make the block device with lofiadm: root@server:# lofiadm -a /path/to/file.iso /dev/lofi/1

# Mount the image as a read-only filesystem: root@server:# mount -F hsfs -o ro /dev/lofi/1 /mountpoint

Mount CDROM root@server:# mount -F hsfs -o nomaplcase,ro /dev/sr0 /cdrom Show what options were used when a filesystem was mounted root@server:# mkfs -m /dev/dsk/c?t?d?s? Show what process is using a file or mountpoint. (can also kill the process) root@server:# ps -o pid,ppid,rss,args -p $(fuser -c /mountpoint 2>/dev/null) The useful 'p' and other programs
# See the man pages for more information # Most can add a -v for verbose output prtconf prtdiag psrinfo pagesize # # # # General system information System diag info including any current alerts processor information show avaialble memory page sizes

# The current state of the system vmstat mpstat iostat netstat swap # Some other more detailed stat commands kstat cpustat cputrack busstat trapstat # These take a process id as last argument ##### Read man page about warnings before using these ##### pmap # Show process memory mapping pargs # args used to start process also pargs -e # show environment for a process pfiles # files opn by a process - see warnings pstack # show current stack trace - see warnings pflags # process flags pcred # process owner etc pldd # dynamic libraries linked to process psig # signal handlers and headers pwdx # current working directory

Find what code will run on system 32 or 64 bit


root@server:# isainfo -v

Duplicate disk partition information


root@server:# prtvtoc /dev/rdsk/c?t?d?s? | fmthard -s - /dev/rdsk/c?t? d?s?

Net booting

Network boot a server and install from jumpstart Control Break (CTRL-a f in minicom) ~break if using a Cyclades console server at the ok prompt type
root@server:# boot net - install root@server:# boot net:speed=100,duplex=full -v - install

Show ethernet port speed and MTU


root@server:# dladm show-dev root@server:# dladm show-link

Change IP address on Solaris 10


# Edit the following files root@server:# vim /etc/hosts root@server:# vim /etc/inet/ipnodes

To change the default router ( default gateway )


root@server:# vim /etc/defaultrouter

To change the hostname edit root@server:# vim /etc/hosts root@server:# vim /etc/nodename root@server:# vim /etc/hostname.{interface name}

To get the interface name type ( i.e. hme0, bge0 ) root@server:# prtconf -D | grep network

Add an ip alias
root@server:# fconfig bge0:1 plumb root@server:# ifconfig bge0:1 192.168.1.2 root@server:# ifconfig bge0:1 up # use it and to remove it root@server:# ifconfig bge0:1 down root@server:# ifconfig bge0:1 unplumb # to clear the failed flag on an interface root@server:# ifconfig -a -failed

Configure IPMP across two interfaces in active standby mode


root@server:# cat /etc/hosts 192.168.100.1 DUMMY1 192.168.100.2 DUMMY2 192.168.100.3 real.server

root@server:# for f in $(ls -1 /etc/hostname.*); do echo "Interface file -> $f; echo; cat $f; echo; done Interface file -> hostname.ce0 DUMMY1 netmask + broadcast + group production deprecated -failover up \ addif real.server netmask + broadcast + failover up Interface file -> hostname.ce1 DUMMY2 netmask + broadcast + group production deprecated -failover standby up

Jumpstart I will add information on Jumpstart in the near future

Service Manager

# to show what system services are running or disabled root@server:# svcs -a # To start, stop or restart a service root@server:# svcadm enable ssh root@server:# svcadm disable ssh root@server:# svcadm refresh ssh # to clear maintenance flag and start a service root@server:# svcadm clear ssh root@server:# svcadm enable ssh # Use -t to make change non persistant root@server:# svcadm enable -t ssh # to switch to a milestone root@server:# svcadm milestone svc:/milestone/single-user:default

Packages Some Package management

root@server:# pkgadd -d . packagename root@server:# pkgchk packagename root@server:# pkgparam -v packagename # To show patch versions root@server:# showrev -p

Find files installed by packages Grep for filename in Show current patch levels

root@server:# grep packagename /var/sadm/install/contents # find what patches have been applied to a system root@server:# showrev -p | grep ?????

DTrace DTrace DTrace Oneliners # New processes with arguments, root@server:# dtrace -n 'proc:::exec-success { trace(curpsinfo->pr_psargs); }' # Files opened by process, root@server:# dtrace -n 'syscall::open*:entry { printf("%s %s",execname,copyinstr(arg0)); }' # Syscall count by program, root@server:# dtrace -n 'syscall:::entry { @num[execname] = count(); }' # Syscall count by syscall, root@server:# dtrace -n 'syscall:::entry { @num[probefunc] = count(); }'

# Syscall count by process, root@server:# dtrace -n 'syscall:::entry { @num[pid,execname] = count(); }' # Read bytes by process, root@server:# dtrace -n 'sysinfo:::readch { @bytes[execname] = sum(arg0); }' # Write bytes by process, root@server:# dtrace -n 'sysinfo:::writech { @bytes[execname] = sum(arg0); }' # Read size distribution by process, root@server:# dtrace -n 'sysinfo:::readch { @dist[execname] = quantize(arg0); }' # Write size distribution by process, root@server:# dtrace -n 'sysinfo:::writech { @dist[execname] = quantize(arg0); }' # Disk size by process, root@server:# dtrace -n 'io:::start { printf("%d %s %d",pid,execname,args[0]->b_bcount); }' # Pages paged in by process, root@server:# dtrace -n 'vminfo:::pgpgin { @pg[execname] = sum(arg0); }' # Minor faults by process, root@server:# dtrace -n 'vminfo:::as_fault { @mem[execname] = sum(arg0); }'

S-ar putea să vă placă și