Tuesday, July 28, 2009

Sample ZFS commands and usage

Sample ZFS commands and usage
What You Do and See Why
$ man zpool
$ man zfs
Get familiar with command structure and options
$ su
Password:
# cd /
# mkfile 100m disk1 disk2 disk3 disk5
# mkfile 50m disk4
# ls -l disk*
-rw------T 1 root root 104857600 Sep 11 12:15 disk1
-rw------T 1 root root 104857600 Sep 11 12:15 disk2
-rw------T 1 root root 104857600 Sep 11 12:15 disk3
-rw------T 1 root root 52428800 Sep 11 12:15 disk4
-rw------T 1 root root 104857600 Sep 11 12:15 disk5
Create some “virtual devices” or vdevs as described in the zpool documentation. These can also be real disk slices if you have them available.
# zpool create myzfs /disk1 /disk2
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
myzfs 191M 94K 191M 0% ONLINE -
Create a storage pool and check the size and usage.
# zpool status -v
pool: myzfs
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
myzfs ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk2 ONLINE 0 0 0

errors: No known data errors
Get more detailed status of the zfs storage pool.
# zpool destroy myzfs
# zpool list
no pools available
Destroy a zfs storage pool
# zpool create myzfs mirror /disk1 /disk4
invalid vdev specification
use '-f' to override the following errors:
mirror contains devices of different sizes
Attempt to create a zfs pool with different size vdevs fails. Using -f options forces it to occur but only uses space allowed by smallest device.
# zpool create myzfs mirror /disk1 /disk2 /disk3
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
myzfs 95.5M 112K 95.4M 0% ONLINE -
# zpool status -v
pool: myzfs
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
myzfs ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk2 ONLINE 0 0 0
/disk3 ONLINE 0 0 0

errors: No known data errors
Create a mirrored storage pool. In this case, a 3 way mirrored storage pool.
# zpool detach myzfs /disk3
# zpool status -v
pool: myzfs
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
myzfs ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk2 ONLINE 0 0 0

errors: No known data errors
Detach a device from a mirrored pool.
# zpool attach myzfs /disk1 /disk3
# zpool status -v
pool: myzfs
state: ONLINE
scrub: resilver completed with 0 errors on Tue Sep 11 13:31:49 2007
config:

NAME STATE READ WRITE CKSUM
myzfs ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk2 ONLINE 0 0 0
/disk3 ONLINE 0 0 0

errors: No known data errors
Attach device to pool. This creates a two-way mirror is the pool is not already a mirror, else it adds another mirror, in this case making it a 3 way mirror.
# zpool remove myzfs /disk3
cannot remove /disk3: only inactive hot spares can be removed
# zpool detach myzfs /disk3
Attempt to remove a device from a pool. In this case it’s a mirror, so we must use “zpool detach”.
# zpool add myzfs spare /disk3
# zpool status -v
pool: myzfs
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
myzfs ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk2 ONLINE 0 0 0
spares
/disk3 AVAIL

errors: No known data errors
Add a hot spare to a storage pool.
# zpool remove myzfs /disk3
# zpool status -v
pool: myzfs
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
myzfs ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk2 ONLINE 0 0 0

errors: No known data errors
Remove a hot spare from a pool.
# zpool offline myzfs /disk1
# zpool status -v
pool: myzfs
state: DEGRADED
status: One or more devices has been taken offline by the administrator.
Sufficient replicas exist for the pool to continue functioning
in a degraded state.
action: Online the device using 'zpool online' or replace the device
with 'zpool replace'.
scrub: resilver completed with 0 errors on Tue Sep 11 13:39:25 2007
config:

NAME STATE READ WRITE CKSUM
myzfs DEGRADED 0 0 0
mirror DEGRADED 0 0 0
/disk1 OFFLINE 0 0 0
/disk2 ONLINE 0 0 0

errors: No known data errors
Take the specified device offline. No attempt to read or write to the device will take place until it’s brought back online. Use the -t option to temporarily offline a device. A reboot will bring the device back online.
# zpool online myzfs /disk1
# zpool status -v
pool: myzfs
state: ONLINE
scrub: resilver completed with 0 errors on Tue Sep 11 13:47:14 2007
config:

NAME STATE READ WRITE CKSUM
myzfs ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk2 ONLINE 0 0 0

errors: No known data errors
Bring the specified device online.
# zpool replace myzfs /disk1 /disk3
# zpool status -v
pool: myzfs
state: ONLINE
scrub: resilver completed with 0 errors on Tue Sep 11 13:25:48 2007
config:

NAME STATE READ WRITE CKSUM
myzfs ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk3 ONLINE 0 0 0
/disk2 ONLINE 0 0 0

errors: No known data errors
Replace a disk in a pool with another disk, for example when a disk fails
# zpool scrub myzfs
Perform a scrub of the storage pool to verify that it checksums correctly. On mirror or raidz pools, ZFS will automatically repair any damage.
WARNING: scrubbing is I/O intensive.
# zpool export myzfs
# zpool list
no pools available
Export a pool from the system for importing on another system.
# zpool import -d / myzfs
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
myzfs 95.5M 114K 95.4M 0% ONLINE -
Import a previously exported storage pool. If -d is not specified, this command searches /dev/dsk. As we’re using files in this example, we need to specify the directory of the files used by the storage pool.
# zpool upgrade
This system is currently running ZFS pool version 8.

All pools are formatted using this version.
# zpool upgrade -v
This system is currently running ZFS pool version 8.

The following versions are supported:

VER DESCRIPTION
--- --------------------------------------------------------
1 Initial ZFS version
2 Ditto blocks (replicated metadata)
3 Hot spares and double parity RAID-Z
4 zpool history
5 Compression using the gzip algorithm
6 pool properties
7 Separate intent log devices
8 Delegated administration
For more information on a particular version, including supported
releases, see:

http://www.opensolaris.org/os/community/zfs/version/N

Where 'N' is the version number.
Display pools format version. The -v flag shows the features supported by the current version. Use the -a flag to upgrade all pools to the latest on-disk version. Pools that are upgraded will no longer be accessible to any systems running older versions.
# zpool iostat 5
capacity operations bandwidth
pool used avail read write read write
---------- ----- ----- ----- ----- ----- -----
myzfs 112K 95.4M 0 4 26 11.4K
myzfs 112K 95.4M 0 0 0 0
myzfs 112K 95.4M 0 0 0 0
Get I/O statistics for the pool
# zfs create myzfs/colin
# df -h
Filesystem kbytes used avail capacity Mounted on
...
myzfs/colin 64M 18K 63M 1% /myzfs/colin
Create a file system and check it with standard df -h command. File systems are automatically mounted by default under the /zfs location. See the Mountpoints section of the zfs man page for more details.
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 139K 63.4M 19K /myzfs
myzfs/colin 18K 63.4M 18K /myzfs/colin
List current zfs file systems.
# zpool add myzfs /disk1
invalid vdev specification
use '-f' to override the following errors:
mismatched replication level: pool uses mirror and new vdev is file
Attempt to add a single vdev to a mirrored set fails
# zpool add myzfs mirror /disk1 /disk5
# zpool status -v
pool: myzfs
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
myzfs ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk3 ONLINE 0 0 0
/disk2 ONLINE 0 0 0
mirror ONLINE 0 0 0
/disk1 ONLINE 0 0 0
/disk5 ONLINE 0 0 0

errors: No known data errors
Add a mirrored set of vdevs
# zfs create myzfs/colin2
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 172K 159M 21K /myzfs
myzfs/colin 18K 159M 18K /myzfs/colin
myzfs/colin2 18K 159M 18K /myzfs/colin2
Create a second file system. Note that both file system show 159M available because no quotas are set. Each “could” grow to fill the pool.
# zfs set reservation=20m myzfs/colin
# zfs list -o reservation
RESERV
none
20M
none
Reserve a specified amount of space for a file system ensuring that other users don’t take up all the space.
# zfs set quota=20m myzfs/colin2
# zfs list -o quota myzfs/colin myzfs/colin2
QUOTA
none
20M
Set and view quotas
# zfs set compression=on myzfs/colin2
# zfs list -o compression
COMPRESS
off
off
on
Turn on and verify compression
# zfs set sharenfs=on myzfs/colin2
# zfs get sharenfs myzfs/colin2
NAME PROPERTY VALUE SOURCE
myzfs/colin2 sharenfs on local
Share a filesystem over NFS. There is no need to modify the /etc/dfs/dfstab as the filesystem will be share automatically on boot.
# zfs set sharesmb=on myzfs/colin2
# zfs get sharesmb myzfs/colin2
NAME PROPERTY VALUE SOURCE
myzfs/colin2 sharesmb on local
Share a filesystem over CIFS/SMB. This will make your ZFS filesystem accessible to Windows users.
# zfs snapshot myzfs/colin@test
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 20.2M 139M 21K /myzfs
myzfs/colin 18K 159M 18K /myzfs/colin
myzfs/colin@test 0 - 18K -
myzfs/colin2 18K 20.0M 18K /myzfs/colin2
Create a snapshot called test.
# zfs rollback myzfs/colin@test
Rollback to a snapshot.
# zfs clone myzfs/colin@test myzfs/colin3
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 20.2M 139M 21K /myzfs
myzfs/colin 18K 159M 18K /myzfs/colin
myzfs/colin@test 0 - 18K -
myzfs/colin2 18K 20.0M 18K /myzfs/colin2
myzfs/colin3 0 139M 18K /myzfs/colin3
A snapshot is not directly addressable. A clone must be made. The target dataset can be located anywhere in the ZFS hierarchy, and will be created as the same type as the original.
# zfs destroy myzfs/colin2
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 20.1M 139M 22K /myzfs
myzfs/colin 18K 159M 18K /myzfs/colin
myzfs/colin@test 0 - 18K -
myzfs/colin3 0 139M 18K /myzfs/colin3
Destroy a filesystem
# zfs destroy myzfs/colin
cannot destroy 'myzfs/colin': filesystem has children
use '-r' to destroy the following datasets:
myzfs/colin@test
Attempt to destroy a filesystem that had a child. In this case, the snapshot filesystem. We must either remove the snapshot, or make a clone and promote the clone.
# zfs promote myzfs/colin3
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 20.1M 139M 21K /myzfs
myzfs/colin 0 159M 18K /myzfs/colin
myzfs/colin3 18K 139M 18K /myzfs/colin3
myzfs/colin3@test 0 - 18K -
# zfs destroy myzfs/colin
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 147K 159M 21K /myzfs
myzfs/colin3 18K 159M 18K /myzfs/colin3
myzfs/colin3@test 0 - 18K -
Promte a clone filesystem to no longer be a dependent on it’s “origin” snapshot. This now associates makes the snapshot a child of the cloned filesystem. We can then delete the original filesystem.
# zfs rename myzfs/colin3 myzfs/bob
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 153K 159M 21K /myzfs
myzfs/bob 18K 159M 18K /myzfs/bob
myzfs/bob@test 0 - 18K -
# zfs rename myzfs/bob@test myzfs/bob@newtest
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 146K 159M 20K /myzfs
myzfs/bob 18K 159M 18K /myzfs/bob
myzfs/bob@newtest 0 - 18K -
Rename a filesystem, and separately rename the snapshot.
# zfs get all
NAME PROPERTY VALUE SOURCE
myzfs type filesystem -
myzfs creation Tue Sep 11 14:21 2007 -
myzfs used 146K -
myzfs available 159M -
myzfs referenced 20K -
[...]
Display properties for the given datasets. This can be refined further using options.
# zpool destroy myzfs
cannot destroy 'myzfs': pool is not empty
use '-f' to force destruction anyway
Can’t destroy a pool with active filesystems.
# zfs unmount myzfs/bob
# df -h
myzfs 159M 20K 159M 1% /myzfs
Unmount a ZFS file system
# zfs mount myzfs/bob
# df -h
myzfs 159M 20K 159M 1% /myzfs
myzfs/bob 159M 18K 159M 1% /myzfs/bob
Mount a ZFS filesystem. This is usually automatically done on boot.
# zfs send myzfs/bob@newtest | ssh localhost zfs receive myzfs/backup
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 172K 159M 20K /myzfs
myzfs/backup 18K 159M 18K /myzfs/backup
myzfs/backup@newtest 0 - 18K -
myzfs/bob 18K 159M 18K /myzfs/bob
myzfs/bob@newtest 0 - 18K -
Create a stream representation of the snapshot and redirect it to zfs receive. In this example I’ve redirected to the localhost for illustration purposes. This can be used to backup to a remote host, or even to a local file.
# zpool history
History for 'myzfs':
2007-09-11.15:35:50 zpool create myzfs mirror /disk1 /disk2 /disk3
2007-09-11.15:36:00 zpool detach myzfs /disk3
2007-09-11.15:36:10 zpool attach myzfs /disk1 /disk3
2007-09-11.15:36:53 zpool detach myzfs /disk3
2007-09-11.15:36:59 zpool add myzfs spare /disk3
2007-09-11.15:37:09 zpool remove myzfs /disk3
2007-09-11.15:37:18 zpool offline myzfs /disk1
2007-09-11.15:37:27 zpool online myzfs /disk1
2007-09-11.15:37:37 zpool replace myzfs /disk1 /disk3
2007-09-11.15:37:47 zpool scrub myzfs
2007-09-11.15:37:57 zpool export myzfs
2007-09-11.15:38:05 zpool import -d / myzfs
2007-09-11.15:38:52 zfs create myzfs/colin
2007-09-11.15:39:27 zpool add myzfs mirror /disk1 /disk5
2007-09-11.15:39:38 zfs create myzfs/colin2
2007-09-11.15:39:50 zfs set reservation=20m myzfs/colin
2007-09-11.15:40:18 zfs set quota=20m myzfs/colin2
2007-09-11.15:40:35 zfs set compression=on myzfs/colin2
2007-09-11.15:40:48 zfs snapshot myzfs/colin@test
2007-09-11.15:40:59 zfs rollback myzfs/colin@test
2007-09-11.15:41:11 zfs clone myzfs/colin@test myzfs/colin3
2007-09-11.15:41:25 zfs destroy myzfs/colin2
2007-09-11.15:42:12 zfs promote myzfs/colin3
2007-09-11.15:42:26 zfs rename myzfs/colin3 myzfs/bob
2007-09-11.15:42:57 zfs destroy myzfs/colin
2007-09-11.15:43:23 zfs rename myzfs/bob@test myzfs/bob@newtest
2007-09-11.15:44:30 zfs receive myzfs/backup
Display the command history of all storage pools. This can be limited to a single pool by specifying its name on the command line. The history is only stored for existing pools. Once you’ve destroyed the pool, you’ll no longer have access to it’s history.
# zpool destroy -f myzfs
# zpool status -v
no pools available
Use the -f option to destroy a pool with files systems created


Courtesy: http://www.lildude.co.uk/zfs-cheatsheet/

What can I do if ZFS file system panics on every boot?

What can I do if ZFS file system panics on every boot?
ZFS is designed to survive arbitrary hardware failures through the use of redundancy (mirroring or RAID-Z). Unfortunately, certain failures in non-replicated configurations can cause ZFS to panic when trying to load the pool. This is a bug, and will be fixed in the near future (along with several other nifty features, such as background scrubbing). In the meantime, if you find yourself in the situation where you cannot boot due to a corrupt pool, do the following:

boot using '-m milestone=none'
# mount -o remount /
# rm /etc/zfs/zpool.cache
# reboot
This will remove all knowledge of pools from your system. You will have to re-create your pool and restore from backup.

If a ZFS root file system panics, then you must boot from alternate media, import the root pool, resolve the issue that is causing the failure, export the root pool, and reboot the system. For more information, see the ZFS Troubleshooting Guide.

Monday, July 27, 2009

Remote Login Tip

Subject : Remote Login Tip

Description :

. Tip Sheet for Remote Login Programs
Including telnet, rlogin, rsh, rcp, rdist, rcmd

. Section

1.0: About Remote Login Programs
2.0: Debugging Remote Login Problems
2.1: General Debugging Advice
2.2: Performance Analyis
3.0: Common How Tos
3.1: How to Increase ptys on a SunOS Machine
3.2: How to Increase ptys on a Solaris Machine
3.3: How to Allow/Disallow Remote root Logins under SunOS
3.4: How to Allow/Disallow Remote root Logins under Solaris
3.5: How to Add a Banner to a SunOS telnet Login
3.6: How to Add a Banner to a Solaris telnet Login
3.7: How to Grant rsh/rdist/rcp Permissions
3.8: How to rdist a Directory
4.0: Some Frequently Asked Questions
4.1: General Remote Login Problems
4.2: General R-command Problems
4.3: rcp and rdist Specific Problems
5.0: Patches
5.1: Remote Login Patches for SunOS
5.2: Remote Login Patches for Solaris

. Content

1.0: About Remote Login Programs

This Tip Sheet documents a wide variety of information concerning the
various remote login programs supported under SunOS and Solaris. This
includes telnet, rlogin, rsh and the related r-commands, rcmd, rcp and
rdist. This Tip Sheet is intended as a guide to the most common remote
login problems. Other references which contain some documentation on
the remote login programs are noted in Section 7.0.

2.0 Debugging Remote Login Problems

2.1: General Debugging Advice

The remote login programs very rarely experience problems other than
those outlined in this Tip Sheet. If you are experiencing additional
problems, the commands etherfind (SunOS) or snoop (Solaris) may be
used to discover exactly what is occuring on the network, and the
commands trace (SunOS) or truss (Solaris) may be used to discover
exactly what the commands are doing when they fail. However, the
information that these commands provide is very technical, and not
always easy to interpret.

2.2: Performance Analysis

Problems involving remote login performance are beyond the scope of
service that SunService can provide. If you having problems with
remote login performance, consult Section 8.0 or 9.0 for where you can
get assistance from within Sun.

3.0 Common How Tos

3.1: How to Increase ptys on a SunOS Machine

You may want to increase your number of ptys to allow more people to
make remote logins to your machine at one time. The below example
increases the number of ptys to 128.

First, create a kernel with 128 ptys, by editing your kernel
configuration file (ie, /sys/sun4c/conf/GENERIC). Change the
pseudo-device line, as follows:

pseudo-device pty128

Afterwards, compile and run this kernel.

Second, go to the /dev directory and create the new pty devices:

# cd /dev
# MAKEDEV pty0 pty1 pty2 pty3 pty4 pty5 pty6 pty7

Each pty# creates 16 master-slave pairs. Thus, making 8 sets, as shown
above, results in 8 * 16 = 128 ptys.

Third, add the new pty names to /etc/ttytab, following the examples
already present. The names are tty[pqrstuvw] [0123456789abcdef],
i.e., ttyp0 - ttypf, ttyq0 - ttyqf, ..., ttyw0 - ttywf.

3.2: How to Increase ptys on a Solaris Machine

You may want to increase your number of ptys to allow more people to
make remote logins to your machine at one time.

To increase the number of ptys (pseudo-terminal devices) under
Solaris 2.3, 2.4, and 2.5, two parameters MUST be entered into, or
modified in, the /etc/system file:

set pt_cnt=
set npty=

We also recommend at 2.4and 2.5, that you also add or modify the following
two parameters in the /etc/system file:

set sad_cnt=<2x number specified in pt_cnt>
set nautopush=

Then do a reconfiguration reboot for the changes to take effect (e.g. boot -r
at the boot "OK" prompt).

For example to set to allowing 128 ptys:
set pt_cnt=128
set npty=128
set sadcnt=256
set nautopush=128


pt_cnt sets the number of pty's for System V, while npty sets the number
of pty's for BSD. sadcnt and nautopush are STREAMS parameters and
are needed to support additional users and network resources (in particular
when using NTS terminal server rtelnet).

sadcnt is the number of streams addressable devices nautopush is the
number of streams autopush entries

In general:
nautopush should be the same as pt_cnt.
sadcnt should be 2x number of nautopush.

3.3: How to Allow/Disallow Remote root Logins under SunOS

root login permissions are controlled by the /etc/ttytab file under
SunOS. To change root login permissions, you must modify every single
'network' line in the /etc/ttytab files.

Root access over the network is granted, if all of the network ttys
are labeled secure:

ttyp0 none network off secure

Root access over the network is denied if all of the network ttys are
labelled unsecure:

ttyp0 none network off unsecure

After making changes to the ttytab, you must HUP process 1:

# kill -HUP 1

Alternatively, you can reboot the machine.

3.4: How to Allow/Disallow Remote root Logins under Solaris

In the file /etc/default/login, there is a CONSOLE line.

If this line is commented out, then root access over the network is
granted:

#CONSOLE=/dev/console

If there is no comment in front of the CONSOLE line, root can only
login from the console.

CONSOLE=/dev/console

Changes to this file will take effect at once.

3.5: How to Add a Banner to a SunOS telnet Login

The best way to have a banner displayed before the telnet login: is to
write a wrapper program:

main ()
{
system("/bin/cat /etc/telnetbanner")
execl("/usr/etc/in.telnetd.real","/usr/etc/in.telnetd.real",(char *)0)
}

This wrapper would be compiled and installed as /usr/etc/in.telnetd, a
message would be installed into /etc/telnetbanner, and the original
in.telnetd would then be moved to in.telnetd.real.

Although this setup should work, it is not officially supported by
SunService.

3.6: How to add a Banner to a Solaris telnet Login

Under Solaris 2.4 and higher, you can add a banner by utilizing the
/etc/issue file. Edit this file to contain your banner, and it will be
read and displayed before the login prompt.

%% cat /etc/issue
** USE THIS MACHINE AT YOUR OWN RISK **

%% telnet localhost
...
UNIX(r) System V Release 4.0 (psi)

** USE THIS MACHINE AT YOUR OWN RISK **

login:

This functionality is not available in versions of Solaris earlier
than 2.4 for those cases, you might want to try the workaround
described in Section 3.5, but it is not officially supported, and may
not work.

3.7: How to Grant rsh/rdist/rcp Permissions

If an individual user wants to be able to rsh into his account without
password, or rdist or rcp into his account, he must create a .rhosts
file. This file should simply contain the name of the remote machine
which should have the rsh/rdist/rcp permissions, and also the name of
the user's account on that machine. For example:

%% cat ~/.rhosts
psi appel

The above .rhosts file would allow me to rsh, rdist or rcp to my
account from the account 'appel' on the machine 'psi'.

Root can also grant global permissions with the hosts.equiv file. This
file simply contains a list of remote machines:

%% cat /etc/hosts.equiv
psi

If a machine is listed, all users on that machine will be able to rsh,
rcp or rdist to the local machine, as long as they have accounts on
both machines with the same login name.

The above would grant this permission to the remote machine 'psi'.

The hosts.equiv man page lists other options available in that
configuration file.

3.8: How to rdist a Directory

The most common usage of rdist is to copy an entire directory
structure from one machine to another. This can be done with the
following command:

%% rdist -c directory remotemachine:/directory

In order for the above to work, rdist must be granted remote
permissions, as described in Section 3.7 above. This command may also
be set up in a distfile script, as is described in the rdist man page.

4.0 Some Frequently Asked Questions

4.1: General Remote Login Problems

Q: Why do I get one of the following errors when I try and log in to
my machine? This only occurs when many people are already logged in:

"xxx: could not grant slave pty."
"xxx: open /dev/ptmx: No such device"

A: These errors occur because your machine has run out of ptys. The
default number of ptys is 48, which will usually allow somewhere
around 30-35 users to log in. You simply need to increase the number
of ptys, and then rebuild your kernel. Sections 3.1 and 3.2 outline
how to increase the number of ptys.

Q: Why do I get the following message when I try and log in to my
Solaris machine:

"xxx: open /dev/logindmux: No such file or directory"

A: This is due to a bug in a Solaris patch which implements in-kernel
telnet. It can be corrected by adding the following line to the file
/etc/name_to_major:

logindmux 114

Afterwards, reboot the machine with the reconfigure option:

# touch /reconfigure
# reboot

When the machine comes back up, you should be able to log in
correctly.

Q: Why do I get a core dump from telnet/rlogin when I try and connect
to certain remote machines from my SunOS machine?

A: This is a known bug that occurs when a remote machine has multiple
addresses. It is fixed in the libc patch for 4.1.3 and 4.1.3_u1. See
section 5.1.1 below.

Q1: Why do the r-commands hang forever?
Q2: why do telnet/rlogin give the following error:

"connect: Connection refused"

A: in.telnetd or in.rlogind are not being started up correctly on the
machine you are trying to connect to. Make sure that inetd is running
on that machine, and make sure that the following two lines are
uncommented in the /etc/inetd.conf:

telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd
login stream tcp nowait root /usr/sbin/in.rlogind in.rlogind

(Locations will be slightly different on a SunOS machine).

If you have to make changes to inetd.conf, because the above lines are
missing, or commented out, you must restart inetd:

# kill -HUP inetd-pid

Q: Why do I get the following errors when I try and execute a remote
login:

"Network Unreachable"
"Host Unreachable"

A: These errors imply that routing is set up incorrectly to the
machine that you are trying to access. SunService has a seperate Tip
Sheet dedicated to Routing problems.

4.2: General R-command Problems

Q1: Why do I get a 'Password:' prompt when I rsh or rlogin?
Q2: Why do I get 'Permission Denied' when I rcp or rdist?

A1: You do not have a .rhosts file on the remote machine, correctly
listing your local machine. Section 3.7 explains how to set up a
.rhosts file.

A2: You are given explicit permissions to log in to the remote
machine, but the .rhosts file does not list your correct machine name.
For example, the .rhosts might mention your local machine's long host
name (ie, psi.corp.sun.com), while the remote machine actually
indentifies it by the short name (ie, psi) alternatively, your
.rhosts might read machine-le0, while the login request actually comes
from machine-le1. You can test this by logging in to the remote
machine (supplying your password), and then examining the .rhosts
file:

%% cat .rhosts
psi.corp.sun.com appel

Afterwards, run "who", look for your own login, and see what name your
local machine is identified as:

%% who
appel pts/10 Oct 6 09:59 (psi)

In the above case, my .rhosts file reads 'psi.corp.sun.com' while the
remote machine identifies me as 'psi'. These names must match for rsh,
rcp or rdist to work. After I change my .rhosts file to reflect the
who, the logins will work correctly:

%% cat .rhosts
psi appel

(It should be noted that the remote machine determines the name for
your local machine by looking in the first entry of files, NIS, NIS+
or DNS, depending on how you have your name services set up. If you do
not like the way your remote machine is identifying your local
machine, you will need to determine which of these name services is
providing the incorrect information, and correct it.)

Q: Why do some remote sites refuse to let me connect to them via the
r-commands, complaining that they can't lookup my name?

A: This is probably because the machine you are connecting from does
not have a DNS PTR record. You should consult your DNS maps, and
verify that both A and PTR records are being propagated for the
machine in question. SunService has a document on DNS which explains
this all more in depth.

Q: Why do I get the following error when I connect to a machine via
the r-commands:

"protocol error. Connection Closed."

A: This typically occurs because the permissions on in.rlogind are
incorrectly set on the machine you are trying to connect to.

On a SunOS machine, make sure in.rlogind has the following perms:

-rwxr-xr-x 1 root staff 16384 Jan 20 1994 /usr/etc/in.rlogind

On a Solaris machine, make sure in.rlogind has the following perms:

-r-xr-xr-x 1 bin bin 10848 Jul 15 1994 /usr/sbin/in.rlogind

4.3: rcp and rdist Specific Problems

Q1: Why does rcp/rdist fail, even though permissions are set up right?
Q2: Why do I get one of the following errors when I rcp/rdist:

"stty: TCGETS: operation not supported on socket"
"stty: : Invalid argument"

A: rcp and rdist will fail if certain types of commands exist in the
.cshrc of the account on the remote machine. You can temporarily fix
this by simply moving the .cshrc on the remote machine:

%% mv ~/.cshrc ~/.cshrc.DONOTUSE

Alternatively, you can correct the .cshrc so that rcp and rdist will
work right. You must surround all stty and echo statements in the
.cshrc with an if ($?prompt) endif combination. For example, if the
following line is in your .cshrc:

stty dec

Change it to the following:

if ($?prompt) then
stty dec
endif

If this is done to all stty and echo commands, you should be able to
rcp and rdist to that account correctly.

5.0: Patches

The following is the list of all of the remote login related patches
for 4.1.3, 4.1.3_u1, 4.1.4, 5.3 and 5.4. If you are having remote
login problems, installing the patches is a good place to start,
especially if you recognize the general symptoms noted below.

In order for a machine to be stable, all of the recommended patches
should be installed as well. The list of recommended patches for your
operating system is available from sunsolve1.sun.com.

5.1: Remote Login Patches for SunOS

100383-06 SunOS 4.0.3 4.1 4.1.1 4.1.2 4.1.3: rdist security and hard link

Fixes a security bug which could cause rdist to create setuid root
programs. Also fixes an rdist problem related to hard links.

100468-03 SunOS 4.1.1 4.1.2 4.1.3: rcp/rsh should use setsockopt to detec

Corrects a bug in rcp's behavior when a remote machine crashed, and
also a bug in rsh regarding processes with lots of open file
descriptors.

101673-01 SunOS 4.1.3 Point Patch: rsh hangs, talking to a heavily loaded

This point patch adds a -T (timeout) flag to rsh that can be used
when logging in to a heavily loaded machine.

101488-01 SunOS 4.1.1 4.1.2 4.1.3: TTY settings change when rlogin into a
101561-05 SunOS 4.1.3_U1: TTY settings change when rlogin into a 4.x syst

Corrects an error regarding flow control that showed up when logging
in to SunOS machine from a Solaris machine.

5.1.1: Related Patches for SunOS

100891-13 SunOS 4.1.3: international libc jumbo patch
100890-12 SunOS 4.1.3: domestic libc jumbo patch
101558-07 SunOS 4.1.3_U1: international libc jumbo patch
101759-03 SunOS 4.1.3_U1: domestic libc jumbo patch

Correct a problem where telnet, rlogin and other internet connection
programs coredump if they try and connect to a machine with multiple
A records. Please be sure to install the domestic version, and not
the international version, if you are in the US, because the
international version does not include encryption, which is
necessary for login to work correctly.

5.2: Remote Login Patches for Solaris

101494-01 SunOS 5.3: rdist will not remove remote directories

Fixes a bug where rdist -R would not remove remote directories that
no longer existed on the master.

101681-01 SunOS 5.3: telnet patch

Corrects bugs regarding pipes, and Sun/Dec interaction.

101318-75 SunOS 5.3: Jumbo patch for kernel (includes libc, lockd)
101945-36 SunOS 5.4: jumbo patch for kernel
101946-29 SunOS 5.4_x86: telnetd performance improvement

Improves telnet and rlogin performance by incorporating them into
the kernel.



Reference: http://stone.backrush.com/sunfaq/lmh005.html

Friday, July 24, 2009

How to upgrade VERITAS Volume Manager (VxVM)

How to upgrade VERITAS Volume Manager (VxVM) and Solaris from an older version of Solaris and SUNWvxvm.
--------------------------------------------------------------------------------
Details:
Update both VxVM and Solaris as follows:

Note: It is important to follow these steps in the specified order.

1.Obtain and install a VxVM 3.0.x license key. If currently running version 2.X or higher, there will be a valid key.

2. If any of the file systems /, /usr, /var,or /opt are defined on volumes, make sure that at least one plex for each of those
volumes is formed from a single subdisk that begins on a cylinder boundary. This is necessary because part of the upgrade process involves temporarily converting file systems on volumes back to using direct disk partitions and Solaris requires that disk partitions start on cylinder boundaries.
The upgrade scripts automatically convert file systems on volumes back to using regular disk partitions as necessary. If the upgrade scripts detect any problems (such as lack of cylinder alignment), they display an explanation of the problem
and the upgrade does not proceed.

3.Load and mount the CD-ROM or change to the directory into which the packages were downloaded. The CD-ROM
should then be visible as the file system mounted on /CD_path. If the CD-ROM is mounted automatically, its path
should be /cdrom/CD_name; if mounted manually, the path should be /mnt.

4.Run the upgrade_start script to prepare the previous release of the Volume Manager for its removal:


# CD_path/scripts/upgrade_start
or
scripts/upgrade_start (from the directory where the packages are located)


The upgrade_start script looks for volumes containing file systems. If certain key file systems must be converted back to using partitions, the script will indicate that a reboot is necessary. If so, reboot to single-user mode before proceeding to the next step. If any volumes are in use, they must either be unmounted or it is necessary to reboot to single-user mode.

5.Reboot to single-user mode (using a command such as /etc/shutdown).

6.Remove all SUNWvxvm and SUNWvxva patches and packages.Refer to Sun documentation for this procedure.

7.Shut down and halt the machine by using a command such as /etc/shutdown.

8.Boot from the Solaris CD-ROM to upgrade Solaris. Refer to Sun documentation for correct upgrade procedures.

9.Reboot the machine to single-user mode (using a command such as /etc/shutdown). It is now necessary to remount the CD-ROM manually or change into the directory where the packages have been downloaded.

10. Add the VxVM 3.0.x package by typing:


# pkgadd -d CD_path/OS_version/pkgs VRTSvxvm (from the cdrom)
or
# pkgadd -d . VRTSvxvm (from the directory where the packages are located)

If this returns warnings that include the string /etc/vx, they can be ignored and it can be continued.

11. Complete the upgrade by entering:


# CD_path/scripts/upgrade_finish (from the cdrom)
or
scripts/upgrade_finish (from the directory where the packages are located)


12.To disable the hot-relocation feature, comment out the vxrelocd line in the startup file /etc/rc2.d/S95vxvm-recover, as
follows:


#vxrelocd root &


13. Reboot to multi-user mode. At this point, the pre-upgrade configuration should be in effect and any file systems previously defined on volumes should be defined and mounted.

14.Using pkgadd, install any or all of the additional packages VRTSvmsa, VRTSvmdoc, VRTSvmman and VRTSvmdev.

15. Check the VERITAS support website for the latest patches for the Volume Manager version installed: http://support.veritas.com/

16.Importing a pre-3.x Volume Manager disk group does not automatically upgrade the disk group version to the VxVM 3.x level. It may be necessary to manually upgrade each of the disk groups following a VxVM upgrade:

vxdg upgrade

Reference: http://seer.entsupport.symantec.com/docs/230184.htm

Veritas VxVM & VxFS 3.2 – 5.0 upgrade procedure

Veritas VxVM & VxFS 3.2 – 5.0 upgrade procedure(this procedure should work for upgrading pre-4.0 versions to 4.1 and above)

** prior to starting, create the file: /etc/vx/reconfig.d/state.d/install-db

SUMMARY:

o if using EMC arrays/Powerpath for external storage, configure appropriately (see DETAILS below)
o break root mirror & unencapsulate
** (if any additional volumes have been created in the rootdg diskgroup, they should be backed up
as they will go away when the root drive is unencapsulated; it is never a good idea to
define data volumes on the boot drive in rootdg diskgroup) **
o uninstall 3.2 (remove pkgs & kill processes)
o install Storage Foundation 5.0 (and Maintenance Patch; MP1)
o if data disks are connected, verif the output of vxdisk list (the TYPE column)
o encapsulate & mirror root drive
o upgrading data disks

DETAILS:

o if using EMC arrays/Powerpath for external storage, configure appropriately
- decide if PowerPath should be upgraded or leave uninstalled to use Volume Manager DMP
(DMP will be automatically configured)
o if PowerPath will be upgraded, check with EMC for current compatible version of PowerPath
- see installation guide page 71 (Unsuppressing DMP for EMC PowerPath disks).
(http://support.veritas.com/docs/283887)

o break root mirror & unencapsulate

- … deport data disk groups …
(command: vxdg deport datadg (diskgroup)
(if the root drive is not mirrored, skip to “Unencapsulate boot drive” below)
- vxplex -g rootdg -o rm dis
(do this for each of the mirror drive plexes)
- vxdg -g rootdg rmdisk
- /usr/lib/vxvm/bin/vxdiskunsetup
- cd /etc
- ls *.prevm
(verify that vfstab & system exist, if so)
mv system system-
mv vfstab vfstab-
cp system.prevm system
cp vfstab.prevm vfstab
** (the mounts in the vfstab.prevm should match the slices in the output of:
prtvtoc /dev/rdsk/s2) **
o unencapsulate boot drive
- vxunroot (yes to reboot)
(returns boot drive to booting from native slices)

o uninstall 3.2 (remove pkgs & kill processes)
- … kill vx processes if they exist (ps -aef|grep vx) …
- cp -r /etc/vx/licenses/elm /var/tmp
- pkgrm (ls /opt/VRTS*|grep -v VRTS)
- rm -r /opt/VRTS*
- rm -r /etc/vx /var/vx
- reboot

o install SF 5.0 (and MP2 or latest release)
- … verify that no vx processes have started …
- uncompress & untar installation archive
(5.0 base release; must be downloaded from Customer Care; serial # require via license upgrade)
- run installsf
(or install ; ie … installvm for Volume Manager)
- uncompress & untar MP1 archive
(http://support.veritas.com/docs/288505)
- run installmp
(see included README and release notes)

o if data disks are connected, verify the output of vxdisk list (the TYPE column)
- auto:none (new uninitialized disks)
- auto:sliced (encapsulated disks containg slices)

o encapsulate & mirror root drive
- use vxdctl bootdg rootdg to create default rootdg disk group
- use vxdiskadm to encapsulate and mirror boot drive
(a spare drive must be initialized as sliced and belong to rootdg; vxdiskadm option 1)
(options 2 & 6)
- reboot

o upgrading data disks
- … import data disk groups …
- vxdg import datadg
- use “vxdg upgrade” to upgrade diskgroup versions
command: vxdg upgrade
- mount all data volumes
- use vxupgrade to upgrade vxfs filesystem versions one version at a time if appropriate
o use ‘fstyp | grep version’ to determine starting version
- use fsck (-o full) then vxupgrade to next version
(command: vxupgrade [-n new_version] mount_point )
(repeat until version 7 is reached)
(repititious fsck -o full can be timely but is best practice)

Wednesday, July 8, 2009

Sed Tips

sed (Stream EDitor) refers to a Unix utility for parsing text files and the programming language it uses to apply textual transformations to a sequential stream of data. It reads input files line by line, applying the operation which has been specified via the command line (or a sed script), and then outputs the line. Getting started with sed can be a real pain if you are unfamiliar with perl for regular expressions.

FILE SPACING:

Double space a file
sed '/^$/d;G'

Undo double-spacing (assumes even-numbered lines are always blank)
sed 'n;d'

NUMBERING:

Number each line of a file (number on left, right-aligned)
sed = filename | sed 'N; s/^/ /; s/ *(.{6,})n/1 /'

Number each line of file, but only print numbers if line is not blank
sed '/./=' filename | sed '/./N; s/n/ /'

Count lines (emulates “wc -l”)
sed -n '$='

TEXT CONVERSION AND SUBSTITUTION:

Convert DOS newlines (CR/LF) to Unix format.
sed 's/.$//'

Convert Unix newlines (LF) to DOS format.
sed 's/$'"/`echo r`/"

Delete leading whitespace (spaces, tabs) from front of each line aligns all text flush left
sed 's/^[ t]*//’

Delete trailing whitespace (spaces, tabs) from end of each line
sed 's/[ t]*$//’

Delete BOTH leading and trailing whitespace from each line
sed 's/^[ t]*//;s/[ t]*$//’

Substitute (find and replace) “foo” with “bar” on each line
sed 's/foo/bar/' # replaces only 1st instance in a line

sed 's/foo/bar/4' # replaces only 4th instance in a line

sed 's/foo/bar/g' # replaces ALL instances in a line

Change “scarlet” or “ruby” or “puce” to “red”
sed 's/scarlet/red/g;s/ruby/red/g;s/puce/red/g'

SELECTIVE PRINTING OF CERTAIN LINES:

Print first 10 lines of file (emulates behavior of “head”)
sed 10q

Print first line of file (emulates “head -1″)
sed q

Print the last 10 lines of a file (emulates “tail”)
sed -e :a -e '$q;N;11,$D;ba'

Print the last 2 lines of a file (emulates “tail -2″)
sed '$!N;$!D'

Print the last line of a file (emulates “tail -1″)
sed -n '$p'

Print section of file based on line numbers (lines 8-12, inclusive)
sed -n '8,12p'

Print only lines which match regular expression (emulates “grep”)
sed '/regexp/!d'

Grep for AAA and BBB and CCC (in any order)
sed '/AAA/!d; /BBB/!d; /CCC/!d'

Grep for AAA and BBB and CCC (in that order)
sed '/AAA.*BBB.*CCC/!d'

SELECTIVE DELETION OF CERTAIN LINES:

Delete duplicate, consecutive lines from a file (emulates “uniq”).
sed '$!N; /^(.*)n1$/!P; D'

Delete duplicate, nonconsecutive lines from a file.
sed -n 'G; s/n/&&/; /^([ -~]*n).*n1/d; s/n//; h; P’

Delete all lines except duplicate lines (emulates “uniq -d”).
sed '$!N; s/^(.*)n1$/1/; t; D'

Delete the first line of a file
sed '1d'

Delete the first 10 lines of a file
sed '1,10d'

Delete the last line of a file
sed '$d'

Delete the last 2 lines of a file
sed 'N;$!P;$!D;$d'

Delete the last 10 lines of a file
sed -n -e :a -e '1,10!{P;N;D;};N;ba'

Delete lines matching pattern
sed '/pattern/d'

Delete ALL blank lines from a file (same as “grep ‘.’ “)
sed '/^$/d'

Remove most HTML tags (accommodates multiple-line tags)
sed -e :a -e 's/<[^>]*>//g;/